HDL Module-2
HDL Module-2
College of Engineering
Module 2 - Lab
Combinational Circuits
Overview
Half Adder Module in Verilog
Half adders are a basic building block for new digital designers. A half-adder shows how two
bits can be added together with a few simple logic gates. In practice they are not often used because
they are limited to two one-bit inputs. For adding together larger numbers a full-adder can be used.
A single half-adder has two one-bit inputs, a sum output, and a carry-out output. Refer to figure 1, the
truth table of Half-adder to see how these bits operate.
In this module the sample code will be given for dataflow modeling of a half adder circuit.
There is also a test bench that stimulates the design and ensures that it behaves correctly.
1|P age
Verilog Code for Half Adder Gate Level Modelling
2|P age
Full Adder Module in Verilog
Full adders are a basic building block for new digital designers. Lots of introductory courses
in digital design present full adders to beginners. Once you understand how a full adder works, you
can see how more complicated circuits can be built using only simple gates. I just want to make it
clear to someone new that in reality, FPGA designers are not coding full adders by hand. The tools
are advanced enough to know how to add two numbers together. It's still a good exercise, which is
why it is presented here.
A single full-adder has two one-bit inputs, a carry-in input, a sum output, and a carry-out
output. Many of them can be used together to create a ripple carry adder which can be used to add
large numbers together. A single full-adder is shown in the picture below.
The next picture shows the entire schematic of the full adder and its corresponding truth
table. The red text ties into the code below. w_WIRE_1, w_WIRE_2, w_WIRE_3 are the intermediate
signals shown in the red text on the schematic.
3|P age
Verilog Code for Full Adder in Gate Level Modelling
The binary subtraction consists of four possible elementary operations: 0-0, 0-1, 1-0, and 1-1.
4|P age
Half-Subtractor Truth table
5|P age
Verilog Testbench Code for Half Subtractor – Dataflow Modelling
Full Subtractor
A full subtractor is a combinational circuit that performs the subtraction of three bits. It
consists of three inputs and two outputs. Consider that we want to subtract three 1-bit numbers.
The numbers are X, Y and Z then a difference bit (D) and a borrow bit (B) will get generated.
6|P age
Full Subtractor Schematic Diagram
Task: Write the Verilog code of the ff. combinational circuits using three (3) modelling style. Also
create it’s intended Testbench.
1. Half Adder
2 Full Adder
3.Half Subtractor
4. Full Subtractor
7|P age
Guidelines in creating/submitting outputs
1. You can use RecForth or any screen recorder application to record your
simulated outputs.
1.1 In case you do not have a computer, you can use Smartphone to record
your output.
2. In creating a video (recorded video), Start with greetings, then state your
Complete name, Course, Subject, and Title of the laboratory activites that you are
going to perform.
Link: https://classroom.google.com/c/NDk4OTI2MzE5MTQz?cjc=uolh5gd
8|P age
Annex A.
RUBRIC IN PROJECTS/OUTPUTS
Rating Scale:
10 1.0 – 1.5
9 1.6 – 2.0
8 2.1 – 2.5
7 2.6 – 3.0
9|P age