HDL Le Unite 1
HDL Le Unite 1
• Behavioral Modeling
module mux(
input s, a, b,
output reg y
);
always@(a,b,s) //behavioral statement
if (s == 0)
y = a;
else
y = b;
endmodule
Radha R C, Dept.of ECE,BMSCE
Data Flow modelling
• At this level, the module is designed by specifying
the data flow.
• Shows that how the data / signal flows from input to
ouput
• works on Concurrent Execution
• The modelling uses logical equations
module mux(
input s, a, b,
output y
);
assign y = ((~s & a) | (s & b));
endmodule
Radha R C, Dept.of ECE,BMSCE
Gate Level(Structural) Modelling
• The module is implemented in terms of logic
gates and interconnections between these gates.
• A change in the value of any input signal of a
component activates the component. If two or
more components are activated concurrently,
they will perform their actions concurrently as
well.
• Since logic gate is most popular component,
Verilog has a predefined set of logic gates known
as primitives.
Radha R C, Dept.of ECE,BMSCE
Gate Level(Structural) Modelling
module mux(
input s, a, b,
output y
);
wire sbar, o1, o2; //internal connections
not N1(sbar, s);
and A1(o1, a, sbar);
and A2(o2, b, s);
or O1( y, o1, o2);
endmodule
Radha R C, Dept.of ECE,BMSCE
Switch Level Modelling
– specification
– architecture
– logic design
– circuit design
– physical layout
• Verify at each level of abstraction
initial
begin
..contd…
Radha R C, Dept.of ECE,BMSCE
module Stimulus contd..
…
reset = 1'b1;
#15 reset = 1'b0;
#180 reset = 1'b1; //at time 15+180 = 195ns
#10 reset = 1'b0; //at time 205 ns
#20 $finish;
end
// Monitor the outputs
initial
$monitor($time, " Output q = %d", q); //Monitors q
endmodule
• X- unknown
• Z- high impedance
• \n – newline
• \t - tab
• Mux$12 //valid
• _clk1 //valid
• 1x2_mux //invalid
• $reg1 //invalid
Registers
Displaying information
• $display -system task for displaying values of variables, strings or
expressions.
• $display(p1, p2, p3,....., pn);
▫ p1, p2, p3,..., pn can be quoted strings or variables or expressions
• %d-decimal, %b- binary, %s-string, %h-hex values
• $display("Bus value is %b", bus);
• A $display inserts a newline at the end of the string by default.
• A $display without any arguments produces a newline.
Radha R C, Dept.of ECE,BMSCE
System Tasks contd..
Monitoring information
• $monitor - mechanism to monitor a signal when its value
changes
• $monitor(p1,p2,p3,....,pn);
▫ The parameters p1, p2, ... , pn can be variables, signal names, or
quoted strings
• Only one monitoring list can be active at a time
initial
begin
clock = 0;
reset = 1;
#100 $stop; // This will suspend the simulation at time = 100
#900 $finish; // This will terminate the simulation at time = 1000
end
Radha R C, Dept.of ECE,BMSCE
Compiler Directives
• All compiler directives are defined by using the
`<keyword> construct.
• 'define WORD_SIZE 32
• 'include header.v
• Port Declaration
• module fulladd4(sum, c_out, a, b, c_in);
• //Begin port declarations section
• output [3:0] sum;
• output c_out;
• input [3:0] a, b;
• input c_in;
• //all port declarations are implicitly declared as wire