42 parameter FIXED_PRIORITY =
0,
// 0 - round-robin, 1 - fixed channel priority (0 - highest) 43 parameter BITS =
2 // number of bits to encode channel number (1 << BITS) - number of inputs 46 input srst,
// sync. reset - needed to reset current channel 47 input [(
1 <<
BITS) -
1:
0]
rq,
// request vector 48 input en,
// enable to grant highest priority request (should be reset by grant) 49 output reg grant,
// changed to 1-cycle long (was: stays on until reset by !en) 51 output reg [(
1 <<
BITS) -
1:
0]
grant_chn);
// 1-hot grant output per-channel, single-clock pulse 60 // assign grant = grant_r; 64 always @ (
posedge clk)
begin 69 else if (
valid)
grant_r <=
1;
// grant will stay on until reset by !en 77 // round-robin priority encode 79 input [(
1 <<
BITS) -
1:
0]
rq;
// request vector 80 input [
BITS-
1:
0]
cur_chn;
// current (last served) channel - lowest priority 81 reg valid;
// at least one request 82 reg [
BITS -
1:
0]
chn,
sample_chn;
87 for (
i =
0;
i < (
1 <<
BITS);
i =
i+
1)
begin 88 sample_chn = (
cur_chn -
i) % (
1 <<
BITS);
89 if (
rq[
sample_chn])
begin 100 input [
BITS -
1:
0]
sel;
103 for (
i=
0;
i < (
1 <<
BITS);
i =
i +
1)
begin
10760next_chnwire[BITS-1:0]
reg [1 << BITS -1:0] 10757grant_chn
[BITS:0] func_selrrrqcur_chn
[(1<<BITS)-1:0] func_demuxensel
10758last_chnreg[BITS-1:0]