Question

Write the HDL gate-level hierarchical description of a four-bit adder-subtractor for unsigned binary numbers. You can...

Write the HDL gate-level hierarchical description of a four-bit adder-subtractor for unsigned binary numbers. You can instantiate the four-bit full adder. Write a test bench to test your module.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

module half_adder (input1, input2, sum, carry);
// I/0 declarations
input inputl, input2;
output sum, carry;
//instantiate gate primitives
xor xorl (sum,input1,input2);
and andl (carry,input1,input2);
endmodule

//Full Adder using half adder
module full_adder (input1,input2,carry_in,sum,carry_out);
// I/O declarations
input input1,input2,carry_in;
output sum,carry_out;
//internal signals declaration
wire xor_out,and1_out,and2_out;
//instatiation of half adder
half_adder half_adder1(input1,input2,xor_out,and1_out);
half_adder half_adder2 (carry_in,xor_out,sum,and2_out);
or (carry_out,and2_out,and1_out);
endmodule

module FourBit_AdderSub (input1,input2,carry_in,sum,carry_out);
// I/O declaration
input [3:0] inputl,input2;
output[3:0] sum;
output carry_out;
input carry in;
//internal signals declaration
wire c1,c2,c3,x0,x1,x2,x3;
//instantiate for full adders'
xor xora(x0,carry_in,input2[0]);
full_adder full_adder1 (input1[0],x0,carry_in,sum[0],c1);
xor xorb(x1,carry_in,input2[1]);
full_adder full_adder2(input1[1],x1,c1,sum[1],c2);
xor xorc(x2,carry_in,input2[2]);
full_adder full_adder3 (input1[2],x2,c2,sum[2],c3);
xor xord(x3,carry_in,input2[3]);
full_adder full_adder4 (input1[3],x3,c3,sum[3],carry_out);
endmodule

//Test Bench for the 4bit adder-subtractor

module FourBit_AdderSub_TB;
// Inputs
reg [3:0] input': reg [3:0] input2; reg carry_in;
// Outputs
wire [3:0] sum;
wire carryout;
// Instantiate the Unit Under Test (UUT)
FourBit_AdderSub uut
.inputl(input1),
.input2(input2),
.carry_in(carry_in),
.sum(sum),
.carry_out(carry_out)
);
reg [8:0] i;
initial begin
for (i = 0; i <= 511; i = i + 1) begin
input1[3:0] = 1[8:5]; input2 = i[4:1]; carry_in = 1[0]; #5;
end
end
endmodule

Add a comment
Know the answer?
Add Answer to:
Write the HDL gate-level hierarchical description of a four-bit adder-subtractor for unsigned binary numbers. You can...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please code the following in Verilog: Write the HDL gate-level hierarchical description of a four-bit adder-subtractor...

    Please code the following in Verilog: Write the HDL gate-level hierarchical description of a four-bit adder-subtractor for unsigned binary numbers similar to the following circuit. You can instantiate the four-bit full adder described in the following example code Figure 4.13a, 4-Bit adder-subtractor without overflow Inputs: 4-Bit A, 4-Bit B, and Mode M (0-add/1-subtract) Interfaces: Carry Bits C1, C2, C3 Outputs: Carry C (1 Bit, C4), Sum S (4 bit) Bo A FA FA FA FA module Add half (input a,...

  • Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL 1.3-input majority function 2.Condition...

    Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL 1.3-input majority function 2.Conditional inverter (see the table below: x - control input, y -data input). Do NOT use XOR gates for the implementation. Output 3. Two-input multiplexer (see the table below: x.y -data inputs, z- control input) Output 4. 1-bit half adder. 5. 1-bit full adder by cascading two half adders 6.1-bit full adder directly (as in...

  • Building and testing basic combinational circuits using Verilog HDL Description: Build and test t...

    Building and testing basic combinational circuits using Verilog HDL Description: Build and test the following circuits using gate-level modeling in Verilog HDL. 1. 3-input majority function. 2. Conditional inverter (see the table below: x - control input, y - data input). Do NOT use XOR gates for the implementation.    x y Output 0   y 1   y' 3. Two-input multiplexer (see the table below: x,y - data inputs, z - control input).     z Output 0 x 1 y 4. 1-bit half...

  • Please Can someone paraphrase this ? : 1.4 Binary Subtractor The subtraction of unsigned binary numbers...

    Please Can someone paraphrase this ? : 1.4 Binary Subtractor The subtraction of unsigned binary numbers can be done most conveniently by means of complement. Subtraction A–B can be done by tacking the 2’s complement of B and adding it to A. The 2’s complement can be obtained by taking the 1’s complement and adding one to the least significant pair of bits. The 1’s complement can be implemented with the inverters and a one can be added to the...

  • A full subtractor can be built using two "Half Subtractor" devices and an OR gate. Design...

    A full subtractor can be built using two "Half Subtractor" devices and an OR gate. Design and test a full subtractor (schematic diagram and truth table shown below). Write the expressions of the difference and the borrow beside the circuit. Input Output x y bi bi+1 d 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0...

  • Write the Verilog HDL textfixture stimulus code for an 4 bit binary full adder

    Write the Verilog HDL textfixture stimulus code for an 4 bit binary full adder

  • In quartus prime Implement a 4-bit adder/subtractor using structural VHDL. The circuit will have two 4-bit...

    In quartus prime Implement a 4-bit adder/subtractor using structural VHDL. The circuit will have two 4-bit data inputs (A and B), a control line (add /sub), a 4-bit sum output (S), a carry-out bit (Cout), and an overflow flag. You need two VHDL files (fulladd.vhd) and (hybrid.vhd) to implement the design. VHDL code, fulladd.vhd, will implement a single-bit full adder. The VHDL file, hybrid.vhd, will create four instances of the single-bit full adder. Four XOR gates will be needed to...

  • a) Write a Verilog module that implements a 1-bit partial full adder (PFA). b) Through instantiating...

    a) Write a Verilog module that implements a 1-bit partial full adder (PFA). b) Through instantiating the module in a) plus other logic, implement a 4-bit full adder with Verilog. c) Write a proper test-bench and stimulus, thoroughly test your 4 bit carry lookahead adder. d) Show a waveform snapshot that indicates you adder can correctly compute 0101 + 1101 and show your results.

  • [Paperl (10 pts.) Design a circuit that takes in four 4-bit unsigned numbers, A (A3..Ao), B (B3.....

    [Paperl (10 pts.) Design a circuit that takes in four 4-bit unsigned numbers, A (A3..Ao), B (B3..Bo), C (C3-C), and D (D3..Do) and produces the 6-bit unsigned sum of those numbers. You should use three 4-bit adder blocks (74LS283's), and a minimal number of full adders or half adder build blocks. You should organize your adder circuits to perform as many additions in parallel (at the same time) as possible. Getting started: Write out the columns of addition and see...

  • Introduction: This experiment studies the design of an 8-bit adder/subtractor circuit using VHDL capture. The experiment...

    Introduction: This experiment studies the design of an 8-bit adder/subtractor circuit using VHDL capture. The experiment investigates the implementation of addition and subtraction operations with circuits. This lab uses the virtual simulation environment to validate the design practically in the FPGA board. Equipment: • This experiment requires Quartus Prime and the Intel's DE2-115 FPGA board. • All students should have the Intel QP and ModelSim-Intel-Starter-Edition softwares installed in personal computers. • VPN connection to UNB Network and remote desktop software...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT