the Verilog code for the design:
module HA(a,b,s,cout);
input a,b;
output s,cout;
assign s=a^b;
assign cout=a & b;
endmodule
module FA(a,b,cin,s,cout);
input a,b,cin;
output s,cout;
wire s1,c1,c2;
HA h1(a,b,s1,c1);
HA h2(cin,s1,s,c2);
or rrr1(cout,c1,c2);
endmodule
module four_bit_adder(a,b,cin,s,cout);
input [3:0] a,b;
input cin;
output [3:0] s;
output cout;
wire c0,c1,c2;
FA f0(a[0],b[0],cin,s[0],c0);
FA f1(a[1],b[1],c0,s[1],c1);
FA f2(a[2],b[2],c1,s[2],c2);
FA f3(a[3],b[3],c2,s[3],cout);
endmodule
module four_bit_add_Sub(a,b,sub,out,carry);
input [3:0] a,b;
input sub;
output [3:0] out;
output carry;
wire [3:0] b_out;
xor x1(b_out[0],b[0],sub);
xor x2(b_out[1],b[1],sub);
xor x3(b_out[2],b[2],sub);
xor x4(b_out[3],b[3],sub);
four_bit_adder f111(a,b_out,sub,out,carry);
endmodule
the incomplete module mentioned is also completed here
module four_bit_add_sub (SW,LEDG);
input [8:0] SW;
output [3:0] LEDG;
wire [3:0] B_ones,sum;
assign B_ones[0]=SW[0] ^ SW[1];
assign B_ones[1]=SW[0]^SW[2];
assign B_ones[2]=SW[0]^SW[3];
assign B_ones[3]=SW[0]^SW[3];
fout_bit_adder(sum,{SW[8:5],B_ones,SW[0]});// since b_ones is the input to adder
assign LEDG=sum;
endmodul
Question: Part 1: In the second part of this lab, we will extend our adder to...
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,...
Q3. The adder below adds two 16-bit numbers X and Y (i.e. S-X+Y), where X-Xi5Xi4...XiXo and Y-Y15Y14...YiYo. Assume we are using two's complement representation for our signed numbers, in which flipping all the bits of a number Y and adding one to it will give-Y. Modify the circuit below by including a signal P that picks whether the circuit will add them as X+Y, or subtract them as X-Y = X+(-Y) Suppose when P=0 the circuit will add and when...
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...
Please help to complete the code and write the testbench to design the following adder. 1.In this section, you add pipeline stage. 8 bits are used at every pipeline stage.Use the following template to complete your Verilog coding. // Addition of two 16 bit, 2's complement nos., n1 and n2. 8 bits addition at a time. Result is 17 bits. module adder_b (clk, n1, n2, sum) ; input clk ; input [15:0] n1 ; input [15:0] n2 ; output [16:0]...
1. What logic gates are known as universal gates? (1 point) a) nand, nor b) and, or, not c) nand, nor, xor, xnor d) None of the above 2. Write the half adder truth table. (4 points) 3. Fill in the blank. (1 point) A2 to 1 mux has input lines. 4. True or False? (1 point) A Boolean algebraic sum of products expression is the complement of the product of sums expression. 5. What is the minimum POS expression...
First you must create a logic circuit using only basic gates such as AND, OR, NOR, NAND, NOT, etc. to implement an ADDER capable of adding two 4 bit binary numbers. Second you must create a logic circuit using only basic gates such as AND, OR, NOR, NAND, NOT, etc. to implement a Subtractor that is capable of subtracting the second number from the first, by converting the second number into its 2's complement form and then adding the resulting...
You will use Quartus II to build an 8 bit arithmetic logic unit that performs the following functions: Control Value Function 000 Copy In1 to theResult unchanged 001 Copy In2 to theResult unchanged 010 Add In1 to In2 011 Subtract In2 from In1 100 And In1 and In2 101 Or In1 and In2 110 Shift left In1 by 1 bit 111 Shift right In1 by 1 bit You are allowed to use either gates/logic schematic, or else Verilog. We suggest...
i need sol for this questions please
EXERCISE 1 (9 Marks) PART (A) Let we consider a Full Adder (Fig.1) with: - 2 inputs A, B (1 bit) - Carry Input Cin - 2 Outputs S (sum) and Cout (Carry outpu A-1) Complete the truth table (1 Marks) Tab.1 : Truth Table INPUTS OUTPUTS 4 B Cins Cout H OH OH Fig. 1 : Full Adder 1 bit A-2) From the truth table, give the expressions of the outputs (1...
1. If we had two 4-bit signed 2's complement numbers, X--4 and Y-6 and we wanted to compare them, we might calculate X-Y (a) Show that calculation (b) Explain how the result tells us that Y>IX (c) Now show the calculation for Y. X (d) Explain how this also shows us that Y>X 2. We talked about an ALU that takes two 4-bit inputs, A and B, and then generates a 4-bit result, S, based on a 2-bit command, F1FO....
2. In this question, you are asked to design a synthesizable ALU in Verilog. This ALU gets two 9-bit signed inputs (A, B) in 2’s complement format, and a 4-bit select input (S) based on which decides about the operation that should be executed. The output is Q, and you determine the number of bits for Q in order to have a correct answer. What follows shows these operations: If S=0 Addition (i.e., A+B) If S=1 Subtraction (A-B) If S=2...