SlideShare a Scribd company logo
1 of 16
• Register transfer level (RTL) Design
and Examples
• Register transfer level (RTL) Design
• Examples of RTL Verilog code
1
Register transfer level (RTL) Design
Register transfer level (RTL) Design Digital Circuit
2
Structural Verilog code is not practicable for designing complex circuit. In that case,
RTLVerilog code
is used to design digital circuit. RTL Verilog code of a digital design can be written in
two ways:
1) Using continuous assignment structures.
2) Using Procedural assignment structures.
RTL Coding using continuous assignment
• Modeling of digital circuit using continuous assignment structure is higher level of
abstraction than
structural Verilogcoding.
• It is named as continuous assignment because the assignments written in this
procedure are evaluated continuously whereas in procedural assignment
structure execution of a statement waits for the clock or other parameter. The
expression (in continuous assignment structure) is evaluated whenever any of
the operands changes.
• RTL coding using continuous assignment is usually used to model
combinational circuit which is
more complex than can be handled by structural modeling.
• The declaration ‘module’, ‘input’, ‘output’ and ‘endmodule’ are same as they
Register transfer level (RTL) Design
Examples RTL Verilog coding using continuous
Assignment
Example 1: Write Verilog code to represent the digital circuit that follows the
following logic equations.
Verilog
Code:
3
Register transfer level (RTL) Design
Examples RTL Verilog coding using continuous
Assignment (Cont.)
Example 2: A single bit adder (full
adder).
Verilog
Code:
4
Register transfer level (RTL) Design
Examples RTL Verilog coding using continuous
Assignment (Cont.)
Example 3: Write Verilog code to design 4-bit adder-subtractor circuit using
continuous assignment structure.
Verilog
Code:
5
Register transfer level (RTL) Design
Examples RTL Verilog coding using continuous
Assignment (Cont.)
Example 3: Write Verilog code to design a 2/1 MUX using continuous
assignment structure.
Verilog
Code:
6
Register transfer level (RTL) Design
RTL Verilog Code using Procedural
Assignment
7
Register transfer level (RTL) Design
• Structural Verilog coding and Verilog coding using continuous assignment
structure are used to design simple digital circuit.This approach is practical
when functional complexities are not much (gate count within few hundred).
• With the increase of functional complexities, the above two approaches are not
suitable approach. In designing complex digital circuit, procedural assignment
approach is used.
• In this approach, the functional behavior of the circuit is described using keyword
‘always’.
• Sensitivity list is used with the ‘always’ statement. Sensitivity list indicates ‘output is
sensitive to
what?’. It contains the list of specific inputs, which have effect on the outputs.
• Whenever any event (change) occurs in any of the parameter in the sensitivity list,
the always loop
will be executed.
How to write RTL Verilog code using Procedural assignment
• The declaration ‘module’, ‘input’, ‘output’ and ‘endmodule’ are same as used in
structural Verilog coding and RTL Verilog coding using continuous assignment
structure.
• It is important to remember that all the outputs have to be declare as register using
the keyword ‘reg’.
• The keyword ‘always’ is used to describe the behavior of the circuit. Sensitivity list
has been placed inside the first bracket. The keyword ‘begin and ‘end’ indicates
Example of RTL Verilog Coding using Procedural
Assignment
Example 1: RTL Verilog code using procedural assignment to
design a 2/1 MUX
Verilog Code:
8
Register transfer level (RTL) Design
Example of RTL Verilog Coding using Procedural Assignment
(Continued)
Example 2: RTL Verilog code using procedural assignment to
design a 4/1 MUX
Verilog Code:
9
Register transfer level (RTL) Design
Example of RTL Verilog Coding using Procedural Assignment
(Continued)
Example 3: RTL Verilog code using procedural assignment to design
a 2/4 Decoder
Verilog Code:
10
Register transfer level (RTL) Design
4'b0011:
out=7'b0110000;
4'b0100:
out=7'b0011001;
4'b0101:
out=7'b0010010;
4'b0110:
out=7'b0000010;
4'b0111:
out=7'b1111000;
4'b1000:
out=7'b0000000;
4'b1001:
out=7'b0010000;
default:
Example of RTL Verilog Coding using Procedural Assignment
(Continued)
Example 4: RTL Verilog code using procedural assignment to design a 7-
segment Decoder (for
common anode display).
Verilog Code:
module decoder(en, in,
out); input en;
input [3:0] in;
output [6:0] out;
reg [6:0] out;
always @(en or in)
begin
if(en==0) out=0;
else
begin
case(in)
4'b0000:
out=7'b1000000;
4'b0001:
out=7'b1111001;
11
Register transfer level (RTL) Design
RTL Verilog Coding for sequential
circuit
• Usually procedural assignment structure is used in designing sequential circuit.
• Declaration of ‘module’,‘input’,‘output’,‘reg’, ‘always’ and ‘endmodule’ are same
as used in RTL
Verilog code using procedural assignment for combinational circuit.
• The positive edge and negative edge of the clock and other signal (rst) are
indicated using the
keyword ‘posedge’ and ‘negedge’ respectively.
Examples of RTL Verilog Coding for sequential circuit
Example 1: D type flip-flop with Reset (Active Low)
12
Register transfer level (RTL) Design
Examples of RTL Verilog Coding for sequential circuit
(Continued)
Example 2: Design of a 4-bit binary up
counter.
13
Register transfer level (RTL) Design
Examples of RTL Verilog Coding for sequential circuit (Continued)
14
Example 3: Design of a 4-bit binary up-down
counter.
Register transfer level (RTL) Design
Examples of RTL Verilog Coding for sequential circuit
(Continued)
Example 4: Design of a counter having data loading facility.
Note: In some applications, it is necessary to have a counter to start counting from a
particular value (not
from zero). In this case the starting value needs to be loaded in the counter.
15
Register transfer level (RTL) Design
Examples of RTL Verilog Coding for sequential circuit
(Continued)
Example 5: Design a 4-bit Shift
Register
Module shift_4 (IN, OUT, clk, rst);
input IN, clk, rst;
output OUT;
reg M, N, O,OUT;
always @(posedge clk or posedge
rst) begin if(rst) begin
OUT=0
; M=0;
N=0;
O=0;
end
else begin
OUT=M
; M=N;
N=O;
O=IN;
end
end
endmod
ule
16
Register transfer level (RTL) Design

More Related Content

Similar to fpgartl-verilog-coding-for-sequential-circuit.pptx

Similar to fpgartl-verilog-coding-for-sequential-circuit.pptx (20)

Vlsi
VlsiVlsi
Vlsi
 
Seminar on Digital Multiplier(Booth Multiplier) Using VHDL
Seminar on Digital Multiplier(Booth Multiplier) Using VHDLSeminar on Digital Multiplier(Booth Multiplier) Using VHDL
Seminar on Digital Multiplier(Booth Multiplier) Using VHDL
 
Summer training vhdl
Summer training vhdlSummer training vhdl
Summer training vhdl
 
Coding style for good synthesis
Coding style for good synthesisCoding style for good synthesis
Coding style for good synthesis
 
ASIC design verification
ASIC design verificationASIC design verification
ASIC design verification
 
Summer training vhdl
Summer training vhdlSummer training vhdl
Summer training vhdl
 
2nd presantation
2nd presantation2nd presantation
2nd presantation
 
Session 9 advance_verification_features
Session 9 advance_verification_featuresSession 9 advance_verification_features
Session 9 advance_verification_features
 
Verilogspk1
Verilogspk1Verilogspk1
Verilogspk1
 
Logic Synthesis
Logic SynthesisLogic Synthesis
Logic Synthesis
 
Verilog for synthesis - combinational rev a.pdf
Verilog for synthesis - combinational rev a.pdfVerilog for synthesis - combinational rev a.pdf
Verilog for synthesis - combinational rev a.pdf
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
Verilog
VerilogVerilog
Verilog
 
Vhdl
VhdlVhdl
Vhdl
 
Dot matrix display design using fpga
Dot matrix display design using fpgaDot matrix display design using fpga
Dot matrix display design using fpga
 
How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
Cv of manjunath kudari
Cv of manjunath kudariCv of manjunath kudari
Cv of manjunath kudari
 
DOUBLE PRECISION FLOATING POINT CORE IN VERILOG
DOUBLE PRECISION FLOATING POINT CORE IN VERILOGDOUBLE PRECISION FLOATING POINT CORE IN VERILOG
DOUBLE PRECISION FLOATING POINT CORE IN VERILOG
 
Verilog_ppt.pdf
Verilog_ppt.pdfVerilog_ppt.pdf
Verilog_ppt.pdf
 

Recently uploaded

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 

fpgartl-verilog-coding-for-sequential-circuit.pptx

  • 1. • Register transfer level (RTL) Design and Examples • Register transfer level (RTL) Design • Examples of RTL Verilog code 1 Register transfer level (RTL) Design
  • 2. Register transfer level (RTL) Design Digital Circuit 2 Structural Verilog code is not practicable for designing complex circuit. In that case, RTLVerilog code is used to design digital circuit. RTL Verilog code of a digital design can be written in two ways: 1) Using continuous assignment structures. 2) Using Procedural assignment structures. RTL Coding using continuous assignment • Modeling of digital circuit using continuous assignment structure is higher level of abstraction than structural Verilogcoding. • It is named as continuous assignment because the assignments written in this procedure are evaluated continuously whereas in procedural assignment structure execution of a statement waits for the clock or other parameter. The expression (in continuous assignment structure) is evaluated whenever any of the operands changes. • RTL coding using continuous assignment is usually used to model combinational circuit which is more complex than can be handled by structural modeling. • The declaration ‘module’, ‘input’, ‘output’ and ‘endmodule’ are same as they Register transfer level (RTL) Design
  • 3. Examples RTL Verilog coding using continuous Assignment Example 1: Write Verilog code to represent the digital circuit that follows the following logic equations. Verilog Code: 3 Register transfer level (RTL) Design
  • 4. Examples RTL Verilog coding using continuous Assignment (Cont.) Example 2: A single bit adder (full adder). Verilog Code: 4 Register transfer level (RTL) Design
  • 5. Examples RTL Verilog coding using continuous Assignment (Cont.) Example 3: Write Verilog code to design 4-bit adder-subtractor circuit using continuous assignment structure. Verilog Code: 5 Register transfer level (RTL) Design
  • 6. Examples RTL Verilog coding using continuous Assignment (Cont.) Example 3: Write Verilog code to design a 2/1 MUX using continuous assignment structure. Verilog Code: 6 Register transfer level (RTL) Design
  • 7. RTL Verilog Code using Procedural Assignment 7 Register transfer level (RTL) Design • Structural Verilog coding and Verilog coding using continuous assignment structure are used to design simple digital circuit.This approach is practical when functional complexities are not much (gate count within few hundred). • With the increase of functional complexities, the above two approaches are not suitable approach. In designing complex digital circuit, procedural assignment approach is used. • In this approach, the functional behavior of the circuit is described using keyword ‘always’. • Sensitivity list is used with the ‘always’ statement. Sensitivity list indicates ‘output is sensitive to what?’. It contains the list of specific inputs, which have effect on the outputs. • Whenever any event (change) occurs in any of the parameter in the sensitivity list, the always loop will be executed. How to write RTL Verilog code using Procedural assignment • The declaration ‘module’, ‘input’, ‘output’ and ‘endmodule’ are same as used in structural Verilog coding and RTL Verilog coding using continuous assignment structure. • It is important to remember that all the outputs have to be declare as register using the keyword ‘reg’. • The keyword ‘always’ is used to describe the behavior of the circuit. Sensitivity list has been placed inside the first bracket. The keyword ‘begin and ‘end’ indicates
  • 8. Example of RTL Verilog Coding using Procedural Assignment Example 1: RTL Verilog code using procedural assignment to design a 2/1 MUX Verilog Code: 8 Register transfer level (RTL) Design
  • 9. Example of RTL Verilog Coding using Procedural Assignment (Continued) Example 2: RTL Verilog code using procedural assignment to design a 4/1 MUX Verilog Code: 9 Register transfer level (RTL) Design
  • 10. Example of RTL Verilog Coding using Procedural Assignment (Continued) Example 3: RTL Verilog code using procedural assignment to design a 2/4 Decoder Verilog Code: 10 Register transfer level (RTL) Design
  • 11. 4'b0011: out=7'b0110000; 4'b0100: out=7'b0011001; 4'b0101: out=7'b0010010; 4'b0110: out=7'b0000010; 4'b0111: out=7'b1111000; 4'b1000: out=7'b0000000; 4'b1001: out=7'b0010000; default: Example of RTL Verilog Coding using Procedural Assignment (Continued) Example 4: RTL Verilog code using procedural assignment to design a 7- segment Decoder (for common anode display). Verilog Code: module decoder(en, in, out); input en; input [3:0] in; output [6:0] out; reg [6:0] out; always @(en or in) begin if(en==0) out=0; else begin case(in) 4'b0000: out=7'b1000000; 4'b0001: out=7'b1111001; 11 Register transfer level (RTL) Design
  • 12. RTL Verilog Coding for sequential circuit • Usually procedural assignment structure is used in designing sequential circuit. • Declaration of ‘module’,‘input’,‘output’,‘reg’, ‘always’ and ‘endmodule’ are same as used in RTL Verilog code using procedural assignment for combinational circuit. • The positive edge and negative edge of the clock and other signal (rst) are indicated using the keyword ‘posedge’ and ‘negedge’ respectively. Examples of RTL Verilog Coding for sequential circuit Example 1: D type flip-flop with Reset (Active Low) 12 Register transfer level (RTL) Design
  • 13. Examples of RTL Verilog Coding for sequential circuit (Continued) Example 2: Design of a 4-bit binary up counter. 13 Register transfer level (RTL) Design
  • 14. Examples of RTL Verilog Coding for sequential circuit (Continued) 14 Example 3: Design of a 4-bit binary up-down counter. Register transfer level (RTL) Design
  • 15. Examples of RTL Verilog Coding for sequential circuit (Continued) Example 4: Design of a counter having data loading facility. Note: In some applications, it is necessary to have a counter to start counting from a particular value (not from zero). In this case the starting value needs to be loaded in the counter. 15 Register transfer level (RTL) Design
  • 16. Examples of RTL Verilog Coding for sequential circuit (Continued) Example 5: Design a 4-bit Shift Register Module shift_4 (IN, OUT, clk, rst); input IN, clk, rst; output OUT; reg M, N, O,OUT; always @(posedge clk or posedge rst) begin if(rst) begin OUT=0 ; M=0; N=0; O=0; end else begin OUT=M ; M=N; N=O; O=IN; end end endmod ule 16 Register transfer level (RTL) Design