Unit-II - Design of Digital Systems Updated
Unit-II - Design of Digital Systems Updated
1
Unit-2
• HDL modelling of combinational and sequential circuits: multiplexer, decoder, adder,
flip flops and registers, simple design examples, testbench for combinational and
sequential circuits. Mealy and Moore FSMs, Design Examples.
2
System Verilog Modeling Styles
• Modeling styles are
1. Data flow level
2. Gate level
3. Behavioral level
4. Mixed modeling
3
Modeling Styles: Examples
• Dataflow level modelling of mux:
module mux_2to1 (i0,i1,sel,y);
output logic y;
endmodule
4
Modeling Styles: Examples
• Gate level modeling: module mux_2to1_Gate_Level (i0,i1,sel,y);
input logic i0,i1,sel;
output logic y;
logic y1,y2;
not n1(sel_n, sel);
and and_1(y1, i0,sel_n);
and and_2(y2,i1,sel);
or or_1(y,y1,y2);
endmodule
5
Modeling Styles: Examples
• Behavioral modelling: module mux_2to1_Beh (i0,i1,sel,y);
input logic i0,i1,sel;
output logic y;
always@(*) begin
if (sel==0)
y<=i0;
else
y<=i1;
end
endmodule
6
Testbench for 2-to-1 MUX
7
• Non-synthesizable code for 2-input NAND gate
8
Switch level modelling of 2-input NAND gate
9
Testbench for 2-Input NAND gate
10
Power of System Verilog
11
Dangers of Verilog: Incomplete Specification
12
Incomplete Specification Infers Latches
13
Avoiding Incomplete Specification
14
The Sequential always Block
15
Importance of the Sensitivity List
16
Importance of the Sensitivity List
17
Simulation
18
Blocking vs. Nonblocking Assignments
19
Blocking vs. Nonblocking Assignments
20
x
21
Assignment Styles for Sequential Logic
22
Use Nonblocking for Sequential Logic
23
Simulation
24
Use Blocking for Combinational Logic
25
Use Blocking for Combinational Logic
26
Dangers of Verilog : Priority Logic
27
Resulting Priority Logic
28
Avoiding (Unintended) Priority Logic
29
Useful Boolean Operators
30
31
D-FF with synchronous enable and asynchronous reset
Reset
Input D Q Output
Clk
enable
32
Testbench for D-FF with synchronous enable
33
Simulation
34
Synchronous System Design
35
Two-segment coding style for a DFF with enable input
0
MUX D Q q
d 1
enable
Clk Asyn_reset
36
Simulation
37
Binary up/down counter
clk
Up/Down 4-bit
sync_rst q
Counter
up_down
38
Binary up/down counter
39
Testbench for up/down counter
40
Simulation
41
Universal shift register
clk
si_l
4-bit
si_r USR q
pi_d
Sel
42
Universal Shift Register
43
Testbench for Universal Shift Register
44
Simulation
45
Finite State Machine
46
Some Basic Concepts: FSM
Output Outputs
Logic
Moore FSM
Output Outputs
Logic
FSM Code Development
• The procedure of developing code for an FSM is similar to that of a regular
sequential circuit.
• We first separate the state register and then derive the code for the
combinational next-state logic and output logic.
0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 0
Moore FSM
Output Outputs
Logic
Example: Sequence Detector
Develop the Verilog HDL model for Moore sequence detector which has one-
bit input and one-bit output. This generates logic ‘1’ output whenever it
recognizes sequence “101”.
Moore State Diagram for Sequence Detector
Desired binary sequence to be recognized by detector is “101”.
Code for Moore Sequence Detector
// State register
0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 0 0
End of Lecture