From 74174cf145d71cc40663e9e665a5b9330d392403 Mon Sep 17 00:00:00 2001 From: Philippe Sauter Date: Wed, 2 Oct 2024 19:02:38 +0200 Subject: [PATCH] hw: Add missing cast in ambiguous default expression (#147) * hw: fix slang casting error Slang says: error: assignment pattern target type cannot be deduced in this context According to the spec chapter 6.24.1 the parenthesis around the expression to be casted are necessary. This fixes the slang error. * hw: fix ambiguous inferred type in default Its not pretty but it works. Without the explicit cast or type slang is unable to infer the type of the value in the default. By just adding an explicit cast parenthesis like: '('{0, 0}) Vivado gives a Syntax error. So adding a localparam seems to be the simplest fix. * hw: fix verible linter warning * Improve naming, add clarifying comment on default case --------- Co-authored-by: Paul Scheffler --- hw/cheshire_pkg.sv | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/cheshire_pkg.sv b/hw/cheshire_pkg.sv index a0e8fe50b..e70f5a440 100644 --- a/hw/cheshire_pkg.sv +++ b/hw/cheshire_pkg.sv @@ -463,6 +463,7 @@ package cheshire_pkg; // Choose static colocation of IDs based on how heavily used and/or critical they are function automatic cva6_id_map_t gen_cva6_id_map(cheshire_cfg_t cfg); + localparam int unsigned DefaultMapEntry[2] = '{0, 0}; case (cfg.AxiMstIdWidth) // Provide exclusive ID to I-cache to prevent fetch blocking 1: return '{'{Cva6IdBypMmu, 0}, '{Cva6IdBypLoad, 0}, '{Cva6IdBypAccel, 0}, '{Cva6IdBypStore, 0}, @@ -473,8 +474,9 @@ package cheshire_pkg; // Compress output ID space without any serialization 3: return '{'{Cva6IdBypMmu, 0}, '{Cva6IdBypLoad, 1}, '{Cva6IdBypAccel, 6}, '{Cva6IdBypStore, 2}, '{Cva6IdBypAmo, 3}, '{Cva6IdICache, 4}, '{Cva6IdDCache, 5}}; - // With 4b of ID or more, no remapping is necessary - default: return '{default: '{0, 0}}; + // With 4b of ID or more, no remapping is necessary; return redundant 0 -> 0 ID remaps. + // This leaves ID mapping unaltered only if `MstIdBaseOffset` in `axi_id_serialize` is 0. + default: return '{default: DefaultMapEntry}; endcase endfunction