1) Hi, I'm trying to write a code that looks like this
1 | localparam NUM_OF_LINES = 2; |
2 | localparam ROWS = 2; |
3 | |
4 | genvar i, j; |
5 | |
6 | generate
|
7 | for (i = 0; i < NUM_OF_LINES; i = i+1) |
8 | begin: lines_loop |
9 | for (i = 0; i < NUM_OF_ROWS; i = i+1) |
10 | begin: rows_loop |
11 | always @(posedge clk) |
12 | data[i][j] <= prev_data [i][j]; |
13 | end
|
14 | end
|
ofcourse all the regs are declared. I can't compile it when it's like that, what is the right syntax for loop within a loop? 2) localparam WIDTH = 10; How can I right an addition command with the width of the parameter? explanation: I'm trying to do: data <= data + 1; when data is the width of WIDTH but I don't want it to do the addition with 32 bits so i tried to write "data <= data + WIDTH'h1" but it's not working
:
Edited by Moderator
Yoni C. wrote: > I can't compile it when it's like that What error message do you get? > what is the right syntax for loop within a loop? Lets go one step back: do you know, that a 'loop' in a HDL is completely different from a loop in C? To keep things short: a clock inside a HDL loop is a very tricky thing. What hardware do you expect for that? What hardware do you want to "describe"? (as HDL is read "hardware DESCRIPTION language" you should know what hardware you want to describe...)
:
Edited by Moderator
The messege i get: Error (10049): Verilog HDL error at arrays.sv(20): value must not be assigned to nonvariable "j". I don't realy understand the deferance between loop in c and verilog.
Yoni C. wrote: > for (i = 0; i < NUM_OF_LINES; i = i+1) > ... > for (i = 0; i < NUM_OF_ROWS; i = i+1) Where is j used?
Yoni C. wrote: > Error (10049): Verilog HDL error at arrays.sv(20): value must not be > assigned to nonvariable "j". Which line is line 20?
Lothar M. wrote: > To keep things short: a clock inside a HDL loop is a very tricky thing. > What hardware do you expect for that? What hardware do you want to > "describe"? (as HDL is read "hardware DESCRIPTION language" you should > know what hardware you want to describe...) I want to describe assigning from the registers of "prev_data" to the registers of "data", both of them are 2 dimention registers array.
:
Edited by User