Skip to content

Commit e50d810

Browse files
committed
sail_sv_backend: use packed array
In SystemVerilog, unpacked arrays are typically in the form of `[0:LEN-1]` instead of `[LEN-1:0]` (which is the convention for packed arrays). In fact, commonly people just use `[LEN]` and this is a shorthand for `[0:LEN-1]`. Currently sail_sv_backend always use `[LEN-1:0]` even for unpacked arrays; this causes the whole array to be flipped even the user passed in an array declared with `[LEN]`.
1 parent 0fdd5d3 commit e50d810

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sail_sv_backend/jib_sv.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ module Make (Config : CONFIG) = struct
208208
else ksprintf simple_type "logic [%d:0]" (width - 1)
209209
| CT_ref ctyp -> ksprintf simple_type "sail_reg_%s" (Util.zencode_string (string_of_ctyp ctyp))
210210
| CT_fvector (len, ctyp) ->
211-
let outer_index = sprintf "[%d:0]" (len - 1) in
211+
let outer_index = sprintf "[%d]" len in
212212
begin
213213
match sv_ctyp ~two_state ctyp with
214214
| ty, Some inner_index -> (ty, Some (inner_index ^ outer_index))

0 commit comments

Comments
 (0)