Skip to content

Commit

Permalink
hw: Add missing cast in ambiguous default expression (#147)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
phsauter and paulsc96 authored Oct 2, 2024
1 parent 84062e4 commit 74174cf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hw/cheshire_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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

Expand Down

0 comments on commit 74174cf

Please sign in to comment.