SlideShare a Scribd company logo
1 of 26
Introduction to Verilog HDL
Jyun-Kai HuSeptember 11, 2020
Outline
 Verilog Semantic Introduction
 Continuous assignment
 Nonblocking assignment
 Simulation by VCS
 Code Coverage
2
Language Relationship
Verilog
SystemVerilog
UVM
class librarySynthesizable
SystemVerilog
Synthesizable
Verilog
3
Basic Syntax
4
1 module Top;
2 initial $display(“hello, world");
3 endmodule
this will be executed at program startup
like C’s printf, but automatically append newline character
uninstantiated module as top-level module
Value Set
5
 0 – logic zero
 1 – logic one
 x – unknown value
 both true & false, don’t care (in some condition)
 z – high impedance state
 neither true or false, open circuit
Event Control
6
 blocked until event occurs
 @a $display(a);
 call display by any value change in a
 @(posedge clk) $display(a);
 call display by positive edge on clk
to
from 0 1 x z
0 no pos pos pos
1 neg no neg neg
x neg pos no no
z neg pos no no
Always Construct
7
Basically, a, b, c have the same behavior
But assignment at time zero is unspecified
1 initial while (1) @u a = u;
2
3 initial forever @u b = u;
4
5 always @u c = u;
6
7 always d = u;
unintentional looping
Non-Constant Data Type
8
 Variable
 reg, integer, real, time…
 assigned only in procedure block or declaration
 initial, always, task, function block
 Net
 wire, tri, supply1…
 continuous assigned only
 net declaration assignment, port connection…
 have drive strength
Multiple Assignment
9
0 1 x z
0 0 x x 0
1 x 1 x 1
x x x x x
z 0 1 x z
1 reg a;
2 wire b;
3
4 wire #1 u = 0;
5 wire #1 v = 1;
6
7 always @u a = u;
8 always @v a = v;
9
10 assign b = u;
11 assign b = v;
1 unit delay, which is specified by timescale
result in 0 or 1 after 1 unit delay
(race condition)
result in unknown x after 1 unit delay
(multiple driven)
multiple driven on wire
Registers
10
 Typically composed of D flip-flops
 capture signal at the rising edge of the clock
 Not confused with the data type “reg“
1 module DFFR (
2 input CLK,
3 input D,
4 input R,
5 output reg Q
6 );
7 always @ (posedge CLK, negedge R)
8 if (!R)
9 Q = 0;
10 else
11 Q = D;
12 endmodule
D Flip-Flop
11
same as “or”
does that describe D flip-flop correctly?
implicit type wire
Shift Registers
12
1 module DFFR (
2 input CLK,
3 input D,
4 input R,
5 output reg Q
6 );
7 always @ (posedge CLK, negedge R)
8 if (!R)
9 Q = 0;
10 else
11 Q = D;
12 endmodule
1 module Testbench;
2 reg clk = 0,
3 d1 = 0;
4
5 DFFR dffr1 (
6 .CLK(clk),
7 .R(1'b1),
8 .D(d1),
9 .Q(q1)
10 );
11
12 DFFR dffr2 (
13 .CLK(clk),
14 .R(1'b1),
15 .D(q1),
16 .Q(q2)
17 );
18
19 always #1 clk = !clk;
20 initial #10 $finish;
21 endmodule
1 module DFFR (
2 input CLK,
3 input D,
4 input R,
5 output reg Q
6 );
7 always @ (posedge CLK, negedge R)
8 if (!R)
9 Q = 0;
10 else
11 Q = D;
12 endmodule
race condition!
Nonblocking Assignment
13
1 module DFFR (
2 input CLK,
3 input D,
4 input R,
5 output reg Q
6 );
7 always @ (posedge CLK, negedge R)
8 if (!R)
9 Q <= 0;
10 else
11 Q <= D;
12 endmodule
1 module Testbench;
2 reg clk = 0,
3 d1 = 0;
4
5 DFFR dffr1 (
6 .CLK(clk),
7 .R(1'b1),
8 .D(d1),
9 .Q(q1)
10 );
11
12 DFFR dffr2 (
13 .CLK(clk),
14 .R(1'b1),
15 .D(q1),
16 .Q(q2)
17 );
18
19 always #1 clk = !clk;
20 initial #10 $finish;
21 endmodule
1 module DFFR (
2 input CLK,
3 input D,
4 input R,
5 output reg Q
6 );
7 always @ (posedge CLK, negedge R)
8 if (!R)
9 Q <= 0;
10 else
11 Q <= D;
12 endmodule
evaluate both hand side immediately
but assign at the end of the time step
Stratified Event Queue
 4 event queues at the current simulation time
 Active
 Inactive
 #0, tf_synchronize, vpi_register_cb
 Nonblocking assign update
 <=
 Monitor
 $monitor, $strobe
14
Scheduling Algorithm
15
Simulation by VCS
Synopsys VCS Tool Chain
17
Separate Compilation
18
compile
time
elaboration
time
run
time
1 module Module;
2 reg in;
3 wire out;
4
5 SubModule subModule (
6 .in(in),
7 .out(out)
8 );
9
10 initial in = some_function();
11 endmodule
module, task, function will be resolved in elaboration time
i.e. the prototype can be unavailable during compile time
this makes separate compilation possible
incremental compilation isn’t based on timestamp in VCS
Interact with Your Simulation
 Compile time
 `define FNAME “vec1”
 vcs +define+FNAME=“vec2” …
 Elaboration time
 parameter IDX_FNAME = 1
 vcs –pvalue+<hier>.FNAME=2 …
 Run time
 $value$plusargs(“FNAME=%s”, FNAME)
 ./simv +FNAME=vec2
 $fscanf(“%s”, FNAME)
19
VCS Code Coverage
 Line coverage
 100% coverage is required
 Toggle coverage
 Branch coverage
 Condition coverage
 FSM coverage
20
Toggle Coverage
 Monitor transition on each bit
 0 -> 1, 1 -> 0
 x & z are ignored
 0 -> x -> 1 equals 0 -> 1
21
Verilog Branch
22
1 reg v;
2 reg [2:0] m = 3'b010,
3 n = 3'b110,
4 a, b, c;
5
6
7 if (v)
8 a = m;
9 else
10 a = n;
11
12
13 case (v)
14 1'b0:
15 b = m;
16 1'b1:
17 b = n;
18 endcase
19
20
21 c = v ? m : n;
v a b c
0 3’b110
1 3’b010
x or z 3’b110 old value 3’bx10
Branch Coverage
 Monitor scenarios
 if, case, casex, casez, ?:
23
a b c
0 1 -
0 0/x/z -
1 - 0
1 - 1
default - -
only 5 cases need to be covered
1 reg a, b, c;
2
3 case (a)
4 0:
5 if (b)
6 // do something
7 1:
8 c = c ? a : b;
9 endcase
Condition Coverage
 Monitor boolean formula
 ==, !=
 &&, ||
 &, |, ^, ~^  scalar-only
 vector condition
24
a b C
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
a b C
0 1 1
1 0 1
1 1 0
1 1 1
a
0
1
b
0
1
c
0
1
basic std allvectors
a && b && c
FSM coverage
 Monitor finite-state machine
 transition
 S0->S0, S0->S1, S1->S0
25
1 module FSM #(
2 parameter S0 = 0,
3 S1 = 1
4 ) (
5 input clk,
6 rstN,
7 in,
8 output reg state
9 );
10 always @ (posedge clk, negedge rstN)
11 if (!rstN)
12 state <= S0;
13 else case (state)
14 S0:
15 if (in)
16 state <= S1;
17 S1:
18 state <= S0;
19 endcase
20 endmodule
Coverage Analysis
26
we need to add test case to cover the
condition SEN = 0 & SRST = 1 in the
instance tb.scmCEDS

More Related Content

What's hot

Termòmetre The Arduino Starter Kit
Termòmetre The Arduino Starter KitTermòmetre The Arduino Starter Kit
Termòmetre The Arduino Starter KitLaia P
 
Pasos para simular una mss en vhdl
Pasos para simular una mss en vhdlPasos para simular una mss en vhdl
Pasos para simular una mss en vhdlIvan Salazar C
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorDaniel Roggen
 
Sequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experimentSequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experimentGouthaman V
 
Digital Voltmeter displaying voltage level on a seven segment display and com...
Digital Voltmeter displaying voltage level on a seven segment display and com...Digital Voltmeter displaying voltage level on a seven segment display and com...
Digital Voltmeter displaying voltage level on a seven segment display and com...Karthik Rathinavel
 
Hash Endereçamento Quadrático - Bean
Hash Endereçamento Quadrático - BeanHash Endereçamento Quadrático - Bean
Hash Endereçamento Quadrático - BeanElaine Cecília Gatto
 
javascript function & closure
javascript function & closurejavascript function & closure
javascript function & closureHika Maeng
 
Fpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineFpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineMalik Tauqir Hasan
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilogvenravi10
 
Assembly language
Assembly languageAssembly language
Assembly languagebryle12
 
An other world awaits you
An other world awaits youAn other world awaits you
An other world awaits you信之 岩永
 
Travel management
Travel managementTravel management
Travel management1Parimal2
 
Micro Assignment 2
Micro Assignment 2Micro Assignment 2
Micro Assignment 2babak danyal
 

What's hot (20)

Termòmetre The Arduino Starter Kit
Termòmetre The Arduino Starter KitTermòmetre The Arduino Starter Kit
Termòmetre The Arduino Starter Kit
 
Pasos para simular una mss en vhdl
Pasos para simular una mss en vhdlPasos para simular una mss en vhdl
Pasos para simular una mss en vhdl
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational Processor
 
Sequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experimentSequential Circuits I VLSI 9th experiment
Sequential Circuits I VLSI 9th experiment
 
Switch level modeling
Switch level modelingSwitch level modeling
Switch level modeling
 
07 sequential verilog
07 sequential verilog07 sequential verilog
07 sequential verilog
 
Digital Voltmeter displaying voltage level on a seven segment display and com...
Digital Voltmeter displaying voltage level on a seven segment display and com...Digital Voltmeter displaying voltage level on a seven segment display and com...
Digital Voltmeter displaying voltage level on a seven segment display and com...
 
REPORT
REPORTREPORT
REPORT
 
Hash Endereçamento Quadrático - Bean
Hash Endereçamento Quadrático - BeanHash Endereçamento Quadrático - Bean
Hash Endereçamento Quadrático - Bean
 
javascript function & closure
javascript function & closurejavascript function & closure
javascript function & closure
 
XMOS XS1 and XC
XMOS XS1 and XCXMOS XS1 and XC
XMOS XS1 and XC
 
Fpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineFpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machine
 
FINISHED_CODE
FINISHED_CODEFINISHED_CODE
FINISHED_CODE
 
Appsec obfuscator reloaded
Appsec obfuscator reloadedAppsec obfuscator reloaded
Appsec obfuscator reloaded
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilog
 
Assembly language
Assembly languageAssembly language
Assembly language
 
An other world awaits you
An other world awaits youAn other world awaits you
An other world awaits you
 
Tdm to vo ip 2
Tdm to vo ip 2Tdm to vo ip 2
Tdm to vo ip 2
 
Travel management
Travel managementTravel management
Travel management
 
Micro Assignment 2
Micro Assignment 2Micro Assignment 2
Micro Assignment 2
 

Similar to Introduction to Verilog & code coverage

Digital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsDigital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsIndira Priyadarshini
 
verilog interview
verilog interview verilog interview
verilog interview Maitrik Shah
 
HDL PROGRAMMING-3.pdf
HDL PROGRAMMING-3.pdfHDL PROGRAMMING-3.pdf
HDL PROGRAMMING-3.pdfkaarthikK6
 
Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014Béo Tú
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhtsBéo Tú
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab reportJinesh Kb
 
lecture8_Cuong.ppt
lecture8_Cuong.pptlecture8_Cuong.ppt
lecture8_Cuong.pptHongV34104
 
Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfVerilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfsagar414433
 
Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfVerilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfsagar414433
 
dokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfdokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfVelmathi Saravanan
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisitionazhar557
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Béo Tú
 

Similar to Introduction to Verilog & code coverage (20)

Digital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsDigital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential Circuits
 
Verilog_Examples (1).pdf
Verilog_Examples (1).pdfVerilog_Examples (1).pdf
Verilog_Examples (1).pdf
 
verilog interview
verilog interview verilog interview
verilog interview
 
Fpga creating counter with internal clock
Fpga   creating counter with internal clockFpga   creating counter with internal clock
Fpga creating counter with internal clock
 
HDL PROGRAMMING-3.pdf
HDL PROGRAMMING-3.pdfHDL PROGRAMMING-3.pdf
HDL PROGRAMMING-3.pdf
 
Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab report
 
verilog ppt .pdf
verilog ppt .pdfverilog ppt .pdf
verilog ppt .pdf
 
lecture8_Cuong.ppt
lecture8_Cuong.pptlecture8_Cuong.ppt
lecture8_Cuong.ppt
 
Uart
UartUart
Uart
 
Verilogforlab
VerilogforlabVerilogforlab
Verilogforlab
 
Verilog Cheat sheet-2 (1).pdf
Verilog Cheat sheet-2 (1).pdfVerilog Cheat sheet-2 (1).pdf
Verilog Cheat sheet-2 (1).pdf
 
Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfVerilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdf
 
Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfVerilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdf
 
vhdll.docx
vhdll.docxvhdll.docx
vhdll.docx
 
dokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfdokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdf
 
Basic-VHDL-Constructs1.ppt
Basic-VHDL-Constructs1.pptBasic-VHDL-Constructs1.ppt
Basic-VHDL-Constructs1.ppt
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisition
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

Introduction to Verilog & code coverage

  • 1. Introduction to Verilog HDL Jyun-Kai HuSeptember 11, 2020
  • 2. Outline  Verilog Semantic Introduction  Continuous assignment  Nonblocking assignment  Simulation by VCS  Code Coverage 2
  • 4. Basic Syntax 4 1 module Top; 2 initial $display(“hello, world"); 3 endmodule this will be executed at program startup like C’s printf, but automatically append newline character uninstantiated module as top-level module
  • 5. Value Set 5  0 – logic zero  1 – logic one  x – unknown value  both true & false, don’t care (in some condition)  z – high impedance state  neither true or false, open circuit
  • 6. Event Control 6  blocked until event occurs  @a $display(a);  call display by any value change in a  @(posedge clk) $display(a);  call display by positive edge on clk to from 0 1 x z 0 no pos pos pos 1 neg no neg neg x neg pos no no z neg pos no no
  • 7. Always Construct 7 Basically, a, b, c have the same behavior But assignment at time zero is unspecified 1 initial while (1) @u a = u; 2 3 initial forever @u b = u; 4 5 always @u c = u; 6 7 always d = u; unintentional looping
  • 8. Non-Constant Data Type 8  Variable  reg, integer, real, time…  assigned only in procedure block or declaration  initial, always, task, function block  Net  wire, tri, supply1…  continuous assigned only  net declaration assignment, port connection…  have drive strength
  • 9. Multiple Assignment 9 0 1 x z 0 0 x x 0 1 x 1 x 1 x x x x x z 0 1 x z 1 reg a; 2 wire b; 3 4 wire #1 u = 0; 5 wire #1 v = 1; 6 7 always @u a = u; 8 always @v a = v; 9 10 assign b = u; 11 assign b = v; 1 unit delay, which is specified by timescale result in 0 or 1 after 1 unit delay (race condition) result in unknown x after 1 unit delay (multiple driven) multiple driven on wire
  • 10. Registers 10  Typically composed of D flip-flops  capture signal at the rising edge of the clock  Not confused with the data type “reg“
  • 11. 1 module DFFR ( 2 input CLK, 3 input D, 4 input R, 5 output reg Q 6 ); 7 always @ (posedge CLK, negedge R) 8 if (!R) 9 Q = 0; 10 else 11 Q = D; 12 endmodule D Flip-Flop 11 same as “or” does that describe D flip-flop correctly? implicit type wire
  • 12. Shift Registers 12 1 module DFFR ( 2 input CLK, 3 input D, 4 input R, 5 output reg Q 6 ); 7 always @ (posedge CLK, negedge R) 8 if (!R) 9 Q = 0; 10 else 11 Q = D; 12 endmodule 1 module Testbench; 2 reg clk = 0, 3 d1 = 0; 4 5 DFFR dffr1 ( 6 .CLK(clk), 7 .R(1'b1), 8 .D(d1), 9 .Q(q1) 10 ); 11 12 DFFR dffr2 ( 13 .CLK(clk), 14 .R(1'b1), 15 .D(q1), 16 .Q(q2) 17 ); 18 19 always #1 clk = !clk; 20 initial #10 $finish; 21 endmodule 1 module DFFR ( 2 input CLK, 3 input D, 4 input R, 5 output reg Q 6 ); 7 always @ (posedge CLK, negedge R) 8 if (!R) 9 Q = 0; 10 else 11 Q = D; 12 endmodule race condition!
  • 13. Nonblocking Assignment 13 1 module DFFR ( 2 input CLK, 3 input D, 4 input R, 5 output reg Q 6 ); 7 always @ (posedge CLK, negedge R) 8 if (!R) 9 Q <= 0; 10 else 11 Q <= D; 12 endmodule 1 module Testbench; 2 reg clk = 0, 3 d1 = 0; 4 5 DFFR dffr1 ( 6 .CLK(clk), 7 .R(1'b1), 8 .D(d1), 9 .Q(q1) 10 ); 11 12 DFFR dffr2 ( 13 .CLK(clk), 14 .R(1'b1), 15 .D(q1), 16 .Q(q2) 17 ); 18 19 always #1 clk = !clk; 20 initial #10 $finish; 21 endmodule 1 module DFFR ( 2 input CLK, 3 input D, 4 input R, 5 output reg Q 6 ); 7 always @ (posedge CLK, negedge R) 8 if (!R) 9 Q <= 0; 10 else 11 Q <= D; 12 endmodule evaluate both hand side immediately but assign at the end of the time step
  • 14. Stratified Event Queue  4 event queues at the current simulation time  Active  Inactive  #0, tf_synchronize, vpi_register_cb  Nonblocking assign update  <=  Monitor  $monitor, $strobe 14
  • 17. Synopsys VCS Tool Chain 17
  • 18. Separate Compilation 18 compile time elaboration time run time 1 module Module; 2 reg in; 3 wire out; 4 5 SubModule subModule ( 6 .in(in), 7 .out(out) 8 ); 9 10 initial in = some_function(); 11 endmodule module, task, function will be resolved in elaboration time i.e. the prototype can be unavailable during compile time this makes separate compilation possible incremental compilation isn’t based on timestamp in VCS
  • 19. Interact with Your Simulation  Compile time  `define FNAME “vec1”  vcs +define+FNAME=“vec2” …  Elaboration time  parameter IDX_FNAME = 1  vcs –pvalue+<hier>.FNAME=2 …  Run time  $value$plusargs(“FNAME=%s”, FNAME)  ./simv +FNAME=vec2  $fscanf(“%s”, FNAME) 19
  • 20. VCS Code Coverage  Line coverage  100% coverage is required  Toggle coverage  Branch coverage  Condition coverage  FSM coverage 20
  • 21. Toggle Coverage  Monitor transition on each bit  0 -> 1, 1 -> 0  x & z are ignored  0 -> x -> 1 equals 0 -> 1 21
  • 22. Verilog Branch 22 1 reg v; 2 reg [2:0] m = 3'b010, 3 n = 3'b110, 4 a, b, c; 5 6 7 if (v) 8 a = m; 9 else 10 a = n; 11 12 13 case (v) 14 1'b0: 15 b = m; 16 1'b1: 17 b = n; 18 endcase 19 20 21 c = v ? m : n; v a b c 0 3’b110 1 3’b010 x or z 3’b110 old value 3’bx10
  • 23. Branch Coverage  Monitor scenarios  if, case, casex, casez, ?: 23 a b c 0 1 - 0 0/x/z - 1 - 0 1 - 1 default - - only 5 cases need to be covered 1 reg a, b, c; 2 3 case (a) 4 0: 5 if (b) 6 // do something 7 1: 8 c = c ? a : b; 9 endcase
  • 24. Condition Coverage  Monitor boolean formula  ==, !=  &&, ||  &, |, ^, ~^  scalar-only  vector condition 24 a b C 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 a b C 0 1 1 1 0 1 1 1 0 1 1 1 a 0 1 b 0 1 c 0 1 basic std allvectors a && b && c
  • 25. FSM coverage  Monitor finite-state machine  transition  S0->S0, S0->S1, S1->S0 25 1 module FSM #( 2 parameter S0 = 0, 3 S1 = 1 4 ) ( 5 input clk, 6 rstN, 7 in, 8 output reg state 9 ); 10 always @ (posedge clk, negedge rstN) 11 if (!rstN) 12 state <= S0; 13 else case (state) 14 S0: 15 if (in) 16 state <= S1; 17 S1: 18 state <= S0; 19 endcase 20 endmodule
  • 26. Coverage Analysis 26 we need to add test case to cover the condition SEN = 0 & SRST = 1 in the instance tb.scmCEDS