aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-06-06 08:35:50 +0200
committerTristan Gingold <tgingold@free.fr>2022-06-06 08:35:50 +0200
commit825099cdda3cbfbe5210570d6c2f0bb6abb360e2 (patch)
tree3bd3c9d6a1cfc0c63df48d48fa44ddeb54fa129d /src
parent26d9756273a66c4bd359b89db4829edcdb30e522 (diff)
downloadghdl-825099cdda3cbfbe5210570d6c2f0bb6abb360e2.tar.gz
ghdl-825099cdda3cbfbe5210570d6c2f0bb6abb360e2.tar.bz2
ghdl-825099cdda3cbfbe5210570d6c2f0bb6abb360e2.zip
synth-vhdl_stmts: handle alias in assignment expression
Diffstat (limited to 'src')
-rw-r--r--src/synth/elab-vhdl_values.adb19
-rw-r--r--src/synth/elab-vhdl_values.ads4
-rw-r--r--src/synth/synth-vhdl_stmts.adb3
3 files changed, 24 insertions, 2 deletions
diff --git a/src/synth/elab-vhdl_values.adb b/src/synth/elab-vhdl_values.adb
index 35dd113a7..c5485c400 100644
--- a/src/synth/elab-vhdl_values.adb
+++ b/src/synth/elab-vhdl_values.adb
@@ -69,6 +69,25 @@ package body Elab.Vhdl_Values is
return (V.Typ, Strip_Alias_Const (V.Val));
end Strip_Alias_Const;
+ function Get_Memory (V : Value_Acc) return Memory_Ptr is
+ begin
+ case V.Kind is
+ when Value_Const =>
+ return Get_Memory (V.C_Val);
+ when Value_Alias =>
+ return Get_Memory (V.A_Obj) + V.A_Off.Mem_Off;
+ when Value_Memory =>
+ return V.Mem;
+ when others =>
+ raise Internal_Error;
+ end case;
+ end Get_Memory;
+
+ function Get_Memory (V : Valtyp) return Memory_Ptr is
+ begin
+ return Get_Memory (V.Val);
+ end Get_Memory;
+
function Is_Equal (L, R : Valtyp) return Boolean is
begin
return Is_Equal (Get_Memtyp (L), Get_Memtyp (R));
diff --git a/src/synth/elab-vhdl_values.ads b/src/synth/elab-vhdl_values.ads
index 8e4887c18..b1aad9ce1 100644
--- a/src/synth/elab-vhdl_values.ads
+++ b/src/synth/elab-vhdl_values.ads
@@ -167,6 +167,10 @@ package Elab.Vhdl_Values is
-- is not correct anymore.
function Strip_Alias_Const (V : Valtyp) return Valtyp;
+ -- Return the memory of a Value_Memory value, but also handle const and
+ -- aliases.
+ function Get_Memory (V : Valtyp) return Memory_Ptr;
+
-- Return the memtyp of V; also strip const and aliases.
function Get_Memtyp (V : Valtyp) return Memtyp;
diff --git a/src/synth/synth-vhdl_stmts.adb b/src/synth/synth-vhdl_stmts.adb
index f226e7b59..7d72d832d 100644
--- a/src/synth/synth-vhdl_stmts.adb
+++ b/src/synth/synth-vhdl_stmts.adb
@@ -497,8 +497,7 @@ package body Synth.Vhdl_Stmts is
Error_Msg_Synth
(+Loc, "cannot assign a net to a static value");
else
- Strip_Const (V);
- Copy_Memory (Targ.Val.Mem + Off.Mem_Off, V.Val.Mem, V.Typ.Sz);
+ Copy_Memory (Targ.Val.Mem + Off.Mem_Off, Get_Memory (V), V.Typ.Sz);
end if;
end if;
end Synth_Assignment_Simple;