padfoot_1729
Newbie level 1
Hi guys,
I had been practicing a few problems in verilog and got stuck on this :
Question : write a program so that output should be 1 when 'x' is greater than or equal to 'y'
x and y are binary
My logic module:
My stimulus/ test-bench module :
--------------------------------------------
OUTPUT OBTAINED:
Please Help with the above issue, output is shown as 0 when x=1 and y=0.
Thank you!!
I had been practicing a few problems in verilog and got stuck on this :
Question : write a program so that output should be 1 when 'x' is greater than or equal to 'y'
x and y are binary
My logic module:
Code Verilog - [expand] 1 2 3 4 5 6 7 module comparator( input x, input y, output z); assign z = ~y + x ; endmodule
My stimulus/ test-bench module :
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 `timescale 1ns / 1ps module stimulus; reg x; reg y; wire z; comparator uut ( .x(x), .y(y), .z(z) ); initial begin x=0; y=0; #20 x=1; #20 y=1; #20 x=0; #40; end initial begin $monitor("x=%d, y=%d, z=%d \n",x,y,z); end endmodule
--------------------------------------------
OUTPUT OBTAINED:
Please Help with the above issue, output is shown as 0 when x=1 and y=0.
Thank you!!
Last edited by a moderator: