B
bl
Guest
I would like to create a parameterized synthsizeable piece of code in
verilog or system verilog to assign a vector
a section of the vector using a variable as the index.
Consider the following snippet:
integer index, index_base;
parameter max = 4;
for (index_base = 0; index_base<max; index_base = index_base+1)
begin
vector_out = vector_in
[((index_base + 1)*max-1): (index_base*max)]
end
The code above is not acceptable code as a part of the bus cannot be
extracted in this manner as the indices are not
constants while extracting several bits. However, if one were indexing
through it a bit at a time the simulators support
it.
I could get around it by changing it to the following:
for (index_base = 0; index_base<max; index_base = index_base+1)
begin
for (index = 0; index < max; index = index + 1)
begin
vector_out[index] = vector_in[(index_base*max)+ index];
end
end
This works but gets cumbersome and less readable. Is there a construct
in verilog 2k or system verilog that is less convoluted.
Thanks
bl
verilog or system verilog to assign a vector
a section of the vector using a variable as the index.
Consider the following snippet:
integer index, index_base;
parameter max = 4;
for (index_base = 0; index_base<max; index_base = index_base+1)
begin
vector_out = vector_in
[((index_base + 1)*max-1): (index_base*max)]
end
The code above is not acceptable code as a part of the bus cannot be
extracted in this manner as the indices are not
constants while extracting several bits. However, if one were indexing
through it a bit at a time the simulators support
it.
I could get around it by changing it to the following:
for (index_base = 0; index_base<max; index_base = index_base+1)
begin
for (index = 0; index < max; index = index + 1)
begin
vector_out[index] = vector_in[(index_base*max)+ index];
end
end
This works but gets cumbersome and less readable. Is there a construct
in verilog 2k or system verilog that is less convoluted.
Thanks
bl