diff options
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/netlists-expands.adb | 4 | ||||
-rw-r--r-- | src/synth/netlists-memories.adb | 6 | ||||
-rw-r--r-- | src/synth/synth-expr.adb | 8 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/synth/netlists-expands.adb b/src/synth/netlists-expands.adb index ebc51670d..3438ee132 100644 --- a/src/synth/netlists-expands.adb +++ b/src/synth/netlists-expands.adb @@ -52,7 +52,7 @@ package body Netlists.Expands is Max := Get_Param_Uns32 (Inst1, 1); pragma Assert (Max /= 0); - Res := Res * Natural (Max); + Res := Res * Natural (Max + 1); exit when Inst1 = Inst; end loop; @@ -99,7 +99,7 @@ package body Netlists.Expands is begin pragma Assert (Max /= 0); - for I in 0 .. Max - 1 loop + for I in 0 .. Max loop if Sub_Inst /= No_Instance then -- recurse. raise Internal_Error; diff --git a/src/synth/netlists-memories.adb b/src/synth/netlists-memories.adb index e56990c03..4904e0cec 100644 --- a/src/synth/netlists-memories.adb +++ b/src/synth/netlists-memories.adb @@ -342,10 +342,8 @@ package body Netlists.Memories is begin -- Check max Max := Get_Param_Uns32 (Inst, 1); - if Max = 0 then - Max := Last_Size / Step; - end if; - if Max * Step /= Last_Size then + pragma Assert (Max /= 0); + if (Max + 1) * Step /= Last_Size then raise Internal_Error; end if; 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, |