SlideShare a Scribd company logo
1 of 11
Download to read offline
• RTLVerilog coding using continuous assignment.
• RTLVerilog coding using procedural assignment.
Verilog HDL
RTL Verilog coding for combinational circuit
Prepared By-
Mohammed Abdul Kader
Lecturer, EEE, IIUC
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
2
RTLVerilog Coding of Digital Circuit
StructuralVerilog code is not practicable for designing complex circuit. In that case, RTLVerilog code
is used to design digital circuit. RTLVerilog 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
structuralVerilog coding.
• 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 are used in
structural Verilog code. The difference is the keyword ‘assign’is used to write the continuous
assignment.
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
3
Examples RTLVerilog coding using continuous Assignment
Example 1: WriteVerilog code to represent the digital circuit that follows the following logic
equations.
Verilog Code:
Exercise 1: WriteVerilog code to represent the digital circuit that follows the following logic
equations.
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
4
Examples RTLVerilog coding using continuous Assignment (Cont.)
Example 2: A single bit adder (full adder).
Verilog Code:
Exercise 2: Design a 4-bit adder circuit using continuous assignment structure ofVerilog code.
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
5
Examples RTLVerilog coding using continuous Assignment (Cont.)
Example 3: WriteVerilog code to design 4-bit adder-subtractor circuit using continuous assignment
structure.
Verilog Code:
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
6
Examples RTLVerilog coding using continuous Assignment (Cont.)
Example 3: WriteVerilog code to design a 2/1 MUX using continuous assignment structure.
Verilog Code:
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
7
RTLVerilog Code using Procedural Assignment
• StructuralVerilog coding andVerilog 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.
• The declaration ‘module’, ‘input’, ‘output’ and ‘endmodule’ are same as used in structural Verilog
coding and RTLVerilog 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 start and completion of the always
block respectively. However, the use of ‘begin and ‘end’ is optional. It is just increase the clarity of
the code. Within the always block, it is described ‘What does the circuit always do: which is
basically the behavior of the circuit.
’
How to write RTLVerilog code using Procedural assignment
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
8
Example of RTLVerilog Coding using Procedural Assignment
Example 1: RTLVerilog code using procedural assignment to design a 2/1 MUX
Verilog Code:
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
9
Example of RTLVerilog Coding using Procedural Assignment (Continued)
Example 2: RTLVerilog code using procedural assignment to design a 4/1 MUX
Verilog Code:
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
10
Example of RTLVerilog Coding using Procedural Assignment (Continued)
Example 3: RTLVerilog code using procedural assignment to design a 2/4 Decoder
Verilog Code:
Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC
11
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;
4'b0010: out=7'b0100100;
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: out=7'b1111111;
endcase
end
end
endmodule
Example of RTLVerilog Coding using Procedural Assignment (Continued)
Example 4: RTLVerilog code using procedural assignment to design a 7-segment Decoder (for
common anode display).
Verilog Code:

More Related Content

Similar to fpgartl-verilog-coding-for-combinational-circuit.pdf

A_Brief_Summary_on_Summer_Courses[1]
A_Brief_Summary_on_Summer_Courses[1]A_Brief_Summary_on_Summer_Courses[1]
A_Brief_Summary_on_Summer_Courses[1]
Gayatri Kindo
 
Unit 5_Realizing Applications in FPGA.pdf
Unit 5_Realizing Applications in FPGA.pdfUnit 5_Realizing Applications in FPGA.pdf
Unit 5_Realizing Applications in FPGA.pdf
kanyaakiran
 
Prepare a Verilog HDL code for the following register Positive Edge.pdf
Prepare a Verilog HDL code for the following register  Positive Edge.pdfPrepare a Verilog HDL code for the following register  Positive Edge.pdf
Prepare a Verilog HDL code for the following register Positive Edge.pdf
ezonesolutions
 
Cv of manjunath kudari
Cv of manjunath kudariCv of manjunath kudari
Cv of manjunath kudari
Jagadeesh Dh
 
Ravikanth Resume
Ravikanth ResumeRavikanth Resume
Ravikanth Resume
Ravi Kanth
 

Similar to fpgartl-verilog-coding-for-combinational-circuit.pdf (20)

Tutor1
Tutor1Tutor1
Tutor1
 
Summer training vhdl
Summer training vhdlSummer training vhdl
Summer training vhdl
 
Summer training vhdl
Summer training vhdlSummer training vhdl
Summer training vhdl
 
Vlsi
VlsiVlsi
Vlsi
 
Summer training vhdl
Summer training vhdlSummer training vhdl
Summer training vhdl
 
VLSI
VLSIVLSI
VLSI
 
A_Brief_Summary_on_Summer_Courses[1]
A_Brief_Summary_on_Summer_Courses[1]A_Brief_Summary_on_Summer_Courses[1]
A_Brief_Summary_on_Summer_Courses[1]
 
24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf
 
Unit 5_Realizing Applications in FPGA.pdf
Unit 5_Realizing Applications in FPGA.pdfUnit 5_Realizing Applications in FPGA.pdf
Unit 5_Realizing Applications in FPGA.pdf
 
IRJET- Switch Level Implementation of A 4-Bit Logical Unit using Mixed Logic ...
IRJET- Switch Level Implementation of A 4-Bit Logical Unit using Mixed Logic ...IRJET- Switch Level Implementation of A 4-Bit Logical Unit using Mixed Logic ...
IRJET- Switch Level Implementation of A 4-Bit Logical Unit using Mixed Logic ...
 
Prepare a Verilog HDL code for the following register Positive Edge.pdf
Prepare a Verilog HDL code for the following register  Positive Edge.pdfPrepare a Verilog HDL code for the following register  Positive Edge.pdf
Prepare a Verilog HDL code for the following register Positive Edge.pdf
 
ASIC design verification
ASIC design verificationASIC design verification
ASIC design verification
 
Electrical Rule Check Verification Methodology For SoC
Electrical Rule Check Verification Methodology For SoCElectrical Rule Check Verification Methodology For SoC
Electrical Rule Check Verification Methodology For SoC
 
Logic Synthesis
Logic SynthesisLogic Synthesis
Logic Synthesis
 
resume
resumeresume
resume
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative Programming
 
Lear unified env_paper-1
Lear unified env_paper-1Lear unified env_paper-1
Lear unified env_paper-1
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Cv of manjunath kudari
Cv of manjunath kudariCv of manjunath kudari
Cv of manjunath kudari
 
Ravikanth Resume
Ravikanth ResumeRavikanth Resume
Ravikanth Resume
 

Recently uploaded

notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Recently uploaded (20)

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 

fpgartl-verilog-coding-for-combinational-circuit.pdf

  • 1. • RTLVerilog coding using continuous assignment. • RTLVerilog coding using procedural assignment. Verilog HDL RTL Verilog coding for combinational circuit Prepared By- Mohammed Abdul Kader Lecturer, EEE, IIUC
  • 2. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 2 RTLVerilog Coding of Digital Circuit StructuralVerilog code is not practicable for designing complex circuit. In that case, RTLVerilog code is used to design digital circuit. RTLVerilog 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 structuralVerilog coding. • 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 are used in structural Verilog code. The difference is the keyword ‘assign’is used to write the continuous assignment.
  • 3. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 3 Examples RTLVerilog coding using continuous Assignment Example 1: WriteVerilog code to represent the digital circuit that follows the following logic equations. Verilog Code: Exercise 1: WriteVerilog code to represent the digital circuit that follows the following logic equations.
  • 4. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 4 Examples RTLVerilog coding using continuous Assignment (Cont.) Example 2: A single bit adder (full adder). Verilog Code: Exercise 2: Design a 4-bit adder circuit using continuous assignment structure ofVerilog code.
  • 5. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 5 Examples RTLVerilog coding using continuous Assignment (Cont.) Example 3: WriteVerilog code to design 4-bit adder-subtractor circuit using continuous assignment structure. Verilog Code:
  • 6. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 6 Examples RTLVerilog coding using continuous Assignment (Cont.) Example 3: WriteVerilog code to design a 2/1 MUX using continuous assignment structure. Verilog Code:
  • 7. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 7 RTLVerilog Code using Procedural Assignment • StructuralVerilog coding andVerilog 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. • The declaration ‘module’, ‘input’, ‘output’ and ‘endmodule’ are same as used in structural Verilog coding and RTLVerilog 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 start and completion of the always block respectively. However, the use of ‘begin and ‘end’ is optional. It is just increase the clarity of the code. Within the always block, it is described ‘What does the circuit always do: which is basically the behavior of the circuit. ’ How to write RTLVerilog code using Procedural assignment
  • 8. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 8 Example of RTLVerilog Coding using Procedural Assignment Example 1: RTLVerilog code using procedural assignment to design a 2/1 MUX Verilog Code:
  • 9. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 9 Example of RTLVerilog Coding using Procedural Assignment (Continued) Example 2: RTLVerilog code using procedural assignment to design a 4/1 MUX Verilog Code:
  • 10. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 10 Example of RTLVerilog Coding using Procedural Assignment (Continued) Example 3: RTLVerilog code using procedural assignment to design a 2/4 Decoder Verilog Code:
  • 11. Lecture Materials on "RTLVerilog Coding for combinational circuit", By- Mohammed Abdul Kader, Lecturer, EEE, IIUC 11 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; 4'b0010: out=7'b0100100; 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: out=7'b1111111; endcase end end endmodule Example of RTLVerilog Coding using Procedural Assignment (Continued) Example 4: RTLVerilog code using procedural assignment to design a 7-segment Decoder (for common anode display). Verilog Code: