Experiment 1 - UCS 704 - ESD
Experiment 1 - UCS 704 - ESD
x A value of "don't care". x values are neither a 0 nor a 1, and should be treated as unknown values.
A high-impedance value from a tri-state buffer when the control signal is not asserted. Corresponds to a
z
wire that is not connected, or is "floating".
Verilog: Data Types
• Wire: It specified with the wire keyword represent physical wires that carry electrical signals from
one module to the next.
• Wires do not store any data, and they must be constantly supplied with a value or they will not
contain a value.
• Wires may not be the target of a blocking or sequential assignment.
• Wires come in one of three varieties:
Type Function
wire These wires carry simple data from one port to another.
These wires are a logical OR of all input data values applied to the wire. These synthesize to OR gates with multiple input
wor ports.
These wires are a logical AND of all input data values applied to the wire. These synthesize to AND gates with multiple input
wand ports.
• Wires can be assigned a value using the assign keyword. All assign
declarations are considered to be running concurrently and
continuously. wire a, b, c;
• In the following case, the value of a is dependent on the values assign a = b & c;
of b and c. Any change in either b or c will result in an automatic and
instantaneous change in the value of a.
Verilog: Data Types
reg:
• A register, denoted with the keyword reg is a memory storage location.
• with user-defined size
• Example:
reg a, b; //reg without size means 1-bit
reg [31:0] c; // a 32-bit register
GATE: AND
//Program_1_and_gate
//Program_2_and_gate
module and_gate;
module and_gate_1;
reg a, b;
reg a;
wire z;
reg b;
wire y,;
and my_and(z, a, b);
assign y = a & b;
initial
begin
initial
a = 0; b =1;
begin
#10
a = 0; b = 1;
$display("a= %b b= %b z= %b", a, b, z);
//#10
$finish;
$display("a=%b b=%b y=%b", a, b, y);
end
$finish;
endmodule
end
endmodule // example_and_gate
GATE: AND
//AND
initial begin
module andGate;
reg x; // Inputx
$display("INPUT\tOUTPUT");
reg y; // Inputy
$monitor("x=%d,y=%d,z=%d \n",x,y,z);
wire z; // Outputz
end
andComp uut (
endmodule
.x(x),
module andComp(
.y(y),
input x,
.z(z)
input y,
);
output z
initial begin // Initialize Inputs
);
x = 0;
assign z = x&y;
y = 0;
endmodule
#20 x = 1;
#20 y = 1;
#20 x = 0;
//#20 x = 1;
//#40;
end
GATE: AND
#Program_3_and_gate initial
module and_gate_1; begin
reg a, b; a = 0; b = 0;
wire z, temp; #10
a = 0; b = 1;
assign temp = b; #10
and my_and(z, a, temp); a = 1; b = 0;
always @(a or b) #10
begin a = 1; b = 1;
$display("a= %b b= %b z= %b", a, b, z);
end end
endmodule
always @ (A or B): Using the always statement, a procedural statement in Verilog, we run the program sequentially.
(A, B) is known as the sensitivity list or the trigger list. The sensitivity list includes all input signals used by the always
block. It controls when the statements in the always block are to be evaluated. @ is a part of the syntax, used before
the sensitivity list. In Verilog, begin embarks and end concludes any block which contains more than one statement in
it.
GATE: AND and NOT
module and_not;
reg a, b; // reg without size means 1-bit
wire tmp, z;
not my_not(tmp, b);
and my_and(z, a, tmp);
initial
begin
a = 1; b = 1;
#5
$display("a=%b b=%b z=%b", a, b, z);
$finish;
end
endmodule
NOR GATE
//NOR
initial begin
module norGate; initial begin // Initialize Inputs
reg x; // Inputx x = 0; $display("INPUT\
y = 0; tOUTPUT");
reg y; // Inputy #20 x = 1; $monitor("x=%d,y=%d,z=%d \n",x,y,z);
wire z; // Outputz #20 y = 1; end
norComp uut ( #20 x = 0; endmodule
//#20 x = 1; module norComp(
.x(x), //#40; input x,
.y(y), end input y,
.z(z) output z
);
); assign z = ~(x|y);
endmodule
GATE: Assignment
• $dumpfile("test.vcd");
will dump the changes in a file named test.vcd.
• The changes are recorded in a file called VCD file that stands for value change dump.
• A VCD (value change dump) stores all the information about value changes.
• We can not have more than one $dumpfile statements in verilog simulation.
• But what exactly are we going to dump in this file?
• This is specified by $dumpvars that we will cover next.
• One more thing, the declaration onf $dumpfile must come before the $dumpvars or any other
system tasks that specifies dump.
Dumpfile
$dumpvars
The $dumpvars is used to specify which variables are to be dumped (in the file
mentioned by $dumpfile).
The simplest way to use it is without any argument.
$dumpvars;
In this case, it dumps ALL variables in the current testbench module and in all other
modules instantiated by it.
The general syntax of the $dumpvars include two arguments as in $dumpvars(<levels> <,
<module_or_variable>>* );
REF: https://www.referencedesigner.com/tutorials/verilog/verilog_62.php