views:

199

answers:

4
                for (j=0;j<k;j=j+1) begin:loop2
                    assign row[i+1][j][m+i:0] = {1'b0,row[i][j][m+i-1:0]};
                end

row is a register.

It does not work as I am doing it. Can anyone please help me to fix it?

Thank you very much.

A: 

When I try to compile your code (using the VCS simulator), I get the following type of compile error:

The following expression should be a constant: (m+i)

Obviously, since you have provided an incomplete code sample, I have had to make many assumptions about how you have declared your variables. I assumed that i and m are integer variables. If that is the case, you could attempt to use a generate block.

If that is not the case, you must:

  1. Show more Verilog code.
  2. Show the exact compiler error and/or warning messages you get.

"It does not work as I am doing it" is not very descriptive.

toolic
I had made a new comment to update my code, please look at it and help me to fix it, thanks
shen
A: 

assign is used for a continuous assignment. It does not look like that is what you want. Remove the assign keyword for a regular procedural assignment.

mark4o
A: 

It is true that assign keyword should not be used there since that for loop has to be inside of an always block. Assign can only be used outside an always block. The error means that you are indexing the array with a variable expression.

I'm guessing that m is not a loop variable and therefore the values are unknown and could potentially result in invalid values for the array. This results in the expression being non sythesizable as well. If m is truly some variable value you are going to have to restructure your logic for it to work.

mux_master
It is not true that assign must be used outside of an always block. Verilog supports procedural continuous assignments with the syntax above (its just not what should have been used in this example). When applied it sets up a new continuous assign to the variable until a deassign is called. In practice they seem to be rarely used and only for testbench code to my knowledge.
JeffW
A: 
    for (d=k-1;d>0;d=d-1) begin:loop8
        input_temp[d][0][m+d-1:0] <= {s_temp[d-1][m+d-2],s_temp[d-1][m+d-2:0]};
        input_temp[d][1][m+d-1:0] <= {c_temp[d-1][m+d-2:0],1'b0};
        for (c=0;c<k;c=c+1) begin:loop5
            row[d][c][m+d-1:0] <= {row[d-1][c][m+d-2],row[d-1][c][m+d-2:0]};
        end
    end

This is my updated code, which correct all the error, but it still does not work, this code block is inside always. m is parameter.

Can you please help me out, thanks

shen
You still have not explained in detail how it does not work. Are you trying to simluate? Synthesize? Other? Do you get compile errors? If so, have you spent any time reading the documentation that comes with your tool to understand the errors? If you are simulating, how does the result vary from your expectations? Also, it is better to update your original question, rather than ask another question here.
toolic