Skip to content

Commit a9c7946

Browse files
committed
Change parameter concatenation to increments of DEST_WIDTH
1 parent ad3905a commit a9c7946

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

rtl/axis_switch.v

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ module axis_switch #
4141
parameter DEST_WIDTH = $clog2(S_COUNT),
4242
parameter USER_ENABLE = 1,
4343
parameter USER_WIDTH = 1,
44-
parameter M_BASE = {32'd3, 32'd2, 32'd1, 32'd0},
45-
parameter M_TOP = {32'd3, 32'd2, 32'd1, 32'd0},
44+
parameter M_BASE = {2'd3, 2'd2, 2'd1, 2'd0},
45+
parameter M_TOP = {2'd3, 2'd2, 2'd1, 2'd0},
4646
parameter M_CONNECT = {M_COUNT{{S_COUNT{1'b1}}}},
4747
parameter S_REG_TYPE = 0,
4848
parameter M_REG_TYPE = 2,
@@ -93,24 +93,24 @@ initial begin
9393
end
9494

9595
for (i = 0; i < M_COUNT; i = i + 1) begin
96-
if (M_BASE[i*32 +: 32] < 0 || M_BASE[i*32 +: 32] > 2**DEST_WIDTH-1 || M_TOP[i*32 +: 32] < 0 || M_TOP[i*32 +: 32] > 2**DEST_WIDTH-1) begin
96+
if (M_BASE[i*DEST_WIDTH +: DEST_WIDTH] < 0 || M_BASE[i*DEST_WIDTH +: DEST_WIDTH] > 2**DEST_WIDTH-1 || M_TOP[i*DEST_WIDTH +: DEST_WIDTH] < 0 || M_TOP[i*DEST_WIDTH +: DEST_WIDTH] > 2**DEST_WIDTH-1) begin
9797
$error("Error: value out of range");
9898
$finish;
9999
end
100100
end
101101

102102
for (i = 0; i < M_COUNT; i = i + 1) begin
103-
if (M_BASE[i*32 +: 32] > M_TOP[i*32 +: 32]) begin
103+
if (M_BASE[i*DEST_WIDTH +: DEST_WIDTH] > M_TOP[i*DEST_WIDTH +: DEST_WIDTH]) begin
104104
$error("Error: invalid range");
105105
$finish;
106106
end
107107
end
108108

109109
for (i = 0; i < M_COUNT; i = i + 1) begin
110110
for (j = i+1; j < M_COUNT; j = j + 1) begin
111-
if (M_BASE[i*32 +: 32] <= M_TOP[j*32 +: 32] && M_BASE[j*32 +: 32] <= M_TOP[i*32 +: 32]) begin
112-
$display("%d: %08x-%08x", i, M_BASE[i*32 +: 32], M_TOP[i*32 +: 32]);
113-
$display("%d: %08x-%08x", j, M_BASE[j*32 +: 32], M_TOP[j*32 +: 32]);
111+
if (M_BASE[i*DEST_WIDTH +: DEST_WIDTH] <= M_TOP[j*DEST_WIDTH +: DEST_WIDTH] && M_BASE[j*DEST_WIDTH +: DEST_WIDTH] <= M_TOP[i*DEST_WIDTH +: DEST_WIDTH]) begin
112+
$display("%d: %08x-%08x", i, M_BASE[i*DEST_WIDTH +: DEST_WIDTH], M_TOP[i*DEST_WIDTH +: DEST_WIDTH]);
113+
$display("%d: %08x-%08x", j, M_BASE[j*DEST_WIDTH +: DEST_WIDTH], M_TOP[j*DEST_WIDTH +: DEST_WIDTH]);
114114
$error("Error: ranges overlap");
115115
$finish;
116116
end
@@ -153,7 +153,7 @@ generate
153153
select_valid_next = 1'b0;
154154
drop_next = 1'b1;
155155
for (k = 0; k < M_COUNT; k = k + 1) begin
156-
if (int_s_axis_tdest[m*DEST_WIDTH +: DEST_WIDTH] >= M_BASE[k*32 +: 32] && int_s_axis_tdest[m*DEST_WIDTH +: DEST_WIDTH] <= M_TOP[k*32 +: 32] && (M_CONNECT & (1 << (m+k*S_COUNT)))) begin
156+
if (int_s_axis_tdest[m*DEST_WIDTH +: DEST_WIDTH] >= M_BASE[k*DEST_WIDTH +: DEST_WIDTH] && int_s_axis_tdest[m*DEST_WIDTH +: DEST_WIDTH] <= M_TOP[k*DEST_WIDTH +: DEST_WIDTH] && (M_CONNECT & (1 << (m+k*S_COUNT)))) begin
157157
select_next = k;
158158
select_valid_next = 1'b1;
159159
drop_next = 1'b0;

tb/test_axis_switch_4x4.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import os
2828

2929
import axis_ep
30-
import math
3130

3231
module = 'axis_switch'
3332
testbench = 'test_%s_4x4' % module
@@ -54,7 +53,7 @@ def bench():
5453
KEEP_WIDTH = (DATA_WIDTH/8)
5554
ID_ENABLE = 1
5655
ID_WIDTH = 8
57-
DEST_WIDTH = math.ceil(math.log(M_COUNT+1, 2))
56+
DEST_WIDTH = (M_COUNT+1).bit_length()
5857
USER_ENABLE = 1
5958
USER_WIDTH = 1
6059
M_BASE = [0, 1, 2, 3]

tb/test_axis_switch_4x4.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ parameter ID_WIDTH = 8;
4242
parameter DEST_WIDTH = $clog2(M_COUNT+1);
4343
parameter USER_ENABLE = 1;
4444
parameter USER_WIDTH = 1;
45-
parameter M_BASE = {32'd3, 32'd2, 32'd1, 32'd0};
46-
parameter M_TOP = {32'd3, 32'd2, 32'd1, 32'd0};
45+
parameter M_BASE = {3'd3, 3'd2, 3'd1, 3'd0};
46+
parameter M_TOP = {3'd3, 3'd2, 3'd1, 3'd0};
4747
parameter M_CONNECT = {M_COUNT{{S_COUNT{1'b1}}}};
4848
parameter S_REG_TYPE = 0;
4949
parameter M_REG_TYPE = 2;

tb/test_axis_switch_4x4_64.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import os
2828

2929
import axis_ep
30-
import math
3130

3231
module = 'axis_switch'
3332
testbench = 'test_%s_4x4_64' % module
@@ -54,7 +53,7 @@ def bench():
5453
KEEP_WIDTH = (DATA_WIDTH/8)
5554
ID_ENABLE = 1
5655
ID_WIDTH = 8
57-
DEST_WIDTH = math.ceil(math.log(M_COUNT+1, 2))
56+
DEST_WIDTH = (M_COUNT+1).bit_length()
5857
USER_ENABLE = 1
5958
USER_WIDTH = 1
6059
M_BASE = [0, 1, 2, 3]

tb/test_axis_switch_4x4_64.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ parameter ID_WIDTH = 8;
4242
parameter DEST_WIDTH = $clog2(M_COUNT+1);
4343
parameter USER_ENABLE = 1;
4444
parameter USER_WIDTH = 1;
45-
parameter M_BASE = {32'd3, 32'd2, 32'd1, 32'd0};
46-
parameter M_TOP = {32'd3, 32'd2, 32'd1, 32'd0};
45+
parameter M_BASE = {3'd3, 3'd2, 3'd1, 3'd0};
46+
parameter M_TOP = {3'd3, 3'd2, 3'd1, 3'd0};
4747
parameter M_CONNECT = {M_COUNT{{S_COUNT{1'b1}}}};
4848
parameter S_REG_TYPE = 0;
4949
parameter M_REG_TYPE = 2;

0 commit comments

Comments
 (0)