Posts

Showing posts from October, 2020

Ads

Verilog: Half Subtractor Behavioral Modelling with Testbench Code

Image
   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: Half Subtractor Behavioral Modelling Verilog Code  

Verilog: Half Adder Behavioral Modelling with Testbench Code

Image
  Verilog Code Half Adder Behavioral Modelling module Half_Adder ( input a, b; output sum, carry ); always @(a or b) assign {carry,sum} = 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, sum=%b, carry=%b”, a, b, sum, carry); end endmodule Xilinx Output: Half Adder Verilog Code Behavioral Modelling

Full Subtractor Verilog Code in Behavioral Modelling with Testbench Code

Image
Full Subtractor Verilog Code in Behavioral Modelling module Full_Sub ( input a, b, bin; output diff, borr ); always @(a or b or bin) assign {borr,diff} = (~a) + b + bin; endmodule // test-bench initial begin a=0; b=0; bin=0; #100; //wait 100ns for global reset to finish //add stimulus here #100 a=0; b=1; bin=0; #100 a=1; b=0; bin=0; #100 a=1; b=1; bin=0; end initial begin #100 $ monitor (“a=%b, b=%b, bin=%b, diff=%b, borr=%b”, a, b, bin, diff, borr); end endmodule Xilinx Output: Full Subtractor Verilog Code Behavioral Modelling

Verilog: XNOR Gate Behavioral Modelling with Testbench Code

Image
Verilog Code XNOR Gate Behavioral Modelling module XNOR_GATE ( input a, b, output out ); reg out; always @(a or b) begin if (a==b) out = 1’b1; else out = 1’b0; 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, out=%b”, a, b, out); end endmodule Xilinx Output: Verilog XNOR Gate Behavioral Modelling Response

Verilog: XOR Gate Behavioral Modelling with Testbench Code

Image
Verilog Code XOR Gate Behavioral Modelling module XOR_GATE ( input a, b, output out ); reg out; always @(a or b) begin if (a==b) out = 1’b0; else out = 1’b1; 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, out=%b”, a, b, out); end endmodule Xilinx Output: XOR Gate Verilog Behavioral Modelling

Verilog: NOR Gate Behavioral Modelling with Testbench Code

Image
     Verilog Code NOR Gate Behavioral Modelling module NOR_GATE ( input a, b, output out ); reg out; always @(a or b) begin if (a==0 & b==0) out = 1’b1; else out = 1’b0; 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, out=%b”, a, b, out); end endmodule Xilinx Output: NOR Gate Behavioral Modelling Verilog

Verilog: NOT Gate Behavioral Modelling with Testbench Code

Image
  Verilog Code NOT Gate Behavioral Modelling // main module NOT_GATE ( input a; output out ); reg out; always @(a) begin if (a==0) out = 1’b1; else out = 1’b0; endmodule // test-bench initial begin a=0; #100; //wait 100ns for global reset to finish //add stimulus here #100 a=0; #100 a=1; end initial begin #100 $ monitor (“a=%b, out=%b”, a, out); end endmodule Xilinx Output: Not Gate Behavioral Modelling

Ads

Popular posts from this blog

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

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

VLSI: 2 Bit Magnitude Comparator Dataflow Modelling

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

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