SlideShare a Scribd company logo
I-CHIP
VERILOG HDL
Hardware Description Language
• With the advent of SSI, MSI, LSI and now VLSI, designers could put
thousands of gates on a single chip.
• Due to circuits becoming very complicated, designs could no longer be
done by hand, and the need came to automate these design processes.
• Therefore came the advent of Hardware Description Languages (HDLs, like
VHDL, Verilog, System Verilog) and Electronic Design Automation (EDA)
tools like Xilinx, which generate corresponding circuits to the written code.
• It resembles an ordinary computer programming language, such as C, but
is specifically oriented to describing hardware structures and the behavior
of logic circuits.
• By describing designs in HDLs, functional verification of the design can be
done early in the design cycle.
• Facilitates prototyping digital hardware before fabrication.
a verilog presentation for deep concept understa
Verilog HDL
• Verification + Logic = Verilog
• Hardware modeling and verification of digital circuit elements.
• It has many versions, but Verilog-2001 or Verilog-2005 are most
commonly used.
• Two parts to a creating a digital element in HDL:
• Design of a digital circuit in HDL
• Verification of the circuit: to provide it different sets of inputs and make
sure it behaves as intended.
• System Verilog: superset of Verilog, having made enhancements suited
for verification purposes.
Functional Verification and Logic
Design
• The spec is translated to HDL code
by the design team.
• The verification plan is carried out
by setting out test cases to be
verified.
• Done parallelly, hand-in-hand.
Chip Design Life Cycle
Circuit Design
• The HDL code is mapped to actual
hardware components according
to the target hardware (FPGA,
ASIC).
• !! The code for your design must
always be synthesizable
• have hardware corresponding to
it.
• Feasible to practically implement.
• Timing constraints are verified.
Chip Design Life Cycle
Verilog HDL
• HDL is meant to describe the behavior or functionality of hardware. It
is not a software language.
• Error free code is not guaranteed to be synthesizable to the correct
hardware.
• Hardware Parallelism is achieved, whereas software languages execute
code sequentially.
Verilog HDL: Design and Testbench
Verilog Syntax
Verilog: Module
• Black-box, or basic hardware that provides some functionality.
• The ports of a module are declared as input, output, or inout.
• Each line is terminated.
• Verilog is a CASE SENSITIVE LANGUAGE
• Defining one module within another module is illegal.
• Nesting of comments is illegal.
Verilog: Module
module modulename(port list);
port list declarations;
internal signal declarations;
behaviour;
//single line comments
/* double line
comments */
endmodule
Verilog: Variable/Module Names
• Variable names consist of alphanumeric characters, _ and $.
• They must begin with an alphabet or _
• They should be descriptive
• No keyword should be used as a variable name.
• $display
• 2scomp
• $decoder
• and, or, not
Verilog: Values
• Verilog is a 4 valued language
• Logic 1
• Logic 0
• X – unknown state
• Z – high impedance state
Verilog: Specifying Numbers
<size>’<base><number>
• size is specified in decimal
• If unspecified, default value is 32-bits
• Number is comprised of values from 0-9, a-f, x, or z
• base – legal values include
• b or B, h or H, o or O, d or D
• Default value is decimal
Verilog: Specifying Numbers
<size>’<base><number>
Signed number specification
• Negative numbers are stored as 2’s complement and the negative sign
must be specified before the size.
• Placing _ in numbers improves readability
• ? Is equivalent to z
Verilog: Data Types (Reg and Net)
Net
• Represent connections between hardware components.
• Nets must be continuously driven by the devices they are connected to
• Default: one bit value, default value is z
• Can be assigned only through continuous assignments.
• wire, wand, wor, tri, triand, trior, trireg
wire varname;
wire [size-1:0]varname;
Verilog: Data Types (Reg and Net)
Reg
• Used to store a value with respect to the Verilog language.
• Retain a value until a new value is assigned to them.
• Assigned in only procedural blocks (procedural assignments).
• Default value is x.
integer varname;
reg [size-1:0]varname; 128 34 87 1 32
Verilog: Data Types (Reg and Net)
Reg
• integer – used to store a 32-bit value, commonly used in loops.
• real
• time – used to store the simulation time
Verilog: Vectors
• By default, reg and net values are 1-bit.
reg/wire [size-1:0] varname; //Little Endian Notation
reg [7:0]A; A[6:4] wrong A[4:6] A = 8’10101010
reg/wire [0:size-1] varname; //Big Endian Notation
reg [0:7]B; B[1:3] = 3’b111 B[3:1] xxx wrong
7 6 5 4 3 2 1 0
1 1 1 1 1 1
0 1 2 3 4 5 6 7
1 1 1
Verilog: Vectors Part Select
• Part select of vectors must be in the order the vector is declared.
7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7
Verilog: Vector Variable Part Select
varname[starting_bit+:width] increment from starting bit
varname[starting_bit-:width] decrement from starting bit
Verilog: Vectors
reg/wire [N-1:0]x; one N-bit variable
• Can part select
• Can directly assign N-bit value in one assignment
• x = 8’b0110_1010
Reg/wire x[N-1:0]; N 1-bit variable
• Cannot part select
• Bits can be accessed or assigned one at a time.
• x[5] = 1’b0;
Verilog: Vectors
reg/wire [width-1:0] varname [depth-1:0]
integer varname[N-1:0]
reg [3:0] A[7:0] A[0] = 4’1111;
Verilog: Strings
• Can be assigned to reg values
• Each character occupies 8 bits/1 byte
Gate Level Modeling
• Use of primitives
• and, nand, or, nor, xor, xnor, buf, not
• bufif0, bufif1, notif0, notif1
Gate Level Modeling
Gate Level Modeling
Gate Level Modeling
• Use of primitives
• and, nand, or, nor, xor, xnor, buf, not
• bufif0, bufif1, notif0, notif1
Dataflow Modeling
• Describes functionality of a device based on the dataflow and the
transformations(arithmetic or Boolean expressions) carried out on the
data from input side to output side.
Verilog: Variable Assignments
2 types of assignments
• Continuous Assignments: for wire/net, infer combinational logic
• Procedural Assignments: for reg, infer combinational or sequential
logic
Continuous Assignments:
assign varname = <boolean/arithmetic expression>
Verilog: Variable Assignments
2 types of assignments
• Continuous Assignments: for wire/net
• Procedural Assignments: for reg
Procedural Blocks: initial and always
initial begin
//assignments, behavior
end
always@(negedge clk) begin
//behavior
end
Verilog: Types of Procedural Assignments
1. Blocking Assignments
• Used for implementation of combinational logic in procedural
blocks.
• Blocking assignments are executed sequentially, one after another.
• They do not block execution of other nonblocking assignments in a
parallel block.
Verilog: Types of Procedural Assignments
2. Nonblocking Assignments (<=)
• Used for implementation of sequential logic in procedural blocks.
• They are used to simulate the hardware parallelism.
• First, all of the LHS values are calculated and saved at a temporary
location.
• Then, at the end of the current time-step, they are assigned at
once to the RHS.
Verilog: Types of Procedural Assignments
2. Nonblocking Assignments
Verilog: To print a value
Verilog: System Task - To print a value
• Use system tasks $display and $monitor to print values.
• $display is written in a procedural block, and executed when
encountered only once.
• $monitor executes and displays values each time one of its arguments
changes in value
• Only one monitor must be used.
• If more than one monitor are used in a module, the last monitor will be the
one that is active. The others will be overwritten.
$display(“<format specifiers>”, var1, var2…);
$monitor(“<format specifiers>”, var1, var2…);
Verilog: Module Instantiations
• A module can be instantiated within another for use.
• There are 2 types of instantiations
• Named/Explicit Instantiations
• Positional Instantiations
module dff(input clk, d, output
q);
wire a;
//working
endmodule
module shiftregister();
Reg clock, datain;
Dff name(.clk(clock), .d(datain)
endmodule
Verilog: Module Instantiations
• A module can be instantiated within another for use.
• There are 2 types of instantiations
• Named/Explicit Instantiations
• Positional Instantiations
Verilog: Module Instantiations
• Module instantiations create a hierarchy in the design.
• Signals local to each module cannot be accessed directly from their top
module, but instead through a hierarchical referencing dot (.) operator.
• Use $display(“%m”) to get the location in hierarchy
Verilog: Operators
Verilog: Arithmetic Operators
• Result will evaluate to x if either of
the operands has an x value in any of
its bits.
Verilog: Logical Operators
• Used for logical expressions.
• A nonzero value is regarded as true, a zero value as false.
Verilog: Bitwise Operators
Verilog: Reduction Operators
• Perform the logical operation on all the individual bits to yield a one-bit result.
• Useful for parity checkers/generators where all bits must be xor/xnor’d
• Useful for creating multi-input gates.
Verilog: Shift Operators
• Shift the vector
• Useful for multiplication or division by powers of 2, or shift and add operations.
Verilog: Concatenation {var1, var2…}
• Concatenates the arguments into a single number.
• Can take only sized arguments.
Verilog: Replication {m{n}}
• Replicates the n argument, m-times.
Verilog: Ternary Operator ?:
Exp ? True : false;
//multiplexer
assign out = sel?d1:d0;
4:1
out = sel1? Sel0?d3:d2 : sel0?d1:d0;
Out = exp? 4’b1101 : 4’b1011 out=4’b1xx1;
• If the exp evaluates to x, then both true and false expressions are compared
bit by bit.
• The bit is returned where the bits match
• X is returned where the bits are different.
Verilog: if, else if (exp) begin
//code
end
else if (exp) begin
//code
end
else begin
//code
end
• Always in a procedural block.
• Always, initial
Verilog: case statement
• The alternatives are matched with the expression one by one, bit-by-bit, comparing
0, 1, x, and z.
• The expression that matches is then executed.
Verilog: casex and casez statement
• In casex, the x and z are treated as don’t cares
• In casez, the z are treated as don’t cares
Verilog: While Loop
• Run continuously until the expression becomes false.
Verilog: Repeat Loop
• Run a fixed number of times
• The argument cannot be a general expression, it must be a number.
• Useful for defining clock signals.
Verilog: Forever Loop
• Runs continuously, forever, with no end.
• Always defined in procedural blocks.
• They must be terminated by a $finish statement in a parallel block.
Verilog: For Loop
Consist of
• An initial condition
• A loop condition
• An assignment to change the value of the loop variable
• Loops unroll into their corresponding set of assignments.
Verilog: Latch-based Designs
• Leaving if..else statements incomplete i.e. not covering all possible scenarios leads
to inadvertent synthesis of sequential logic where combinational logic was intended.
• It leads to synthesis of latch based designs to store the previous value in the
scenarios that have been missed, leading to a mismatch from the intended
combinational design.
• To prevent this, ensure that an else(for if/else) or default(case) has been defined.
module mux(input sel, d0,
d1, output out);
always@(sel, d0, d1) begin
if(sel) out=d1;
else out=d0;
end
endmodule
module dlatch(input en, d, output q);
always@(en, d) begin
if(en) q=d;
endmodule
Verilog: Reset Syntax for Sequential Ckts.
2 types of resets: Synchronous & Asynchronous
• Synchronous reset is sampled at the clock edge
• Asynchronous reset does not have any dependency on a synchronizing signal(clock) and it resets the circuit as
soon as asserted.
Further, we have 2 more types of resets:
• Active-Low: A logic 0 on the reset line is used to reset the circuit. The line is held high in idle state.
• Active-High: A logic 1 on the reset line is used to reset the circuit. The line is held low in idle state.
Verilog: Reset Syntax
always@(posedge clk or negedge rst)
begin
if(!rst) //reset the circuit
else //functionality
end
always@(posedge clk or posedge rst)
begin
if(rst) //reset the circuit
else //functionality
end
always@(posedge clk) begin
if(rst) //reset the
circuit
else //functionality
end
always@(posedge clk) begin
if(!rst) //reset the
circuit
else //functionality
end
Verilog: Parameters
• Constants defined in a module.
• Enhance Reusability of the code by allowing overwriting of parameters of modules
according to requirement.
• In positional overwriting of parameters, the parameters will be assigned values in
the order defined in module.
• If not overwritten, the default value of the parameter is used.
module_name #(parameter1, parameter2…) varname(<port connections)
• Named overwriting of parameters
module_name #(.NAME1(parameter1), .NAME2(parameter2)…) varname(<port connections)
• Overwriting using defparam
Verilog: Local Parameters
• Constants defined in a module which are local to that module.
• They cannot be overwritten by instantiation.
• localparam var1 = <val>, var2 = <val>…;
• Especially useful for encoding state machines, where we do not want the state to
change by overwriting during instantiations.
Verilog: Inter & Intra-Assignment Delay
• Inter-Assignment delay: delay between the various assignments.
• The statement is evaluated and executed at the time it is scheduled to be.
• Intra-Assignment delay: delay within an assignment
• The RHS values are first evaluated and stored at a location. The assignment is made after
the delay time has elapsed.
a verilog presentation for deep concept understa
Verilog: $monitor, $display, $strobe
$display
• Executes once to print the values.
• Executes in the active region of event queue, and thus cannot print values after non-blocking
assignments in that time-step.
$monitor
• Remains active throughout the lifetime of the program, and prints values each time an update
is made to its arguments.
• Executes in the postponed region of event-queue and therefore can print values updated after
non-blocking assignments
$strobe
• Executes once to print the values.
• Executes in the postponed region of event-queue and therefore can print values updated after
non-blocking assignments
Thank You

More Related Content

PPTX
Verilog Final Probe'22.pptx
PDF
Verilog
PPTX
Verilog overview
PDF
Short Notes on Verilog and SystemVerilog
PDF
Verilog HDL
PDF
Verilog Cheat sheet-2 (1).pdf
PDF
Verilog_Cheat_sheet_1672542963.pdf
PDF
Verilog_Cheat_sheet_1672542963.pdf
Verilog Final Probe'22.pptx
Verilog
Verilog overview
Short Notes on Verilog and SystemVerilog
Verilog HDL
Verilog Cheat sheet-2 (1).pdf
Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdf

Similar to a verilog presentation for deep concept understa (20)

PDF
Verilog_Overview.pdf
PPTX
Verilogspk1
PDF
verilog ppt .pdf
PPTX
HDL_verilog_unit_1 for engagement subjects and technology
PDF
SKEL 4273 CAD with HDL Topic 2
PPT
Coding verilog
PPTX
systemverilog and veriog presentation
PPTX
systemverilog and veriog presentation
PDF
dokumen.tips_verilog-basic-ppt.pdf
PPT
Verilog Lecture2 thhts
PPTX
very large scale integration ppt vlsi.pptx
PDF
PPTX
Experiment 1- UCS 704_ESD engineering money waste
PPT
PPT
Verilog tutorial
PDF
Verilog tutorial
PDF
Verilog tutorial
PDF
Verilog HDL coding in VLSi Design circuits.pdf
PDF
VHDL- data types
PPTX
INTERN VLSI 1.pptx INTERN VLSI 1.pptx ppt
Verilog_Overview.pdf
Verilogspk1
verilog ppt .pdf
HDL_verilog_unit_1 for engagement subjects and technology
SKEL 4273 CAD with HDL Topic 2
Coding verilog
systemverilog and veriog presentation
systemverilog and veriog presentation
dokumen.tips_verilog-basic-ppt.pdf
Verilog Lecture2 thhts
very large scale integration ppt vlsi.pptx
Experiment 1- UCS 704_ESD engineering money waste
Verilog tutorial
Verilog tutorial
Verilog tutorial
Verilog HDL coding in VLSi Design circuits.pdf
VHDL- data types
INTERN VLSI 1.pptx INTERN VLSI 1.pptx ppt
Ad

Recently uploaded (20)

PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Welding lecture in detail for understanding
PPT
Project quality management in manufacturing
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Well-logging-methods_new................
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
OOP with Java - Java Introduction (Basics)
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Lecture Notes Electrical Wiring System Components
Operating System & Kernel Study Guide-1 - converted.pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Welding lecture in detail for understanding
Project quality management in manufacturing
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Well-logging-methods_new................
Internet of Things (IOT) - A guide to understanding
UNIT-1 - COAL BASED THERMAL POWER PLANTS
UNIT 4 Total Quality Management .pptx
OOP with Java - Java Introduction (Basics)
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
R24 SURVEYING LAB MANUAL for civil enggi
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Ad

a verilog presentation for deep concept understa

  • 2. Hardware Description Language • With the advent of SSI, MSI, LSI and now VLSI, designers could put thousands of gates on a single chip. • Due to circuits becoming very complicated, designs could no longer be done by hand, and the need came to automate these design processes. • Therefore came the advent of Hardware Description Languages (HDLs, like VHDL, Verilog, System Verilog) and Electronic Design Automation (EDA) tools like Xilinx, which generate corresponding circuits to the written code. • It resembles an ordinary computer programming language, such as C, but is specifically oriented to describing hardware structures and the behavior of logic circuits. • By describing designs in HDLs, functional verification of the design can be done early in the design cycle. • Facilitates prototyping digital hardware before fabrication.
  • 4. Verilog HDL • Verification + Logic = Verilog • Hardware modeling and verification of digital circuit elements. • It has many versions, but Verilog-2001 or Verilog-2005 are most commonly used. • Two parts to a creating a digital element in HDL: • Design of a digital circuit in HDL • Verification of the circuit: to provide it different sets of inputs and make sure it behaves as intended. • System Verilog: superset of Verilog, having made enhancements suited for verification purposes.
  • 5. Functional Verification and Logic Design • The spec is translated to HDL code by the design team. • The verification plan is carried out by setting out test cases to be verified. • Done parallelly, hand-in-hand. Chip Design Life Cycle
  • 6. Circuit Design • The HDL code is mapped to actual hardware components according to the target hardware (FPGA, ASIC). • !! The code for your design must always be synthesizable • have hardware corresponding to it. • Feasible to practically implement. • Timing constraints are verified. Chip Design Life Cycle
  • 7. Verilog HDL • HDL is meant to describe the behavior or functionality of hardware. It is not a software language. • Error free code is not guaranteed to be synthesizable to the correct hardware. • Hardware Parallelism is achieved, whereas software languages execute code sequentially.
  • 8. Verilog HDL: Design and Testbench
  • 10. Verilog: Module • Black-box, or basic hardware that provides some functionality. • The ports of a module are declared as input, output, or inout. • Each line is terminated. • Verilog is a CASE SENSITIVE LANGUAGE • Defining one module within another module is illegal. • Nesting of comments is illegal.
  • 11. Verilog: Module module modulename(port list); port list declarations; internal signal declarations; behaviour; //single line comments /* double line comments */ endmodule
  • 12. Verilog: Variable/Module Names • Variable names consist of alphanumeric characters, _ and $. • They must begin with an alphabet or _ • They should be descriptive • No keyword should be used as a variable name. • $display • 2scomp • $decoder • and, or, not
  • 13. Verilog: Values • Verilog is a 4 valued language • Logic 1 • Logic 0 • X – unknown state • Z – high impedance state
  • 14. Verilog: Specifying Numbers <size>’<base><number> • size is specified in decimal • If unspecified, default value is 32-bits • Number is comprised of values from 0-9, a-f, x, or z • base – legal values include • b or B, h or H, o or O, d or D • Default value is decimal
  • 15. Verilog: Specifying Numbers <size>’<base><number> Signed number specification • Negative numbers are stored as 2’s complement and the negative sign must be specified before the size. • Placing _ in numbers improves readability • ? Is equivalent to z
  • 16. Verilog: Data Types (Reg and Net) Net • Represent connections between hardware components. • Nets must be continuously driven by the devices they are connected to • Default: one bit value, default value is z • Can be assigned only through continuous assignments. • wire, wand, wor, tri, triand, trior, trireg wire varname; wire [size-1:0]varname;
  • 17. Verilog: Data Types (Reg and Net) Reg • Used to store a value with respect to the Verilog language. • Retain a value until a new value is assigned to them. • Assigned in only procedural blocks (procedural assignments). • Default value is x. integer varname; reg [size-1:0]varname; 128 34 87 1 32
  • 18. Verilog: Data Types (Reg and Net) Reg • integer – used to store a 32-bit value, commonly used in loops. • real • time – used to store the simulation time
  • 19. Verilog: Vectors • By default, reg and net values are 1-bit. reg/wire [size-1:0] varname; //Little Endian Notation reg [7:0]A; A[6:4] wrong A[4:6] A = 8’10101010 reg/wire [0:size-1] varname; //Big Endian Notation reg [0:7]B; B[1:3] = 3’b111 B[3:1] xxx wrong 7 6 5 4 3 2 1 0 1 1 1 1 1 1 0 1 2 3 4 5 6 7 1 1 1
  • 20. Verilog: Vectors Part Select • Part select of vectors must be in the order the vector is declared. 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7
  • 21. Verilog: Vector Variable Part Select varname[starting_bit+:width] increment from starting bit varname[starting_bit-:width] decrement from starting bit
  • 22. Verilog: Vectors reg/wire [N-1:0]x; one N-bit variable • Can part select • Can directly assign N-bit value in one assignment • x = 8’b0110_1010 Reg/wire x[N-1:0]; N 1-bit variable • Cannot part select • Bits can be accessed or assigned one at a time. • x[5] = 1’b0;
  • 23. Verilog: Vectors reg/wire [width-1:0] varname [depth-1:0] integer varname[N-1:0] reg [3:0] A[7:0] A[0] = 4’1111;
  • 24. Verilog: Strings • Can be assigned to reg values • Each character occupies 8 bits/1 byte
  • 25. Gate Level Modeling • Use of primitives • and, nand, or, nor, xor, xnor, buf, not • bufif0, bufif1, notif0, notif1
  • 28. Gate Level Modeling • Use of primitives • and, nand, or, nor, xor, xnor, buf, not • bufif0, bufif1, notif0, notif1
  • 29. Dataflow Modeling • Describes functionality of a device based on the dataflow and the transformations(arithmetic or Boolean expressions) carried out on the data from input side to output side.
  • 30. Verilog: Variable Assignments 2 types of assignments • Continuous Assignments: for wire/net, infer combinational logic • Procedural Assignments: for reg, infer combinational or sequential logic Continuous Assignments: assign varname = <boolean/arithmetic expression>
  • 31. Verilog: Variable Assignments 2 types of assignments • Continuous Assignments: for wire/net • Procedural Assignments: for reg Procedural Blocks: initial and always initial begin //assignments, behavior end always@(negedge clk) begin //behavior end
  • 32. Verilog: Types of Procedural Assignments 1. Blocking Assignments • Used for implementation of combinational logic in procedural blocks. • Blocking assignments are executed sequentially, one after another. • They do not block execution of other nonblocking assignments in a parallel block.
  • 33. Verilog: Types of Procedural Assignments 2. Nonblocking Assignments (<=) • Used for implementation of sequential logic in procedural blocks. • They are used to simulate the hardware parallelism. • First, all of the LHS values are calculated and saved at a temporary location. • Then, at the end of the current time-step, they are assigned at once to the RHS.
  • 34. Verilog: Types of Procedural Assignments 2. Nonblocking Assignments
  • 35. Verilog: To print a value
  • 36. Verilog: System Task - To print a value • Use system tasks $display and $monitor to print values. • $display is written in a procedural block, and executed when encountered only once. • $monitor executes and displays values each time one of its arguments changes in value • Only one monitor must be used. • If more than one monitor are used in a module, the last monitor will be the one that is active. The others will be overwritten. $display(“<format specifiers>”, var1, var2…); $monitor(“<format specifiers>”, var1, var2…);
  • 37. Verilog: Module Instantiations • A module can be instantiated within another for use. • There are 2 types of instantiations • Named/Explicit Instantiations • Positional Instantiations module dff(input clk, d, output q); wire a; //working endmodule module shiftregister(); Reg clock, datain; Dff name(.clk(clock), .d(datain) endmodule
  • 38. Verilog: Module Instantiations • A module can be instantiated within another for use. • There are 2 types of instantiations • Named/Explicit Instantiations • Positional Instantiations
  • 39. Verilog: Module Instantiations • Module instantiations create a hierarchy in the design. • Signals local to each module cannot be accessed directly from their top module, but instead through a hierarchical referencing dot (.) operator. • Use $display(“%m”) to get the location in hierarchy
  • 41. Verilog: Arithmetic Operators • Result will evaluate to x if either of the operands has an x value in any of its bits.
  • 42. Verilog: Logical Operators • Used for logical expressions. • A nonzero value is regarded as true, a zero value as false.
  • 44. Verilog: Reduction Operators • Perform the logical operation on all the individual bits to yield a one-bit result. • Useful for parity checkers/generators where all bits must be xor/xnor’d • Useful for creating multi-input gates.
  • 45. Verilog: Shift Operators • Shift the vector • Useful for multiplication or division by powers of 2, or shift and add operations.
  • 46. Verilog: Concatenation {var1, var2…} • Concatenates the arguments into a single number. • Can take only sized arguments.
  • 47. Verilog: Replication {m{n}} • Replicates the n argument, m-times.
  • 48. Verilog: Ternary Operator ?: Exp ? True : false; //multiplexer assign out = sel?d1:d0; 4:1 out = sel1? Sel0?d3:d2 : sel0?d1:d0; Out = exp? 4’b1101 : 4’b1011 out=4’b1xx1; • If the exp evaluates to x, then both true and false expressions are compared bit by bit. • The bit is returned where the bits match • X is returned where the bits are different.
  • 49. Verilog: if, else if (exp) begin //code end else if (exp) begin //code end else begin //code end • Always in a procedural block. • Always, initial
  • 50. Verilog: case statement • The alternatives are matched with the expression one by one, bit-by-bit, comparing 0, 1, x, and z. • The expression that matches is then executed.
  • 51. Verilog: casex and casez statement • In casex, the x and z are treated as don’t cares • In casez, the z are treated as don’t cares
  • 52. Verilog: While Loop • Run continuously until the expression becomes false.
  • 53. Verilog: Repeat Loop • Run a fixed number of times • The argument cannot be a general expression, it must be a number. • Useful for defining clock signals.
  • 54. Verilog: Forever Loop • Runs continuously, forever, with no end. • Always defined in procedural blocks. • They must be terminated by a $finish statement in a parallel block.
  • 55. Verilog: For Loop Consist of • An initial condition • A loop condition • An assignment to change the value of the loop variable • Loops unroll into their corresponding set of assignments.
  • 56. Verilog: Latch-based Designs • Leaving if..else statements incomplete i.e. not covering all possible scenarios leads to inadvertent synthesis of sequential logic where combinational logic was intended. • It leads to synthesis of latch based designs to store the previous value in the scenarios that have been missed, leading to a mismatch from the intended combinational design. • To prevent this, ensure that an else(for if/else) or default(case) has been defined. module mux(input sel, d0, d1, output out); always@(sel, d0, d1) begin if(sel) out=d1; else out=d0; end endmodule module dlatch(input en, d, output q); always@(en, d) begin if(en) q=d; endmodule
  • 57. Verilog: Reset Syntax for Sequential Ckts. 2 types of resets: Synchronous & Asynchronous • Synchronous reset is sampled at the clock edge • Asynchronous reset does not have any dependency on a synchronizing signal(clock) and it resets the circuit as soon as asserted. Further, we have 2 more types of resets: • Active-Low: A logic 0 on the reset line is used to reset the circuit. The line is held high in idle state. • Active-High: A logic 1 on the reset line is used to reset the circuit. The line is held low in idle state.
  • 58. Verilog: Reset Syntax always@(posedge clk or negedge rst) begin if(!rst) //reset the circuit else //functionality end always@(posedge clk or posedge rst) begin if(rst) //reset the circuit else //functionality end always@(posedge clk) begin if(rst) //reset the circuit else //functionality end always@(posedge clk) begin if(!rst) //reset the circuit else //functionality end
  • 59. Verilog: Parameters • Constants defined in a module. • Enhance Reusability of the code by allowing overwriting of parameters of modules according to requirement. • In positional overwriting of parameters, the parameters will be assigned values in the order defined in module. • If not overwritten, the default value of the parameter is used. module_name #(parameter1, parameter2…) varname(<port connections) • Named overwriting of parameters module_name #(.NAME1(parameter1), .NAME2(parameter2)…) varname(<port connections) • Overwriting using defparam
  • 60. Verilog: Local Parameters • Constants defined in a module which are local to that module. • They cannot be overwritten by instantiation. • localparam var1 = <val>, var2 = <val>…; • Especially useful for encoding state machines, where we do not want the state to change by overwriting during instantiations.
  • 61. Verilog: Inter & Intra-Assignment Delay • Inter-Assignment delay: delay between the various assignments. • The statement is evaluated and executed at the time it is scheduled to be. • Intra-Assignment delay: delay within an assignment • The RHS values are first evaluated and stored at a location. The assignment is made after the delay time has elapsed.
  • 63. Verilog: $monitor, $display, $strobe $display • Executes once to print the values. • Executes in the active region of event queue, and thus cannot print values after non-blocking assignments in that time-step. $monitor • Remains active throughout the lifetime of the program, and prints values each time an update is made to its arguments. • Executes in the postponed region of event-queue and therefore can print values updated after non-blocking assignments $strobe • Executes once to print the values. • Executes in the postponed region of event-queue and therefore can print values updated after non-blocking assignments

Editor's Notes

  • #2: Advantage: Less time taken
  • #3: We will start at small level
  • #4: Advantage: Less time taken
  • #5: We will start at small level
  • #6: We will start at small level
  • #7: Advantage: Less time taken
  • #8: Advantage: Less time taken
  • #10: Advantage: Less time taken
  • #11: Advantage: Less time taken
  • #12: Advantage: Less time taken
  • #13: Advantage: Less time taken
  • #14: Advantage: Less time taken
  • #15: Advantage: Less time taken
  • #16: Advantage: Less time taken
  • #17: Advantage: Less time taken
  • #18: Advantage: Less time taken
  • #19: Advantage: Less time taken
  • #20: Advantage: Less time taken
  • #21: Advantage: Less time taken
  • #22: Advantage: Less time taken
  • #23: Advantage: Less time taken
  • #24: Advantage: Less time taken
  • #25: Advantage: Less time taken
  • #26: Advantage: Less time taken
  • #27: Advantage: Less time taken
  • #28: Advantage: Less time taken
  • #29: Advantage: Less time taken
  • #30: Advantage: Less time taken
  • #31: Advantage: Less time taken
  • #32: Advantage: Less time taken
  • #33: Advantage: Less time taken
  • #34: Advantage: Less time taken
  • #35: Advantage: Less time taken
  • #36: Advantage: Less time taken
  • #37: Advantage: Less time taken
  • #38: Advantage: Less time taken
  • #39: Advantage: Less time taken
  • #40: Advantage: Less time taken
  • #41: Advantage: Less time taken
  • #42: Advantage: Less time taken
  • #43: Advantage: Less time taken
  • #44: Advantage: Less time taken
  • #45: Advantage: Less time taken
  • #46: Advantage: Less time taken
  • #47: Advantage: Less time taken
  • #48: Advantage: Less time taken
  • #49: Advantage: Less time taken
  • #50: Advantage: Less time taken
  • #51: Advantage: Less time taken
  • #52: Advantage: Less time taken
  • #53: Advantage: Less time taken
  • #54: Advantage: Less time taken
  • #55: Advantage: Less time taken
  • #56: Advantage: Less time taken
  • #57: Advantage: Less time taken
  • #58: Advantage: Less time taken
  • #59: Advantage: Less time taken
  • #60: Advantage: Less time taken
  • #61: Advantage: Less time taken
  • #63: Advantage: Less time taken