P
Peng Yu
Guest
Hi,
The in and out of the first code list is always x. The second code
list is corrected. Why the first isn't correct? Must I use a function
instead of a module under this situation?
Thanks!
Peng
/////the code with errors
module reverse(output out, input in);
assign out = ~in;
endmodule
module timing;
reg in, clock;
wire out;
reverse reverse(out, in);
initial begin : init_value
in = 0;
clock = 0;
#50 $stop;
end
always begin
in <= out;
@(posedge clock);
$display("time=%0t,in=%b,out=%b,clock=%b", $time, in, out, clock);
end
always
#5 clock = ~clock;
endmodule
///////////the end of the incorrect code
////the code list without errors
module timing;
reg in, clock;
function reverse(input in);
reverse = ~in;
endfunction
initial begin : init_value
in = 0;
clock = 0;
#50 $stop;
end
always begin
in <= reverse(in);
@(posedge clock);
$display("time=%0t,in=%b,clock=%b", $time, in, clock);
end
always
#5 clock = ~clock;
endmodule
///////the end of the correct code
The in and out of the first code list is always x. The second code
list is corrected. Why the first isn't correct? Must I use a function
instead of a module under this situation?
Thanks!
Peng
/////the code with errors
module reverse(output out, input in);
assign out = ~in;
endmodule
module timing;
reg in, clock;
wire out;
reverse reverse(out, in);
initial begin : init_value
in = 0;
clock = 0;
#50 $stop;
end
always begin
in <= out;
@(posedge clock);
$display("time=%0t,in=%b,out=%b,clock=%b", $time, in, out, clock);
end
always
#5 clock = ~clock;
endmodule
///////////the end of the incorrect code
////the code list without errors
module timing;
reg in, clock;
function reverse(input in);
reverse = ~in;
endfunction
initial begin : init_value
in = 0;
clock = 0;
#50 $stop;
end
always begin
in <= reverse(in);
@(posedge clock);
$display("time=%0t,in=%b,clock=%b", $time, in, clock);
end
always
#5 clock = ~clock;
endmodule
///////the end of the correct code