Ee121 HDL Assignment
Ee121 HDL Assignment
ROLL NO.-CS24B1066
ASSIGNMENT 1
module <testbench_name>;
<module_name> uut (
.<input_port>(<input_signal>),
.<output_port>(<output_signal>)
);
initial begin
$finish;
end
endmodule
Verilog Design Source Code and Testbench Code: Structure & Purpose
Verilog is a hardware description language (HDL) used to model electronic systems. It consists
of two main components:
1. Design Source Code – Describes the behavior or structure of the digital circuit.
2. Testbench Code – Tests and verifies the design module using stimulus.
Component Purpose
module <name> Defines the module and its name.
Port List Declares input and output signals
Data Types (wire, reg) Specifies internal signal types.
Logic Implementation Defines the circuit behavior using assign (for combinational logic) or
always (for sequential logic)
endmodule Marks the end of the module
Explanation of Components
A testbench applies test cases to the design module and observes the output.
Component Purpose
module <testbench_name> Defines the testbench module (has no ports)
Register Declaration (reg) Holds test input values.
Wire Declaration (wire) Captures the design module’s output
DUT Instantiation Connects testbench signals to the design module
initial block Defines test cases and applies stimulus
$monitor and $display Prints output values for debugging.
Simulation Control ($finish) Stops the simulation.
Explanation of Components
Dataflow
Design Code
Gatelevel
Dataflow
Behavioral
Output
Design code
Dataflow
Gatelevel
Behavioral
Output
Gatelevel
Behavioral
Output
NAND GATE: Testbench Code
Design Code
Dataflow
Gatelevel
Behavioral
Output
Design Code
Dataflow
Gatelevel
Behavioral
Output
Gatelevel
Behavioral
Output
XNOR GATE: Testbench Code
Design Code
Dataflow
Gatelevel
Behavioral
Output
Gatelevel
Behavioral
Output
FULL ADDER
Testbench Code:
Design Code:
Datatype
Gatelevel
Behavorial
Output
HALF SUBTRACTOR
Testbench Code
Design Code
Dataflow
Gatelevel
Behavorial
Output
FULL SUBTRACTOR
Testbench Code
Design Code
Dataflow
Gatelevel
Behavorial
Output
5.Write the design and testbench code for:
Ans: 2x1 Multiplexer
Testbench Code
Design Code
Dataflow
Gatelevel
Behavorial
Output
4x1 Multiplexer
Testbench Code
Design Code
Dataflow
Gatelevel
Behavorial
Output