Reputation: 142
My input consists of a parameterized number of units. The output I need is to remove the first bit of each unit.
For example if the input has units of size 3-bits each and the input value was 011011
, the output should be 1111
Here is the solution i used for this:
parameter data_in_size = 11;
parameter data_out_size = 10;
parameter units = 4;
parameter skip_bits = 1;
input [data_in_size * units - 1 : 0] data_in;
output [data_in_size * units - 1 : 0] data_out;
genvar i;
generate
for (i = 0; i < units; i = i + 1) begin
assign data_out[data_out_size * i +: data_out_size] = data_in [(data_in_size * i + skip_bits) +: data_out_size];
end
endgenerate
But I get the following error The left-hand-side of continuous assignment is illegal
How can i get through this error and why i am getting it ?
Upvotes: 0
Views: 1343
Reputation: 4381
Your code works perfectly well. Might be a simulator issue.
But I would like to focus on logic implementation in your code. The logic seems to be wrong.
First error seems to be in declaration of data_out
and the slicing logic : data_in [(data_in_size * i + skip_bits) +: data_out_size]
must be replaced with: data_in [(data_in_size * i + skip_bits) +: data_in_size]
Lets suppose i=0; data_out_size=3; data_in_size=4
then the LHS evaluates to data_out[2:0] = data_in[4:1]
. When i=1
, data_out[5:3] = data_in[8:5]
. As you can see the bit slicing seems to be incorrect. Since LSB is sliced.
I think you might need to have following logic for bit slicing:
assign data_out[data_out_size * i +: data_out_size] = data_in[(data_in_size * i) +: (data_in_size - skip_bits)];
This will slice the MSB bit of every unit chunk, keeping the rest of bits as it is.
I simulated your code at EdaPlayground here. As an example, you will have following data_out and data_in values. Note the sliced MSB from each unit.
data_int = 1100101010010101
data_out = 100010001101
Upvotes: 2