diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-10-28 20:07:46 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-10-28 20:07:46 +0100 |
commit | fce8f04ce5aef77c597ea3f97f84ec5ffb08a3da (patch) | |
tree | 33d971a255b7bb533e5316fd4460cc70b01ed405 /src/synth/synth-expr.adb | |
parent | 13a28fa63e8dca2b31e09c2b393a6440b64d05b8 (diff) | |
download | ghdl-fce8f04ce5aef77c597ea3f97f84ec5ffb08a3da.tar.gz ghdl-fce8f04ce5aef77c597ea3f97f84ec5ffb08a3da.tar.bz2 ghdl-fce8f04ce5aef77c597ea3f97f84ec5ffb08a3da.zip |
synth: adjust computation of max for dyn_extract.
Diffstat (limited to 'src/synth/synth-expr.adb')
-rw-r--r-- | src/synth/synth-expr.adb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index d16dedffe..e58cfce74 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -964,7 +964,7 @@ package body Synth.Expr is Off := Index_To_Offset (Bnd, Idx_Val.Scal, Name) * W; else Voff := Dyn_Index_To_Offset (Bnd, Idx_Val, Name); - Voff := Build_Memidx (Get_Build (Syn_Inst), Voff, W, Bnd.Len, + Voff := Build_Memidx (Get_Build (Syn_Inst), Voff, W, Bnd.Len - 1, Width (Clog2 (Uns64 (W * Bnd.Len)))); Set_Location (Voff, Name); Off := 0; @@ -1260,7 +1260,11 @@ package body Synth.Expr is (Name, Pfx_Bnd, Get_Net (Left), Get_Net (Right), Inp, Step, Off, Wd); -- FIXME: convert range to offset. - Max := (Pfx_Bnd.Len - Off) / Step; + -- example: len=128 wd=8 step=8 => max=16 + -- len=8 wd=4 step=1 => max=4 + -- max so that max*step+wd <= len - off + -- max <= (len - off - wd) / step + Max := (Pfx_Bnd.Len - Off - Wd) / Step; Inp := Build_Memidx (Get_Build (Syn_Inst), Inp, Step * El_Wd, Max, |