mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Temporary change to mmu/priority_encoder.sv
Necessary to get synth working Original HDL is still there, just commented out
This commit is contained in:
parent
636e2de9df
commit
ad86295fcf
@ -27,24 +27,48 @@
|
|||||||
|
|
||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
|
||||||
|
// Teo Ene 04/15:
|
||||||
|
// Temporarily removed paramterized priority encoder for non-parameterized one
|
||||||
|
// To get synthesis working quickly
|
||||||
|
|
||||||
// *** We should look for a better parameterized priority encoder. This has a
|
// *** We should look for a better parameterized priority encoder. This has a
|
||||||
// bad code smell and might not synthesize
|
// bad code smell and might not synthesize
|
||||||
|
//module priority_encoder #(parameter BINARY_BITS = 3) (
|
||||||
|
// input [(2**BINARY_BITS)-1:0] one_hot,
|
||||||
|
// output [BINARY_BITS-1:0] binary
|
||||||
|
//);
|
||||||
|
//
|
||||||
|
// localparam ONE_HOT_BITS = 2**BINARY_BITS;
|
||||||
|
//
|
||||||
|
// genvar i, j;
|
||||||
|
// generate
|
||||||
|
// for (i = 0; i < ONE_HOT_BITS; i++) begin
|
||||||
|
// for (j = 0; j < BINARY_BITS; j++) begin
|
||||||
|
// if (i[j]) begin
|
||||||
|
// assign binary[j] = one_hot[i];
|
||||||
|
// end
|
||||||
|
// end
|
||||||
|
// end
|
||||||
|
// endgenerate
|
||||||
|
//
|
||||||
|
//endmodule
|
||||||
|
|
||||||
module priority_encoder #(parameter BINARY_BITS = 3) (
|
module priority_encoder #(parameter BINARY_BITS = 3) (
|
||||||
input [(2**BINARY_BITS)-1:0] one_hot,
|
input logic [7:0] one_hot,
|
||||||
output [BINARY_BITS-1:0] binary
|
output logic [2:0] binary
|
||||||
);
|
);
|
||||||
|
|
||||||
localparam ONE_HOT_BITS = 2**BINARY_BITS;
|
always_comb
|
||||||
|
case (one_hot)
|
||||||
genvar i, j;
|
8'h1: binary=3'h0;
|
||||||
generate
|
8'h2: binary=3'h1;
|
||||||
for (i = 0; i < ONE_HOT_BITS; i++) begin
|
8'h4: binary=3'h2;
|
||||||
for (j = 0; j < BINARY_BITS; j++) begin
|
8'h8: binary=3'h3;
|
||||||
if (i[j]) begin
|
8'h10: binary=3'h4;
|
||||||
assign binary[j] = one_hot[i];
|
8'h20: binary=3'h5;
|
||||||
end
|
8'h40: binary=3'h6;
|
||||||
end
|
8'h80: binary=3'h7;
|
||||||
end
|
default: binary=3'h0; //should never happen
|
||||||
endgenerate
|
endcase
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
Loading…
Reference in New Issue
Block a user