Hazard3/hdl/arith/hazard3_priority_encode.v

42 lines
964 B
Coq
Raw Normal View History

/*****************************************************************************\
2022-06-09 07:12:01 +08:00
| Copyright (C) 2021-2022 Luke Wren |
| SPDX-License-Identifier: Apache-2.0 |
\*****************************************************************************/
2021-05-21 09:34:16 +08:00
// req: bitmap
// gnt: index of least set bit (HIGHEST_WINS=0) or most set bit (HIGHEST_WINS=1)
2021-05-21 09:34:16 +08:00
`default_nettype none
2021-05-21 10:46:29 +08:00
module hazard3_priority_encode #(
parameter W_REQ = 16,
parameter HIGHEST_WINS = 0,
parameter W_GNT = $clog2(W_REQ) // do not modify
2021-05-21 09:34:16 +08:00
) (
input wire [W_REQ-1:0] req,
output wire [W_GNT-1:0] gnt
);
wire [W_REQ-1:0] gnt_onehot;
2021-05-21 09:34:16 +08:00
hazard3_onehot_priority #(
.W_REQ (W_REQ),
.HIGHEST_WINS (HIGHEST_WINS)
) priority_u (
.req (req),
.gnt (gnt_onehot)
);
2021-05-21 09:34:16 +08:00
hazard3_onehot_encode #(
.W_REQ (W_REQ)
) encode_u (
.req (gnt_onehot),
.gnt (gnt)
);
2021-05-21 09:34:16 +08:00
2021-05-21 10:46:29 +08:00
endmodule
`ifndef YOSYS
`default_nettype wire
`endif