Latest Post

Ads

Verilog: Half Subtractor Behavioral Modelling with Testbench Code

  Verilog Code Half Subtractor Behavioral Modelling

module Half_Sub (

input a, b;

output diff, borr );

always @(a or b)

assign {borr,diff} = (~a) + b;

endmodule


// test-bench

initial begin

a=0; b=0;

#100;

//wait 100ns for global reset to finish

//add stimulus here

#100 a=0; b=1;

#100 a=1; b=0;

#100 a=1; b=1;

end

initial begin

#100 $monitor(“a=%b, b=%b, diff=%b, borr=%b”, a, b, diff, borr);

end

endmodule


Xilinx Output:

Verilog Code of Half Subtractor Behavioral Modelling Testbench
Half Subtractor Behavioral Modelling Verilog Code

 

Comments

Ads

Popular posts from this blog

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

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

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

VLSI: 4-1 MUX Dataflow Modelling with Testbench

1 to 4 DEMUX (Demultiplexer) Verilog CodeStructural/Gate Level Modelling with Testbench