aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-09-07 04:56:58 +0200
committerTristan Gingold <tgingold@free.fr>2022-09-07 04:56:58 +0200
commitd646114db387b69e2fe92a1c68c2c27c35f7dc5f (patch)
treeeffc33716fc1fba6af4f7fc05689a67bc1a58a61 /src
parent68a7010349341dfaa8aa7b8b27701bf639ea0857 (diff)
downloadghdl-d646114db387b69e2fe92a1c68c2c27c35f7dc5f.tar.gz
ghdl-d646114db387b69e2fe92a1c68c2c27c35f7dc5f.tar.bz2
ghdl-d646114db387b69e2fe92a1c68c2c27c35f7dc5f.zip
elab-vhdl_values: factorize code
Diffstat (limited to 'src')
-rw-r--r--src/simul/simul-vhdl_simul.adb4
-rw-r--r--src/synth/elab-vhdl_decls.adb2
-rw-r--r--src/synth/elab-vhdl_values.adb25
-rw-r--r--src/synth/elab-vhdl_values.ads8
-rw-r--r--src/synth/synth-vhdl_expr.adb2
-rw-r--r--src/synth/synth-vhdl_stmts.adb4
6 files changed, 16 insertions, 29 deletions
diff --git a/src/simul/simul-vhdl_simul.adb b/src/simul/simul-vhdl_simul.adb
index 856f18a0b..cd34a5ca4 100644
--- a/src/simul/simul-vhdl_simul.adb
+++ b/src/simul/simul-vhdl_simul.adb
@@ -1990,7 +1990,7 @@ package body Simul.Vhdl_Simul is
end loop;
-- Call resolution function
- Res := Exec_Resolution_Call (R.Inst, R.Func, Create_Value_Memory (Arr));
+ Res := Exec_Resolution_Call (R.Inst, R.Func, Create_Value_Memtyp (Arr));
-- Set driving value.
Exec_Write_Signal (R.Sig, (Res.Typ, Res.Val.Mem),
@@ -2338,7 +2338,7 @@ package body Simul.Vhdl_Simul is
Res : Valtyp;
begin
Res := Exec_Resolution_Call (Inst, Get_Implementation (Func),
- Create_Value_Memory (Val));
+ Create_Value_Memtyp (Val));
Res := Synth.Vhdl_Expr.Synth_Subtype_Conversion
(Inst, Res, Res_Typ, False, Func);
if Res = No_Valtyp then
diff --git a/src/synth/elab-vhdl_decls.adb b/src/synth/elab-vhdl_decls.adb
index 97836929c..4c09a656c 100644
--- a/src/synth/elab-vhdl_decls.adb
+++ b/src/synth/elab-vhdl_decls.adb
@@ -416,7 +416,7 @@ package body Elab.Vhdl_Decls is
pragma Assert (Areapools.Is_Empty (Expr_Pool));
Current_Pool := Instance_Pool;
- Val := Create_Value_Memory (Create_Memory_U32 (0));
+ Val := Create_Value_Memtyp (Create_Memory_U32 (0));
Current_Pool := Expr_Pool'Access;
Create_Object (Syn_Inst, Decl, Val);
end;
diff --git a/src/synth/elab-vhdl_values.adb b/src/synth/elab-vhdl_values.adb
index 25ce08b77..7adf69030 100644
--- a/src/synth/elab-vhdl_values.adb
+++ b/src/synth/elab-vhdl_values.adb
@@ -95,17 +95,6 @@ package body Elab.Vhdl_Values is
return Is_Equal (Get_Memtyp (L), Get_Memtyp (R));
end Is_Equal;
- function Create_Value_Memtyp (Mt : Memtyp) return Valtyp
- is
- subtype Value_Type_Memory is Value_Type (Value_Memory);
- function Alloc is new Areapools.Alloc_On_Pool_Addr (Value_Type_Memory);
- Res : Value_Acc;
- begin
- Res := To_Value_Acc (Alloc (Current_Pool, (Kind => Value_Memory,
- Mem => Mt.Mem)));
- return (Mt.Typ, Res);
- end Create_Value_Memtyp;
-
function Create_Value_Wire (S : Uns32) return Value_Acc
is
subtype Value_Type_Wire is Value_Type (Value_Wire);
@@ -136,8 +125,8 @@ package body Elab.Vhdl_Values is
Init => Init)));
end Create_Value_Signal;
- function Create_Value_Memory_Pool (Mt : Memtyp; Pool : Areapool_Acc)
- return Valtyp
+ function Create_Value_Memory (Mt : Memtyp; Pool : Areapool_Acc)
+ return Valtyp
is
subtype Value_Type_Memory is Value_Type (Value_Memory);
function Alloc is new Areapools.Alloc_On_Pool_Addr (Value_Type_Memory);
@@ -146,12 +135,12 @@ package body Elab.Vhdl_Values is
V := To_Value_Acc (Alloc (Pool, Value_Type_Memory'(Kind => Value_Memory,
Mem => Mt.Mem)));
return (Mt.Typ, V);
- end Create_Value_Memory_Pool;
+ end Create_Value_Memory;
- function Create_Value_Memory (Mt : Memtyp) return Valtyp is
+ function Create_Value_Memtyp (Mt : Memtyp) return Valtyp is
begin
- return Create_Value_Memory_Pool (Mt, Current_Pool);
- end Create_Value_Memory;
+ return Create_Value_Memory (Mt, Current_Pool);
+ end Create_Value_Memtyp;
function Create_Value_Memory (Vtype : Type_Acc; Pool : Areapool_Acc)
return Valtyp
@@ -162,7 +151,7 @@ package body Elab.Vhdl_Values is
begin
Areapools.Allocate (Pool.all, M,
Vtype.Sz, Size_Type (2 ** Natural (Vtype.Al)));
- return Create_Value_Memory_Pool ((Vtype, To_Memory_Ptr (M)), Pool);
+ return Create_Value_Memory ((Vtype, To_Memory_Ptr (M)), Pool);
end Create_Value_Memory;
function Create_Value_File (File : File_Index) return Value_Acc
diff --git a/src/synth/elab-vhdl_values.ads b/src/synth/elab-vhdl_values.ads
index 5c56cb548..57ef8048b 100644
--- a/src/synth/elab-vhdl_values.ads
+++ b/src/synth/elab-vhdl_values.ads
@@ -133,8 +133,6 @@ package Elab.Vhdl_Values is
function Is_Equal (L, R : Valtyp) return Boolean;
- function Create_Value_Memtyp (Mt : Memtyp) return Valtyp;
-
-- Create a Value_Net.
function Create_Value_Net (S : Uns32) return Value_Acc;
@@ -147,9 +145,9 @@ package Elab.Vhdl_Values is
function Create_Value_Memory (Vtype : Type_Acc; Pool : Areapool_Acc)
return Valtyp;
- function Create_Value_Memory_Pool (Mt : Memtyp; Pool : Areapool_Acc)
- return Valtyp;
- function Create_Value_Memory (Mt : Memtyp) return Valtyp;
+ function Create_Value_Memory (Mt : Memtyp; Pool : Areapool_Acc)
+ return Valtyp;
+ function Create_Value_Memtyp (Mt : Memtyp) return Valtyp;
function Create_Value_Uns (Val : Uns64; Vtype : Type_Acc) return Valtyp;
function Create_Value_Int (Val : Int64; Vtype : Type_Acc) return Valtyp;
diff --git a/src/synth/synth-vhdl_expr.adb b/src/synth/synth-vhdl_expr.adb
index 58599b109..9f581a8ce 100644
--- a/src/synth/synth-vhdl_expr.adb
+++ b/src/synth/synth-vhdl_expr.adb
@@ -705,7 +705,7 @@ package body Synth.Vhdl_Expr is
begin
Val := Synth_Expression (Syn_Inst, Get_Prefix (Name));
Obj := Elab.Vhdl_Heap.Synth_Dereference (Read_Access (Val));
- return Create_Value_Memory (Obj);
+ return Create_Value_Memtyp (Obj);
end;
when others =>
Error_Kind ("synth_name", Name);
diff --git a/src/synth/synth-vhdl_stmts.adb b/src/synth/synth-vhdl_stmts.adb
index f2bf8db0d..5b958681d 100644
--- a/src/synth/synth-vhdl_stmts.adb
+++ b/src/synth/synth-vhdl_stmts.adb
@@ -255,7 +255,7 @@ package body Synth.Vhdl_Stmts is
if Dest_Off /= (0, 0) and then Dest_Dyn.Voff /= No_Net then
raise Internal_Error;
end if;
- Dest_Base := Create_Value_Memory
+ Dest_Base := Create_Value_Memtyp
(Elab.Vhdl_Heap.Synth_Dereference (Read_Access (Dest_Base)));
Dest_Typ := Dest_Base.Typ;
@@ -1841,7 +1841,7 @@ package body Synth.Vhdl_Stmts is
if Info.Obj.Val.Kind = Value_Memory then
-- But for memory value, do not copy the content, as it is
-- a reference.
- Obj := Create_Value_Memory_Pool
+ Obj := Create_Value_Memory
(Get_Memtyp (Info.Obj), Instance_Pool);
else
Obj := Unshare (Info.Obj, Instance_Pool);