Question

Design a verilog code for four-bit subtractor. write the simulation code and constraints file for nexys...

Design a verilog code for four-bit subtractor. write the simulation code and constraints file for nexys 4.

Homework Answers

Answer #1
module fadder (A, B, Cin, Sum, Cout);
    input A, B;
    input Cin;
    output Sum;
    output Cout;
    wire t1,t2,t3,t4;
  xor x1(t1,A,B);
  xor x2(Sum,t1,Cin);
  and g1(t2,A,B);
  and g2(t3,B,Cin);
  and g3(t4,Cin,A);
  or  g4(Cout,t2,t3,t4);  
endmodule


module add_sub_4 (A, B, In, Res, Out);
    input [3:0] A, B;
    input In;
    output [3:0] Res;
    output Out;
    wire t1,t2,t3,t4,t5,t6,t7;


          xor x3(t3,B[0],In);
          xor x4(t4,B[1],In);
          xor x5(t5,B[2],In);
          xor x6(t6,B[3],In);
          fadder f5(A[0],t3,In,Res[0],t1);
          fadder f6(A[1],t4,t1,Res[1],t2);
          fadder f7(A[2],t5,t2,Res[2],t3);
          fadder f8(A[3],t6,t3,Res[3],Out);  
endmodule
Know the answer?
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
Similar Questions
Design a 4 to 16 decoder using Verilog HDL. The inputs are a four-bit vector W=...
Design a 4 to 16 decoder using Verilog HDL. The inputs are a four-bit vector W= [w1 w2 w3 w4] and an enable signal En. The outputs are represented by the 16-bit vector Y= [y0 y1 …..y15]. a) Write Verilog HDL behavioral style code for 2-to-4 decoder. b) Write Verilog HDL behavioral style code for 4-to-16 decoder by instantiation of 2-to-4 decoders.
Design a 4 to 16 decoder using Verilog HDL. The inputs are a four-bit vector W=...
Design a 4 to 16 decoder using Verilog HDL. The inputs are a four-bit vector W= [w1 w2 w3 w4] and an enable signal En. The outputs are represented by the 16-bit vector Y= [y0 y1 …..y15]. a) Write Verilog HDL behavioral style code for 2-to-4 decoder. b) Write Verilog HDL behavioral style code for 4-to-16 decoder by instantiation of 2-to-4 decoders.
VERILOG Design an Arithmetic Logic Unit (ALU) that can perform four-bit 1. Four-bit addition; 2. Four-bit...
VERILOG Design an Arithmetic Logic Unit (ALU) that can perform four-bit 1. Four-bit addition; 2. Four-bit subtraction; 3. Four-bit multiplication; 4. Four-bit comparator (that compares two binary numbers to check whether two numbers are equal, or one is less/greater than other). Write test benches and simulate each module/submodule. Hint: First make individual modules of the four-bit adder, four-bit subtractor, four-bit multiplier, four-bit comparator modules (make all these in same/one project) and then use a multiplexer to combine these modules to...
Please write verilog code for a 4-bit Carry Look-Ahead (CLA) Adder.
Please write verilog code for a 4-bit Carry Look-Ahead (CLA) Adder.
Use contraction beginning with a 4-bit adder-subtractor with carry in, to design a 4-bit circuit without...
Use contraction beginning with a 4-bit adder-subtractor with carry in, to design a 4-bit circuit without carry out that increments its input by 0010 for input S=0 and decrements its input by 0010 for input S=1. Perform the design by designing the distinct 1-bit full adder cells needed and indicating the type of cell used in each of the four bit positions.
Design and code a Verilog module to convert a 4 digit unsigned BCD whole number into...
Design and code a Verilog module to convert a 4 digit unsigned BCD whole number into a 14 bit binary number.
Write verilog code for a 8:1 Mux using the blocks of 2:1 Mux; Draw the block...
Write verilog code for a 8:1 Mux using the blocks of 2:1 Mux; Draw the block diagram for this design and write the truth table to prove that the design works as intended. Write verilog code for a 16:1 Mux using the blocks of 4:1 Mux; Draw the block diagram for this design and write the truth table to prove that the design works as intended.
Write verilog code for a 16:1 Mux using the blocks of 4:1 Mux; Draw the block...
Write verilog code for a 16:1 Mux using the blocks of 4:1 Mux; Draw the block diagram for this design and write the truth table to prove that the design works as intended.
Write down the VERILOG code for a 2-to-4 decoder and the testbench code to test it
Write down the VERILOG code for a 2-to-4 decoder and the testbench code to test it
Write down the VERILOG code for an AND gate and the testbench code to test it
Write down the VERILOG code for an AND gate and the testbench code to test it
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT