diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-11-05 19:04:34 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-11-05 19:04:34 +0100 |
commit | de83417dd4417ba6971ac29506b1bdd48f49df21 (patch) | |
tree | 934ce3fb4429b40a27a3d80b6d1c4801fa6fd5d6 /src/synth/netlists-memories.adb | |
parent | 88ed8221440822debc64a52dc33e7b51222a6293 (diff) | |
download | ghdl-de83417dd4417ba6971ac29506b1bdd48f49df21.tar.gz ghdl-de83417dd4417ba6971ac29506b1bdd48f49df21.tar.bz2 ghdl-de83417dd4417ba6971ac29506b1bdd48f49df21.zip |
netlists-memories: truncate wide addresses.
Diffstat (limited to 'src/synth/netlists-memories.adb')
-rw-r--r-- | src/synth/netlists-memories.adb | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/synth/netlists-memories.adb b/src/synth/netlists-memories.adb index 96166a3e7..07c063cbf 100644 --- a/src/synth/netlists-memories.adb +++ b/src/synth/netlists-memories.adb @@ -338,27 +338,27 @@ package body Netlists.Memories is Step : constant Uns32 := Get_Param_Uns32 (Inst, 0); Sub_Addr : constant Net := Get_Input_Net (Inst, 0); Addr_W : constant Width := Get_Width (Sub_Addr); - Max : Uns32; + Max : constant Uns32 := Get_Param_Uns32 (Inst, 1); + Max_W : constant Width := Clog2 (Max + 1); + Sub_Addr1 : Net; begin -- Check max - Max := Get_Param_Uns32 (Inst, 1); pragma Assert (Max /= 0); if (Max + 1) * Step /= Last_Size then raise Internal_Error; end if; -- Check addr width. - if Addr_W > 31 then - raise Internal_Error; - end if; if Addr_W = 0 then raise Internal_Error; end if; - if 2**Natural (Addr_W - 1) > Max then + if Addr_W > Max_W then -- Need to truncate. - raise Internal_Error; + Sub_Addr1 := Build_Trunc (Ctxt, Id_Utrunc, Sub_Addr, Max_W); + else + Sub_Addr1 := Sub_Addr; end if; - Indexes (I).Addr := Sub_Addr; + Indexes (I).Addr := Sub_Addr1; if I = Indexes'Last then if Step /= Val_Wd then @@ -374,13 +374,11 @@ package body Netlists.Memories is use Netlists.Concats; Concat : Concat_Type; Inp : Input; - Idx : Net; begin for I in Indexes'Range loop Inp := Get_Input (Indexes (I).Inst, 0); - Idx := Get_Driver (Inp); Disconnect (Inp); - Append (Concat, Idx); + Append (Concat, Indexes (I).Addr); end loop; Build (Ctxt, Concat, Low_Addr); |