ad_mux: another fix cases where channel number is not power of mux size

main
Laszlo Nagy 2020-05-31 18:56:28 +01:00 committed by Laszlo Nagy
parent 0badfdfa31
commit 5df2961624
1 changed files with 5 additions and 1 deletions

View File

@ -54,6 +54,8 @@ module ad_mux #(
output [CH_W-1:0] data_out
);
`define MIN(A,B) (A<B?A:B)
localparam MUX_SZ = CH_CNT < REQ_MUX_SZ ? CH_CNT : REQ_MUX_SZ;
localparam CLOG2_CH_CNT = $clog2(CH_CNT);
localparam CLOG2_MUX_SZ = $clog2(MUX_SZ);
@ -95,7 +97,9 @@ generate
end
end
for (j = 0; j < MUX_SZ**(NUM_STAGES-i); j = j + MUX_SZ) begin: g_mux
localparam MAX_RANGE_PER_STAGE=MUX_SZ**(NUM_STAGES-i);
for (j = 0; j < `MIN(MAX_RANGE_PER_STAGE,CH_CNT); j = j + MUX_SZ) begin: g_mux
ad_mux_core #(
.CH_W (CH_W),