From ad86295fcf22d04fdae0e9e124bd94539fb8c992 Mon Sep 17 00:00:00 2001 From: Teo Ene Date: Thu, 15 Apr 2021 13:37:12 -0500 Subject: [PATCH] Temporary change to mmu/priority_encoder.sv Necessary to get synth working Original HDL is still there, just commented out --- wally-pipelined/src/mmu/priority_encoder.sv | 52 +++++++++++++++------ 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/wally-pipelined/src/mmu/priority_encoder.sv b/wally-pipelined/src/mmu/priority_encoder.sv index 6bb22826..12fe1659 100644 --- a/wally-pipelined/src/mmu/priority_encoder.sv +++ b/wally-pipelined/src/mmu/priority_encoder.sv @@ -27,24 +27,48 @@ `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 // 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) ( - input [(2**BINARY_BITS)-1:0] one_hot, - output [BINARY_BITS-1:0] binary + input logic [7:0] one_hot, + output logic [2: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 + always_comb + case (one_hot) + 8'h1: binary=3'h0; + 8'h2: binary=3'h1; + 8'h4: binary=3'h2; + 8'h8: binary=3'h3; + 8'h10: binary=3'h4; + 8'h20: binary=3'h5; + 8'h40: binary=3'h6; + 8'h80: binary=3'h7; + default: binary=3'h0; //should never happen + endcase endmodule