Saturday, January 28, 2023

   

TWO i/p (8bitwide) COMPARATOR:- 

module comp8 (gt8,eq8,lt8,A8,B8);
input[7:0]A8,B8;
output gt8,eq8,lt8;
wire [2:0]Y22;
wire a8,b8,c8,d8,e8,f8;
comp4 co11 (a8,b8,c8,{A8[7],A8[6],A8[5],A8[4]},{B8[7],B8[6],B8[5],B8[4]});
comp4 co22 (d8,e8,f8,{A8[3],A8[2],A8[1],A8[0]},{B8[3],B8[2],B8[1],B8[0]});
mux2x1_3b mm1 ({gt8,eq8,lt8},a8,Y22,3'b100);
mux2x1_3b mm2 (Y22,c8,{d8,e8,f8},3'b001);
endmodule

TEST BENCH:- 

module comp8_tb();
reg [7:0]A8,B8;
wire gt8,eq8,lt8;
comp8 dut (gt8,eq8,lt8,A8,B8);
initial
begin
repeat(20)
begin
{A8,B8}=$random;
#2
$display("A=",{A8}," B=",{B8},":"," greater:",gt8," equal:",eq8," lesser:",lt8);
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...