diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-10-27 21:45:03 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-10-27 21:45:03 +0100 |
commit | 152541125dedcc10d1e82cbba4f6e8492a2c4d0d (patch) | |
tree | add0348d53c241ea1c3cb6a6b23dd5ff098926c2 | |
parent | 720e7e5eb31d978ccddcd35ad0267eafef17f383 (diff) | |
download | ghdl-152541125dedcc10d1e82cbba4f6e8492a2c4d0d.tar.gz ghdl-152541125dedcc10d1e82cbba4f6e8492a2c4d0d.tar.bz2 ghdl-152541125dedcc10d1e82cbba4f6e8492a2c4d0d.zip |
netlists-expand: truncate address if needed.
-rw-r--r-- | src/synth/netlists-expands.adb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/synth/netlists-expands.adb b/src/synth/netlists-expands.adb index 8689f1f59..ebc51670d 100644 --- a/src/synth/netlists-expands.adb +++ b/src/synth/netlists-expands.adb @@ -18,6 +18,8 @@ -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. +with Mutils; use Mutils; + with Netlists.Gates; use Netlists.Gates; with Netlists.Utils; use Netlists.Utils; with Netlists.Butils; use Netlists.Butils; @@ -172,6 +174,8 @@ package body Netlists.Expands is -- 2. compute number of cells. Nbr_Els : constant Natural := Count_Nbr_Elements (Addr_Net); + Addr_Len : Uns32; + Els : Case_Element_Array_Acc; Idx : Positive; Off : Uns32; @@ -189,6 +193,12 @@ package body Netlists.Expands is -- 3. build mux tree Extract_Address (Ctxt, Addr_Net, Ndims, Addr); + Addr_Len := Uns32 (Clog2 (Uns64 (Nbr_Els))); + if Get_Width (Addr) > Addr_Len then + -- Truncate the address. This is requied so that synth_case doesn't + -- use default value. + Addr := Build_Trunc (Ctxt, Id_Utrunc, Addr, Addr_Len); + end if; Def := No_Net; Synth_Case (Ctxt, Addr, Els.all, Def, Res, Loc); |