Design a combinational circuit that accepts a 2-bit number and generates an output binary number equal to the square of the input number.

Design a combinational circuit that accepts a 2-bit number and generates an output binary number equal to the square of the input number.


SIMULATION
RTL ANALYSIS

VERILOG CODE

module obj3exp_5( input A,B, output W,X,Y,Z ); 

 assign W=(A&B);

 assign X=(A&!B); 

 assign Y=0; 

 assign Z=B;

 endmodule

TESTBENCH CODE

module obj3exp_5_tb(); 

 reg A,B; 

 wire W,X,Y,Z;

 obj3exp_5 tab(A,B,W,X,Y,Z);

 initial begin 

 A=0;B=0; 

 #100 

 A=0;B=1;

 #100

 A=1;B=0;

 #100 

 A=1;B=1; 

 #100 

 $stop;

 end 

endmodule

Post a Comment