array element assignment problem

T

thomasc

Guest
I've been stuck in this problem for a couple of days. Below is the code
fragment that's causing the problem.

On the third line, I'm trying to change the value of an element the array,
called rx_SB. The index of the element(root_x1_LO) has been calculated
correctly in a separate block of code. And other signals(SE_colunt &
clk_RS) has been set properly so the 'if' statement becomes true and the
third line is executed. I witnessed that the simulator(ModelSim) executes
the third line but he value does not change. I simulated the entire code
further to see if the value was updated at the end of the clock cycle.
However, it wasn't.

Please take a look at the code below and let me know what's causing this
problem.
Thanks much in advance.

Please help!

=================================================

always @(posedge clk_RS) begin
if ((SE_count_LO)&&(en_RSE_LO)) begin
rx_SB[root_x1_LO] <= rx_SB[root_x1_LO]^syndrome0_LO; // line 3

en_RSE_LO <= 1'b0;
en_FX1_LO <= 1'b0;
end
end //always


// In order to see if the calculation is done correctly,
// I put the code below instead of line 3.
// But the value of 'rx_err_data' and 'dummy8' does not change.

/* rx_err_data <= rx_SB[root_x1_LO];
dummy8_LO <= rx_err_data ^ syndrome0_LO;
rx_SB[root_x1_LO] <= rx_err_data^syndrome0_LO; */

=================================================
 
Hi Neo,
Yes, I've checked the value of syndrome0_LO, it is not zero. Actually the
calculation of "rx_SB[root_x1_LO]^syndrome0_LO" tunrs out to be unknown(x)
or the new value is not assigned to the array element.
 
Hi,

I hate to debug with waveform when there are arrays involved. Try this:

=================================================

always @(posedge clk_RS) begin
if ((SE_count_LO)&&(en_RSE_LO)) begin
$display ("%d... rx_SB[%d] = %b, syndrome= %b",
$stime, root_x1_LO, rx_SB[root_x1_LO], syndrome0_LO);
^syndrome0_LO; // line 3

en_RSE_LO <= 1'b0;
en_FX1_LO <= 1'b0;
end
end //always
To observe what happens afterwards, do this:

always @ (posedge clk_RS)
if ((SE_count_LO)&&(en_RSE_LO))
#0.1 $display ("%d... After change: rx_SB[%d] = %b"
$stime, root_x1_LO, rx_SB[root_x1_LO]);

cheers,

jz
 
The value of root_x1_LO is 4, which is correct and valid index of the array
rx_SB(an 8x15 array) Strangely, when I assigned
rx_SB[root_x1_LO] to a temporary register, the temp regiser's value is not
updated. I don't understand what the problem is.
 
Could it be that the array is not initialized?

HTH,
Jim

"thomasc" <altecsplinter@hotmail.com> wrote in message
news:86bc1175bbe68046d43ad6b7e722e6ec@localhost.talkaboutprogramming.com...
I've been stuck in this problem for a couple of days. Below is the code
fragment that's causing the problem.

On the third line, I'm trying to change the value of an element the array,
called rx_SB. The index of the element(root_x1_LO) has been calculated
correctly in a separate block of code. And other signals(SE_colunt &
clk_RS) has been set properly so the 'if' statement becomes true and the
third line is executed. I witnessed that the simulator(ModelSim) executes
the third line but he value does not change. I simulated the entire code
further to see if the value was updated at the end of the clock cycle.
However, it wasn't.

Please take a look at the code below and let me know what's causing this
problem.
Thanks much in advance.

Please help!

=================================================

always @(posedge clk_RS) begin
if ((SE_count_LO)&&(en_RSE_LO)) begin
rx_SB[root_x1_LO] <= rx_SB[root_x1_LO]^syndrome0_LO; // line 3

en_RSE_LO <= 1'b0;
en_FX1_LO <= 1'b0;
end
end //always


// In order to see if the calculation is done correctly,
// I put the code below instead of line 3.
// But the value of 'rx_err_data' and 'dummy8' does not change.

/* rx_err_data <= rx_SB[root_x1_LO];
dummy8_LO <= rx_err_data ^ syndrome0_LO;
rx_SB[root_x1_LO] <= rx_err_data^syndrome0_LO; */

=================================================
 
have you looked at the value of syndrome0_LO. if its zero then the
values wont change.
 
try verifying the value of root_x1_LO by assigning it to a temporary
variable.
 
Have you tried to use "=" instead of using "<=" ?

or try to use for statement instead of if statement, since the
en_RSE_LO is one bit, add 1 should change the value of zero and exit
the for loop, so the for statment execute only one time that provide
the same mechanism as using if statement
 
A small suggestion since you used the word try in respect to = and <=
..
You should not "try" as while in some cases you might get away or
just get error in other cases you might get something you didn't
expect.
So unless you are sure what you do let me suggest a general rule that
will always work.

If the reg is FF (like in always @ posedge clk ...) than use only <=
Any other case use =

Have fun.
 

Welcome to EDABoard.com

Sponsor

Back
Top