mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
d5edb1ca88
- don't do a combinatorial loopback on wait in a primitive cell, just bad practice... - changed priority to give readback priority over read, safer?
34 lines
640 B
Verilog
34 lines
640 B
Verilog
/* Simple combinatorial priority arbiter
|
|
* bit[0] has highest priority
|
|
*
|
|
*/
|
|
|
|
module oh_arbiter_static(/*AUTOARG*/
|
|
// Outputs
|
|
grants,
|
|
// Inputs
|
|
requests
|
|
);
|
|
|
|
parameter N=99;
|
|
|
|
input [N-1:0] requests; //request vector
|
|
output [N-1:0] grants; //grant (one hot)
|
|
|
|
genvar j;
|
|
wire [N-1:0] waitmask;
|
|
|
|
assign waitmask[0] = 1'b0;
|
|
generate for (j=N-1; j>=1; j=j-1)
|
|
begin : gen_arbiter
|
|
assign waitmask[j] = |requests[j-1:0];
|
|
end
|
|
endgenerate
|
|
|
|
//grant circuit
|
|
assign grants[N-1:0] = requests[N-1:0] & ~waitmask[N-1:0];
|
|
|
|
endmodule // oh_arbiter_priority
|
|
|
|
|