diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-05-27 09:54:02 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-05-27 09:54:02 +0200 |
commit | 09c757c3bcd7538582fa80a96b093c5a74e7ddaa (patch) | |
tree | ddf601f6799ed964c6a1441cc0162e594fea46b1 | |
parent | e8c9722ebc2b610d6bd6f70fc88e04ea6ec4041c (diff) | |
download | ghdl-09c757c3bcd7538582fa80a96b093c5a74e7ddaa.tar.gz ghdl-09c757c3bcd7538582fa80a96b093c5a74e7ddaa.tar.bz2 ghdl-09c757c3bcd7538582fa80a96b093c5a74e7ddaa.zip |
elab-vhdl_objtypes: add Create_Memory_U32 (for states)
-rw-r--r-- | src/synth/elab-vhdl_objtypes.adb | 19 | ||||
-rw-r--r-- | src/synth/elab-vhdl_objtypes.ads | 3 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/synth/elab-vhdl_objtypes.adb b/src/synth/elab-vhdl_objtypes.adb index 782f4dfa6..d1d263948 100644 --- a/src/synth/elab-vhdl_objtypes.adb +++ b/src/synth/elab-vhdl_objtypes.adb @@ -688,17 +688,21 @@ package body Elab.Vhdl_Objtypes is end case; end Write_Discrete; - function Alloc_Memory (Vtype : Type_Acc) return Memory_Ptr + function Alloc_Memory (Sz : Size_Type; Align2 : Natural) return Memory_Ptr is function To_Memory_Ptr is new Ada.Unchecked_Conversion (System.Address, Memory_Ptr); M : System.Address; begin - Areapools.Allocate (Current_Pool.all, M, - Vtype.Sz, Size_Type (2 ** Natural (Vtype.Al))); + Areapools.Allocate (Current_Pool.all, M, Sz, Size_Type (2 ** Align2)); return To_Memory_Ptr (M); end Alloc_Memory; + function Alloc_Memory (Vtype : Type_Acc) return Memory_Ptr is + begin + return Alloc_Memory (Vtype.Sz, Natural (Vtype.Al)); + end Alloc_Memory; + function Create_Memory (Vtype : Type_Acc) return Memtyp is begin return (Vtype, Alloc_Memory (Vtype)); @@ -756,6 +760,15 @@ package body Elab.Vhdl_Objtypes is return (Vtype, Res); end Create_Memory_Discrete; + function Create_Memory_U32 (Val : Uns32) return Memtyp + is + Res : Memory_Ptr; + begin + Res := Alloc_Memory (4, 2); + Write_U32 (Res, Ghdl_U32 (Val)); + return (null, Res); + end Create_Memory_U32; + function Is_Equal (L, R : Memtyp) return Boolean is begin if L = R then diff --git a/src/synth/elab-vhdl_objtypes.ads b/src/synth/elab-vhdl_objtypes.ads index 850f268b4..c8797e069 100644 --- a/src/synth/elab-vhdl_objtypes.ads +++ b/src/synth/elab-vhdl_objtypes.ads @@ -285,6 +285,9 @@ package Elab.Vhdl_Objtypes is function Create_Memory_Discrete (Val : Int64; Vtype : Type_Acc) return Memtyp; + -- For states. + function Create_Memory_U32 (Val : Uns32) return Memtyp; + function Alloc_Memory (Vtype : Type_Acc) return Memory_Ptr; function Create_Memory (Vtype : Type_Acc) return Memtyp; |