J
JT
Guest
Here's a snippet of code that doesn't work as expected.
What I'm trying to do is have a parameter control the size of the
compare so that I can override the parameter at simulation time to
speed up the compare event;
The parameter TRANSMIT_SYNC_RANGE_PARAM is set to 7 by the simulation,
otherwise it is defaulted to 15.
The first compare of comparing txcounter[7:0] to 8'b11111111 works as
expected. The second compare of txcounter[7:0] to 16'hFFFF never
asserts. I thought that verilog would have just ignored the upper 8
bits of the compare to value but instead it must be extending the LHS
of the compare.
What are the verilog rules on vector extension?
always @ (posedge TX_DATACLK_i or posedge RESET_i)
begin
if (RESET_i) begin
txcounter <= 0;
change <= 0;
dbg_change <= 0;
end //if
else
begin
txcounter <= txcounter + 1;
if (txcounter[7:0] == 8'b11111111)
dbg_change <= 1;
else
dbg_change <= 0;
if (txcounter[TRANSMIT_SYNC_RANGE_PARAM:0] == 16'hffff)
change <= 1;
else
change <= 0;
What I'm trying to do is have a parameter control the size of the
compare so that I can override the parameter at simulation time to
speed up the compare event;
The parameter TRANSMIT_SYNC_RANGE_PARAM is set to 7 by the simulation,
otherwise it is defaulted to 15.
The first compare of comparing txcounter[7:0] to 8'b11111111 works as
expected. The second compare of txcounter[7:0] to 16'hFFFF never
asserts. I thought that verilog would have just ignored the upper 8
bits of the compare to value but instead it must be extending the LHS
of the compare.
What are the verilog rules on vector extension?
always @ (posedge TX_DATACLK_i or posedge RESET_i)
begin
if (RESET_i) begin
txcounter <= 0;
change <= 0;
dbg_change <= 0;
end //if
else
begin
txcounter <= txcounter + 1;
if (txcounter[7:0] == 8'b11111111)
dbg_change <= 1;
else
dbg_change <= 0;
if (txcounter[TRANSMIT_SYNC_RANGE_PARAM:0] == 16'hffff)
change <= 1;
else
change <= 0;