Question

In: Electrical Engineering

Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using...

Design and Test an 8-bit Adder using 4-bit adder. Use
4-bit adder coded in class using full adder that is coded using data flow model. Use test bench
to test 8-bit adder and consider at least five different test vectors to test it.

Solutions

Expert Solution

//verilog top level code for 8 bit adder using 4 bit adders as internal module instantiations

module adder_8bit ( A,B,Cin,S,Cout);

  

//input ports declarations

input [7:0] A,B;

input Cin;

  

//output port declarations

output [7:0] S; //sum output

output Cout ; //carry output

//internal signal declarations

wire C ;

  

//instantiation of 4 bit adders

adder_4bit U0 ( A[3:0],B[3:0],Cin,S[3:0],C);

adder_4bit U1 ( A[7:4],B[7:4],C,S[7:4],Cout);

  

endmodule

  

//verilog code for 4 bit adder using full adders as internal module instantiations

module adder_4bit ( A,B,Cin,S,Cout);

  

//input ports declarations

input [3:0] A,B;

input Cin;

  

//output port declarations

output [3:0] S; //sum output

output Cout ; //carry output

  

  

//internal signal declarations

wire [2:0] c ;

  

//instantiaion of full adders

fulladder F0 ( A[0] , B[0] , Cin , S[0] , c[0] );

fulladder F1 ( A[1] , B[1] , c[0] , S[1] , c[1] );

fulladder F2 ( A[2] , B[2] , c[1] , S[2] , c[2] );

fulladder F3 ( A[3] , B[3] , c[2] , S[3] , Cout );

  

endmodule

  

// DATAFLOW verilog code full adder module

module fulladder (

//input ports declarations

input A,B,Cin,

//output port declartions

output S,Cout);

  

//sum logic

assign S = (A ^ B ^ Cin);

//carry logic

assign Cout = ( A & B ) | ( B & Cin) | (A & Cin) ;

  

endmodule

// verilog testbench code for top module of 8 bit adder  

module test_adder_8bit ;

  

//inputs

reg [7:0] A,B;

reg Cin;

  

//outputs

wire [7:0] S;

wire Cout;

  

//instantiate UUT (unit under test) of top module

adder_8bit UUT (.A(A),.B(B),.Cin(Cin),.S(S),.Cout(Cout));

  

//test vectore for 8 bit adder (input stimulus generations)

initial begin

$dumpfile ("waves.vcd");

$dumpvars;

A = 8'b00101101 ; B = 8'b00101101; Cin = 1'b0; #10;

A = 8'b00100101 ; B = 8'b00100001; Cin = 1'b0; #10;

A = 8'b10100001 ; B = 8'b10101101; Cin = 1'b0; #10;

A = 8'b00100000 ; B = 8'b00100001; Cin = 1'b0; #10;

A = 8'b10101101 ; B = 8'b00101101; Cin = 1'b0; #10;

A = 8'b11101000 ; B = 8'b10100100; Cin = 1'b1; #10;

A = 8'b00100100 ; B = 8'b01101101; Cin = 1'b0; #10;

A = 8'b10101101 ; B = 8'b00101101; Cin = 1'b0; #10;

$finish;

end

  

  

endmodule

// Simulation waveforms


Related Solutions

Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design an 8-bit adder. Show Verilog code and testbench.
Design an 8-bit adder. Show Verilog code and testbench.
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
Problem 3.73 (1-bit full adder using carry lookahead – gate level circuit) 3.73 Design a 4-bit...
Problem 3.73 (1-bit full adder using carry lookahead – gate level circuit) 3.73 Design a 4-bit full adder using carry look-ahead rather than ripple carry.
Design and implementation 4-bit binary full adder with fast carry using behavioral and structural style of...
Design and implementation 4-bit binary full adder with fast carry using behavioral and structural style of modelling. (LS 7483) I want logic diagram and its truth table also i want code for it in VDHL software
Design and implementation 4-bit binary full adder with fast carry using behavioral and structural style of...
Design and implementation 4-bit binary full adder with fast carry using behavioral and structural style of modelling. (LS 7483) i want logic diagram and truth table
(i) Design an 8-bit ripple adder which can add together two 8-bit numbers, inside a hierarchical...
(i) Design an 8-bit ripple adder which can add together two 8-bit numbers, inside a hierarchical block. Explain your design. Name your block with your student number: eg “123456 ripple adder”. (ii) Test your circuit in block form, showing four example additions with manual calculations to show they are correct. [
Create a 4-bit full adder design using VHDL in vivado 2017.2. Project description: You need to...
Create a 4-bit full adder design using VHDL in vivado 2017.2. Project description: You need to create a vhd file for the four-bit full adder. Note: Instead of using bit, please use std_logic; instead of using bit_vector, please use std_logic_vector. One simulation source is required, i.e. testbench Please don't write out on paper. Code written out in text or screen shots would be very much apprecitated.
Design an 8-bit adder. Show the truth table, logic circuit, and Verilog code.
Design an 8-bit adder. Show the truth table, logic circuit, and Verilog code.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT