Skip to content

Commit

Permalink
ad_mux: another fix cases where channel number is not power of mux size
Browse files Browse the repository at this point in the history
  • Loading branch information
ronagyl committed Nov 27, 2020
1 parent 0badfdf commit 5df2961
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/common/ad_mux.v
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 5df2961

Please sign in to comment.