Latest Post

Ads

Verilog: 4 Bit Full Adder Behavioral Modelling with Testbench Code

Verilog Code for 4 Bit Full Adder Behavioral Modelling with Testbench Code

module 4_bit_Add(
    input [3:0]a,b,
    input cin,
    output [3:0]sum,
    output cout
    );
reg [3:0]sum; 
reg cout;
 
always @ (a or b or cin)
   assign {cout,sum}= a + b + cin;
endmodule

//Testbench code for 4 Bit Full Adder Behavioral Modelling

initial begin
// Initialize Inputs 
a = 0; b = 0; cin = 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here 
#100 a=4; b=9; cin=1; 
#100 a=15; b=5; cin=1; 
#100 a=7; b=5; cin=0; 
#100 a=6; b=10; cin=1; 
end
initial begin 
#100 
$monitor(“a = %b, b = %b, cin = %b, sum = %b, cout = %b”, a, b, cin, sum, cout); 
end 
endmodule

Xillinx Output:

4 Bit Full Adder Behavioral Modelling
4 Bit Full Adder Behavioral Modelling Response

Also See:

List of Verilog Programs

Comments

Ads

Popular posts from this blog

VLSI: BCD to Excess 3 and Excess 3 to BCD Dataflow Modelling

Full Subtractor Verilog Code in Structural/Gate Level Modelling with Testbench

VLSI: 4-1 MUX Dataflow Modelling with Testbench

VLSI: Half Subtractor and Full Subtractor Gate Level Modelling

VLSI: 1-4 DEMUX (Demultiplexer) Dataflow Modelling with Testbench