Thursday, January 26, 2023

 

 

TWO i/p (2bitwide) COMPARATOR:- 


module comp2(gt2,eq2,lt2,A2,B2);
input[1:0]A2,B2;
output gt2,eq2,lt2;
wire [2:0]Y1;
wire a,b,c,d,e,f;
comp1  c1 (a,b,c,A2[1],B2[1]);
comp1  c2  (d,e,f,A2[0],B2[0]);
mux2x1_3b m1 ({gt2,eq2,lt2},a,Y1,3'b100);
mux2x1_3b m2 (Y1,c,{d,e,f},3'b001);
endmodule

TEST BENCH:- 

module comp2_tb();
reg [1:0]A2,B2;
wire gt2,eq2,lt2;
comp2 dut (gt2,eq2,lt2,A2,B2);
initial
begin
repeat(20)
begin
{A2,B2}=$random;
#2
$display("A=",{A2}," B=",{B2},":","greater:",gt2,"equal:",eq2,"lesser:",lt2);
end
end
endmodule












No comments:

Post a Comment

VERILOG CODES :-

 VERILOG CODES :- (by NUTAN.K) COMBINATIONAL :-  1.MUX:- (one bit wide)  1a) 2:1 MUX and its Testbench   1b) 4:1 MUX using 2:1 and its testb...