Verilog HDL - Introduction
Verilog HDL - Introduction
Verilog HDL - Introduction
Generating Checking
inputs Circuit Under Design outputs
to CUD (CUD) of CUD
4
8
Test bench
Simulation- Test Bench Styles
Design Methodologies
4-bit Ripple Carry Counter
T-flipflop and the Hierarchy
Ports
Ports provide interface for by which a module can
communicate with its environment
Port connection rules
Connecting Ports
Suppose we have a module
Module- Basic building block
output [3:0] q;
initial begin
//monitor and display
module test (q, r);
…
output q, r;
initial begin
//drive the outputs with signals
…
Another view of this
• 3 chunks of verilog, one for each of:
Another piece of
hardware, called Your hardware
TEST, to generate called
interesting inputs DESIGN
Verilog Examples
Module testAdd generated inputs for module halfAdd and
displayed changes. Module halfAdd was the design
module testAdd(a, b, sum, cOut);
module tBench;
input sum, cOut;
wire su, co, a, b;
output a, b;
reg a, b;
halfAdd ad(su, co, a, b);
testAdd tb(a, b, su, co);
initial begin
endmodule
$monitor ($time,,
“a=%b, b=%b, sum=%b, cOut=%b”,
a, b, sum, cOut);
module halfAdd (sum, cOut, a, b); a = 0; b = 0;
output sum, cOut; #10 b = 1;
input a, b; #10 a = 1;
#10 b = 0;
xor #2 (sum, a, b); #10 $finish;
and #2 (cOut, a, b); end
endmodule endmodule
Gate Level Modeling
A logic circuit can be designed by use of logic
gates.
Verilog supports basic logic gates as predefined
primitives. These primitives are instantiated like
modules except that they are predefined in Verilog
and do not need a module definition.
Gate gate_name(out,in1,in2…)
Buf/not gates
Buflnot gates have one scalar input and
one or more scalar outputs.
Bufif/notif
Instantiation of bufif gates
Design of 4:1 Multiplexer
Contd..
Stimulus
4 bit full adder
Declaration:
Code contd..
4 bit adder using 1 bit adder
Stimulus
Gate Delays:
Rise Delay: Delay associated with a
o/p transition to 1 from any value.
//min delay=4
//type delay=5
//max delay=6
and #(4:5:6) a1(out, i1, i2) ;
output out;
input select, a, b;
table
//select a b : out
1 ? 1 : 1;
? 0 0 : 0;
UDP: Sequential Behavior
• In table description, n+2 columns for n
input
• n input columns + internal state column
+ output (next state) column
• Output port -> reg variable
Level-sensitive Behavior
primitive transparent_latch(out, enable, in);
enable
output out;
in Transparent out
input enable, in;
latch
reg out;
table
1 1 :? : 1;
1 0 :? : 0;
x 0 :0 : -;
Edge-sensitive Behavior
primitive d_flop( q, clock, d );
clock
output q;
d d_flop q
input clock, d;
reg q;
table
(0?) 1 : 1 : 1;
(0?) 0 : 0 : 0;