Module 1 Part 2
Module 1 Part 2
● Counter
○ Increments/ Decrement pulses
4-bit Ripple Carry Counter
Negative edge
trigger
1 2 3 4
D Flipflop
Clk Reset Current Next
State State
↓ 1 x 0
↓ 0 0 0
↓ 0 1 1
Truth table of T flipflop
T- Flip Flop
Hierarchy of 4-bit Ripple Carry Counter
Top-down
Bottom-up
Modules
Basic component in Verilog for describing/defining a hardware
● Dataflow level
● Gate level
● Switch level
Levels of functionality (Types of
Descriptions)
Instances
● Individual object of module
● Module is similar to “function declaration” in C, and instance
likes the concept of “function call”
● Instantiation - Process of creating objects from a module
template
● Instance: The object
Example of Instance
module ripple_carry_counter(q, clk, reset);
output [3:0] q;
input clk, reset;
Instantiation
Stimulus generation
Output checking
Stimulus Block Instantiates Design
Block
Stimulus and Design Block Instantiated
in a Dummy Top-level module
Example with simulation
● 4 Bit Ripple Carry Counter
● Using Top-down and Bottom-up Methodology
● Simulation
Simulation Block reset = 1'b1;
#15 reset = 1'b0;
module stimulus(); #180 reset = 1'b1;
reg clk,reset; #10 reset = 1'b0;
#20 $finish; //terminate the simulation
wire[3:0] q;
end
ripple_carry_counter r1(q, clk, reset);
// Monitor the outputs
initial
initial
clk = 1'b0; //set clk to 0 Begin
always $monitor($ time, “output q=%d”,q);
#5 clk = ~clk; //toggle clk every 5 time units end
initial begin endmodule
Result
Timing diagram
Summary
● Two kinds of design methodologies are used for digital design:
top-down and bottom-up
● Modules are the basic building blocks in Verilog
● A design block and a stimulus block
● The example of the ripple carry counter
Thank you