jfzhan
Newbie level 4
![Newbie level 4](/styles/images/ranks/blevel1.gif)
Dear all,
There are bus A[0:100] ,B[0:15], and the register length[3:0].
The register length can be set by user.
If the length = 0, the B[0:15] = A[0:15],
If the length = 1, the B[0:15] = A[1:16],
If the length = 2, the B[0:15] = A[2:17],
If the length = 3, the B[0:15] = A[3:18], and so on.
can I write like this,
assign s_point = length;
assign e_point = length + 15;
assign B[0:15] = A[s_point:e_point];
The best method is the following method?
always@(length or A) begin
case(length)
0 : B[0:15] = A[0:15];
1 : B[0:15] = A[1:15];
2 : B[0:15] = A[2:15];
...
15 : B[0:15] = A[15:30];
endcase
end
Does there have any good method to write??
Thanks!!
There are bus A[0:100] ,B[0:15], and the register length[3:0].
The register length can be set by user.
If the length = 0, the B[0:15] = A[0:15],
If the length = 1, the B[0:15] = A[1:16],
If the length = 2, the B[0:15] = A[2:17],
If the length = 3, the B[0:15] = A[3:18], and so on.
can I write like this,
assign s_point = length;
assign e_point = length + 15;
assign B[0:15] = A[s_point:e_point];
The best method is the following method?
always@(length or A) begin
case(length)
0 : B[0:15] = A[0:15];
1 : B[0:15] = A[1:15];
2 : B[0:15] = A[2:15];
...
15 : B[0:15] = A[15:30];
endcase
end
Does there have any good method to write??
Thanks!!