diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-04-13 18:15:39 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-04-13 18:15:39 +0200 |
commit | 347b9930c5a65d8cf96a6f7f5d92c37bfee7c21a (patch) | |
tree | 147aa92eaa0867eae11891cec458b6bdf4f3e264 /src/synth/synth-static_oper.adb | |
parent | 547d31b8d955325cbad13e47211d4e4049bf03d0 (diff) | |
download | ghdl-347b9930c5a65d8cf96a6f7f5d92c37bfee7c21a.tar.gz ghdl-347b9930c5a65d8cf96a6f7f5d92c37bfee7c21a.tar.bz2 ghdl-347b9930c5a65d8cf96a6f7f5d92c37bfee7c21a.zip |
synth: move memtyp handling to synth.objtypes.
Diffstat (limited to 'src/synth/synth-static_oper.adb')
-rw-r--r-- | src/synth/synth-static_oper.adb | 229 |
1 files changed, 113 insertions, 116 deletions
diff --git a/src/synth/synth-static_oper.adb b/src/synth/synth-static_oper.adb index 824e5c803..e214b1c09 100644 --- a/src/synth/synth-static_oper.adb +++ b/src/synth/synth-static_oper.adb @@ -21,7 +21,7 @@ with Types; use Types; with Types_Utils; use Types_Utils; -with Grt.Types; +with Grt.Types; use Grt.Types; with Vhdl.Utils; use Vhdl.Utils; with Vhdl.Ieee.Std_Logic_1164; use Vhdl.Ieee.Std_Logic_1164; @@ -237,23 +237,23 @@ package body Synth.Static_Oper is function Synth_Vector_Dyadic (Left, Right : Memtyp; Op : Table_2d; - Loc : Syn_Src) return Valtyp + Loc : Syn_Src) return Memtyp is - Res : Valtyp; + Res : Memtyp; begin if Left.Typ.W /= Right.Typ.W then Error_Msg_Synth (+Loc, "length of operands mismatch"); - return No_Valtyp; + return Null_Memtyp; end if; - Res := Create_Value_Memory (Create_Res_Bound (Left.Typ)); + Res := Create_Memory (Create_Res_Bound (Left.Typ)); for I in 1 .. Uns32 (Vec_Length (Res.Typ)) loop declare Ls : constant Std_Ulogic := Read_Std_Logic (Left.Mem, I - 1); Rs : constant Std_Ulogic := Read_Std_Logic (Right.Mem, I - 1); V : constant Std_Ulogic := Op (Ls, Rs); begin - Write_Std_Logic (Res.Val.Mem, I - 1, V); + Write_Std_Logic (Res.Mem, I - 1, V); end; end loop; @@ -267,21 +267,21 @@ package body Synth.Static_Oper is end loop; end To_Std_Logic_Vector; - function To_Valtyp (Vec : Std_Logic_Vector; El_Typ : Type_Acc) return Valtyp + function To_Memtyp (Vec : Std_Logic_Vector; El_Typ : Type_Acc) return Memtyp is pragma Assert (Vec'First = 1); Res_Typ : Type_Acc; - Res : Valtyp; + Res : Memtyp; begin Res_Typ := Create_Vec_Type_By_Length (Uns32 (Vec'Last), El_Typ); - Res := Create_Value_Memory (Res_Typ); + Res := Create_Memory (Res_Typ); for I in 1 .. Vec'Last loop - Write_Std_Logic (Res.Val.Mem, Uns32 (I - 1), Vec (I)); + Write_Std_Logic (Res.Mem, Uns32 (I - 1), Vec (I)); end loop; return Res; - end To_Valtyp; + end To_Memtyp; - function Synth_Add_Uns_Uns (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Add_Uns_Uns (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); L_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (L.Typ))); @@ -292,11 +292,11 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Add_Uns_Uns (L_Arr, R_Arr); begin - return To_Valtyp (Res_Arr, L.Typ.Vec_El); + return To_Memtyp (Res_Arr, L.Typ.Vec_El); end; end Synth_Add_Uns_Uns; - function Synth_Add_Sgn_Int (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Add_Sgn_Int (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); L_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (L.Typ))); @@ -306,11 +306,11 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Add_Sgn_Int (L_Arr, R_Val); begin - return To_Valtyp (Res_Arr, L.Typ.Vec_El); + return To_Memtyp (Res_Arr, L.Typ.Vec_El); end; end Synth_Add_Sgn_Int; - function Synth_Add_Uns_Nat (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Add_Uns_Nat (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); L_Arr : Std_Logic_Vector (1 .. Natural (L.Typ.W)); @@ -320,11 +320,11 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Add_Uns_Nat (L_Arr, R_Val); begin - return To_Valtyp (Res_Arr, L.Typ.Vec_El); + return To_Memtyp (Res_Arr, L.Typ.Vec_El); end; end Synth_Add_Uns_Nat; - function Synth_Sub_Uns_Uns (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Sub_Uns_Uns (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); L_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (L.Typ))); @@ -335,11 +335,11 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Sub_Uns_Uns (L_Arr, R_Arr); begin - return To_Valtyp (Res_Arr, L.Typ.Vec_El); + return To_Memtyp (Res_Arr, L.Typ.Vec_El); end; end Synth_Sub_Uns_Uns; - function Synth_Sub_Uns_Nat (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Sub_Uns_Nat (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); L_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (L.Typ))); @@ -349,11 +349,11 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Sub_Uns_Nat (L_Arr, R_Val); begin - return To_Valtyp (Res_Arr, L.Typ.Vec_El); + return To_Memtyp (Res_Arr, L.Typ.Vec_El); end; end Synth_Sub_Uns_Nat; - function Synth_Mul_Uns_Uns (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Mul_Uns_Uns (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); L_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (L.Typ))); @@ -364,11 +364,11 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Mul_Uns_Uns (L_Arr, R_Arr); begin - return To_Valtyp (Res_Arr, L.Typ.Vec_El); + return To_Memtyp (Res_Arr, L.Typ.Vec_El); end; end Synth_Mul_Uns_Uns; - function Synth_Mul_Nat_Uns (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Mul_Nat_Uns (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); R_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (R.Typ))); @@ -378,11 +378,11 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Mul_Nat_Uns (L_Val, R_Arr); begin - return To_Valtyp (Res_Arr, R.Typ.Vec_El); + return To_Memtyp (Res_Arr, R.Typ.Vec_El); end; end Synth_Mul_Nat_Uns; - function Synth_Mul_Uns_Nat (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Mul_Uns_Nat (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); L_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (L.Typ))); @@ -392,11 +392,11 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Mul_Uns_Nat (L_Arr, R_Val); begin - return To_Valtyp (Res_Arr, L.Typ.Vec_El); + return To_Memtyp (Res_Arr, L.Typ.Vec_El); end; end Synth_Mul_Uns_Nat; - function Synth_Mul_Sgn_Sgn (L, R : Memtyp; Loc : Syn_Src) return Valtyp + function Synth_Mul_Sgn_Sgn (L, R : Memtyp; Loc : Syn_Src) return Memtyp is pragma Unreferenced (Loc); L_Arr : Std_Logic_Vector (1 .. Natural (Vec_Length (L.Typ))); @@ -407,14 +407,14 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Mul_Sgn_Sgn (L_Arr, R_Arr); begin - return To_Valtyp (Res_Arr, L.Typ.Vec_El); + return To_Memtyp (Res_Arr, L.Typ.Vec_El); end; end Synth_Mul_Sgn_Sgn; function Synth_Shift (Val : Memtyp; Amt : Uns32; Right : Boolean; - Arith : Boolean) return Valtyp + Arith : Boolean) return Memtyp is Len : constant Uns32 := Uns32 (Vec_Length (Val.Typ)); Arr : Std_Logic_Vector (1 .. Natural (Len)); @@ -446,7 +446,7 @@ package body Synth.Static_Oper is end loop; end if; end if; - return To_Valtyp (Arr, Val.Typ.Vec_El); + return To_Memtyp (Arr, Val.Typ.Vec_El); end Synth_Shift; function Get_Static_Ulogic (Op : Memtyp) return Std_Ulogic is @@ -459,7 +459,7 @@ package body Synth.Static_Oper is Imp : Node; Left : Memtyp; Right : Memtyp; - Expr : Node) return Valtyp + Expr : Node) return Memtyp is Def : constant Iir_Predefined_Functions := Get_Implicit_Definition (Imp); @@ -468,143 +468,143 @@ package body Synth.Static_Oper is begin case Def is when Iir_Predefined_Error => - return No_Valtyp; + return Null_Memtyp; when Iir_Predefined_Boolean_Xor => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Boolean'Val (Read_Discrete (Left)) xor Boolean'Val (Read_Discrete (Right))), Res_Typ); when Iir_Predefined_Enum_Equality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Discrete (Left) = Read_Discrete (Right)), Boolean_Type); when Iir_Predefined_Enum_Inequality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Discrete (Left) /= Read_Discrete (Right)), Boolean_Type); when Iir_Predefined_Integer_Plus | Iir_Predefined_Physical_Plus => - return Create_Value_Discrete + return Create_Memory_Discrete (Read_Discrete (Left) + Read_Discrete (Right), Res_Typ); when Iir_Predefined_Integer_Minus | Iir_Predefined_Physical_Minus => - return Create_Value_Discrete + return Create_Memory_Discrete (Read_Discrete (Left) - Read_Discrete (Right), Res_Typ); when Iir_Predefined_Integer_Mul | Iir_Predefined_Physical_Integer_Mul | Iir_Predefined_Integer_Physical_Mul => - return Create_Value_Discrete + return Create_Memory_Discrete (Read_Discrete (Left) * Read_Discrete (Right), Res_Typ); when Iir_Predefined_Integer_Div | Iir_Predefined_Physical_Physical_Div | Iir_Predefined_Physical_Integer_Div => - return Create_Value_Discrete + return Create_Memory_Discrete (Read_Discrete (Left) / Read_Discrete (Right), Res_Typ); when Iir_Predefined_Integer_Mod => - return Create_Value_Discrete + return Create_Memory_Discrete (Read_Discrete (Left) mod Read_Discrete (Right), Res_Typ); when Iir_Predefined_Integer_Rem => - return Create_Value_Discrete + return Create_Memory_Discrete (Read_Discrete (Left) rem Read_Discrete (Right), Res_Typ); when Iir_Predefined_Integer_Exp => - return Create_Value_Discrete + return Create_Memory_Discrete (Read_Discrete (Left) ** Natural (Read_Discrete (Right)), Res_Typ); when Iir_Predefined_Physical_Minimum | Iir_Predefined_Integer_Minimum => - return Create_Value_Discrete + return Create_Memory_Discrete (Int64'Min (Read_Discrete (Left), Read_Discrete (Right)), Res_Typ); when Iir_Predefined_Physical_Maximum | Iir_Predefined_Integer_Maximum => - return Create_Value_Discrete + return Create_Memory_Discrete (Int64'Max (Read_Discrete (Left), Read_Discrete (Right)), Res_Typ); when Iir_Predefined_Integer_Less_Equal | Iir_Predefined_Physical_Less_Equal => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Discrete (Left) <= Read_Discrete (Right)), Boolean_Type); when Iir_Predefined_Integer_Less | Iir_Predefined_Physical_Less => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Discrete (Left) < Read_Discrete (Right)), Boolean_Type); when Iir_Predefined_Integer_Greater_Equal | Iir_Predefined_Physical_Greater_Equal => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Discrete (Left) >= Read_Discrete (Right)), Boolean_Type); when Iir_Predefined_Integer_Greater | Iir_Predefined_Physical_Greater => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Discrete (Left) > Read_Discrete (Right)), Boolean_Type); when Iir_Predefined_Integer_Equality | Iir_Predefined_Physical_Equality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Discrete (Left) = Read_Discrete (Right)), Boolean_Type); when Iir_Predefined_Integer_Inequality | Iir_Predefined_Physical_Inequality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Discrete (Left) /= Read_Discrete (Right)), Boolean_Type); when Iir_Predefined_Physical_Real_Mul => - return Create_Value_Discrete + return Create_Memory_Discrete (Int64 (Fp64 (Read_Discrete (Left)) * Read_Fp64 (Right)), Res_Typ); when Iir_Predefined_Real_Physical_Mul => - return Create_Value_Discrete + return Create_Memory_Discrete (Int64 (Read_Fp64 (Left) * Fp64 (Read_Discrete (Right))), Res_Typ); when Iir_Predefined_Physical_Real_Div => - return Create_Value_Discrete + return Create_Memory_Discrete (Int64 (Fp64 (Read_Discrete (Left)) / Read_Fp64 (Right)), Res_Typ); when Iir_Predefined_Floating_Less => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Fp64 (Left) < Read_Fp64 (Right)), Boolean_Type); when Iir_Predefined_Floating_Less_Equal => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Fp64 (Left) <= Read_Fp64 (Right)), Boolean_Type); when Iir_Predefined_Floating_Equality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Fp64 (Left) = Read_Fp64 (Right)), Boolean_Type); when Iir_Predefined_Floating_Inequality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Fp64 (Left) /= Read_Fp64 (Right)), Boolean_Type); when Iir_Predefined_Floating_Greater => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Fp64 (Left) > Read_Fp64 (Right)), Boolean_Type); when Iir_Predefined_Floating_Greater_Equal => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Fp64 (Left) >= Read_Fp64 (Right)), Boolean_Type); when Iir_Predefined_Floating_Plus => - return Create_Value_Float (Read_Fp64 (Left) + Read_Fp64 (Right), + return Create_Memory_Fp64 (Read_Fp64 (Left) + Read_Fp64 (Right), Res_Typ); when Iir_Predefined_Floating_Minus => - return Create_Value_Float (Read_Fp64 (Left) - Read_Fp64 (Right), + return Create_Memory_Fp64 (Read_Fp64 (Left) - Read_Fp64 (Right), Res_Typ); when Iir_Predefined_Floating_Mul => - return Create_Value_Float (Read_Fp64 (Left) * Read_Fp64 (Right), + return Create_Memory_Fp64 (Read_Fp64 (Left) * Read_Fp64 (Right), Res_Typ); when Iir_Predefined_Floating_Div => - return Create_Value_Float (Read_Fp64 (Left) / Read_Fp64 (Right), + return Create_Memory_Fp64 (Read_Fp64 (Left) / Read_Fp64 (Right), Res_Typ); when Iir_Predefined_Floating_Exp => - return Create_Value_Float + return Create_Memory_Fp64 (Read_Fp64 (Left) ** Natural (Read_Discrete (Right)), Res_Typ); when Iir_Predefined_Array_Array_Concat => @@ -617,20 +617,19 @@ package body Synth.Static_Oper is Iir_Index32 (Get_Bound_Length (Right.Typ, 1)); Bnd : Bound_Type; Res_Typ : Type_Acc; - Res : Valtyp; + Res : Memtyp; begin Bnd := Oper.Create_Bounds_From_Length (Syn_Inst, Get_Index_Type (Get_Type (Expr), 0), L_Len + R_Len); Res_Typ := Create_Onedimensional_Array_Subtype (Ret_Typ, Bnd); - Res := Create_Value_Memory (Res_Typ); + Res := Create_Memory (Res_Typ); if Left.Typ.Sz > 0 then - Copy_Memory (Res.Val.Mem, Left.Mem, Left.Typ.Sz); + Copy_Memory (Res.Mem, Left.Mem, Left.Typ.Sz); end if; if Right.Typ.Sz > 0 then - Copy_Memory (Res.Val.Mem + Left.Typ.Sz, - Right.Mem, Right.Typ.Sz); + Copy_Memory (Res.Mem + Left.Typ.Sz, Right.Mem, Right.Typ.Sz); end if; return Res; end; @@ -642,15 +641,15 @@ package body Synth.Static_Oper is Get_Array_Flat_Length (Right.Typ); Bnd : Bound_Type; Res_Typ : Type_Acc; - Res : Valtyp; + Res : Memtyp; begin Bnd := Oper.Create_Bounds_From_Length (Syn_Inst, Get_Index_Type (Get_Type (Expr), 0), 1 + Rlen); Res_Typ := Create_Onedimensional_Array_Subtype (Ret_Typ, Bnd); - Res := Create_Value_Memory (Res_Typ); - Copy_Memory (Res.Val.Mem, Left.Mem, Left.Typ.Sz); - Copy_Memory (Res.Val.Mem + Left.Typ.Sz, + Res := Create_Memory (Res_Typ); + Copy_Memory (Res.Mem, Left.Mem, Left.Typ.Sz); + Copy_Memory (Res.Mem + Left.Typ.Sz, Right.Mem, Right.Typ.Sz); return Res; end; @@ -661,34 +660,34 @@ package body Synth.Static_Oper is Llen : constant Iir_Index32 := Get_Array_Flat_Length (Left.Typ); Bnd : Bound_Type; Res_Typ : Type_Acc; - Res : Valtyp; + Res : Memtyp; begin Bnd := Oper.Create_Bounds_From_Length (Syn_Inst, Get_Index_Type (Get_Type (Expr), 0), Llen + 1); Res_Typ := Create_Onedimensional_Array_Subtype (Ret_Typ, Bnd); - Res := Create_Value_Memory (Res_Typ); - Copy_Memory (Res.Val.Mem, Left.Mem, Left.Typ.Sz); - Copy_Memory (Res.Val.Mem + Left.Typ.Sz, + Res := Create_Memory (Res_Typ); + Copy_Memory (Res.Mem, Left.Mem, Left.Typ.Sz); + Copy_Memory (Res.Mem + Left.Typ.Sz, Right.Mem, Right.Typ.Sz); return Res; end; when Iir_Predefined_Array_Equality | Iir_Predefined_Record_Equality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Is_Equal (Left, Right)), Boolean_Type); when Iir_Predefined_Array_Inequality | Iir_Predefined_Record_Inequality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (not Is_Equal (Left, Right)), Boolean_Type); when Iir_Predefined_Access_Equality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Access (Left) = Read_Access (Right)), Boolean_Type); when Iir_Predefined_Access_Inequality => - return Create_Value_Discrete + return Create_Memory_U8 (Boolean'Pos (Read_Access (Left) /= Read_Access (Right)), Boolean_Type); @@ -708,19 +707,19 @@ package body Synth.Static_Oper is return Synth_Vector_Dyadic (Left, Right, Xor_Table, Expr); when Iir_Predefined_Ieee_1164_Scalar_Or => - return Create_Value_Discrete + return Create_Memory_U8 (Std_Ulogic'Pos (Or_Table (Get_Static_Ulogic (Left), Get_Static_Ulogic (Right))), Res_Typ); when Iir_Predefined_Ieee_1164_Scalar_And => - return Create_Value_Discrete + return Create_Memory_U8 (Std_Ulogic'Pos (And_Table (Get_Static_Ulogic (Left), Get_Static_Ulogic (Right))), Res_Typ); when Iir_Predefined_Ieee_1164_Scalar_Xor => - return Create_Value_Discrete + return Create_Memory_U8 (Std_Ulogic'Pos (Xor_Table (Get_Static_Ulogic (Left), Get_Static_Ulogic (Right))), Res_Typ); @@ -731,7 +730,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Uns_Uns (Left, Right, Greater, Expr) = Equal; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Eq_Uns_Nat => declare @@ -739,7 +738,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Uns_Nat (Left, Right, Greater, Expr) = Equal; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Gt_Uns_Uns => @@ -748,7 +747,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Uns_Uns (Left, Right, Less, Expr) = Greater; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Gt_Nat_Uns => declare @@ -756,7 +755,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Nat_Uns (Left, Right, Less, Expr) = Greater; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Gt_Uns_Nat => declare @@ -764,7 +763,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Uns_Nat (Left, Right, Less, Expr) = Greater; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Le_Uns_Uns => @@ -773,7 +772,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Uns_Uns (Left, Right, Greater, Expr) <= Equal; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Le_Uns_Nat => declare @@ -781,7 +780,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Uns_Nat (Left, Right, Greater, Expr) <= Equal; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Lt_Uns_Uns => @@ -790,7 +789,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Uns_Uns (Left, Right, Greater, Expr) < Equal; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Lt_Uns_Nat => declare @@ -798,7 +797,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Uns_Nat (Left, Right, Greater, Expr) < Equal; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Lt_Nat_Uns => declare @@ -806,7 +805,7 @@ package body Synth.Static_Oper is begin Res := Synth_Compare_Nat_Uns (Left, Right, Greater, Expr) < Equal; - return Create_Value_Discrete (Boolean'Pos (Res), Res_Typ); + return Create_Memory_U8 (Boolean'Pos (Res), Res_Typ); end; when Iir_Predefined_Ieee_Numeric_Std_Add_Uns_Uns @@ -854,28 +853,28 @@ package body Synth.Static_Oper is Error_Msg_Synth (+Expr, "synth_static_dyadic_predefined: unhandled " & Iir_Predefined_Functions'Image (Def)); - return No_Valtyp; + return Null_Memtyp; end case; end Synth_Static_Dyadic_Predefined; - function Synth_Vector_Monadic (Vec : Memtyp; Op : Table_1d) return Valtyp + function Synth_Vector_Monadic (Vec : Memtyp; Op : Table_1d) return Memtyp is Len : constant Iir_Index32 := Vec_Length (Vec.Typ); - Res : Valtyp; + Res : Memtyp; begin - Res := Create_Value_Memory (Create_Res_Bound (Vec.Typ)); + Res := Create_Memory (Create_Res_Bound (Vec.Typ)); for I in 1 .. Uns32 (Len) loop declare V : constant Std_Ulogic := Read_Std_Logic (Vec.Mem, I - 1); begin - Write_Std_Logic (Res.Val.Mem, I - 1, Op (V)); + Write_Std_Logic (Res.Mem, I - 1, Op (V)); end; end loop; return Res; end Synth_Vector_Monadic; function Synth_Vector_Reduce - (Init : Std_Ulogic; Vec : Memtyp; Op : Table_2d) return Valtyp + (Init : Std_Ulogic; Vec : Memtyp; Op : Table_2d) return Memtyp is El_Typ : constant Type_Acc := Vec.Typ.Vec_El; Res : Std_Ulogic; @@ -889,13 +888,13 @@ package body Synth.Static_Oper is end; end loop; - return Create_Value_Discrete (Std_Ulogic'Pos (Res), El_Typ); + return Create_Memory_U8 (Std_Ulogic'Pos (Res), El_Typ); end Synth_Vector_Reduce; function Synth_Static_Monadic_Predefined (Syn_Inst : Synth_Instance_Acc; Imp : Node; Operand : Memtyp; - Expr : Node) return Valtyp + Expr : Node) return Memtyp is Def : constant Iir_Predefined_Functions := Get_Implicit_Definition (Imp); @@ -907,26 +906,25 @@ package body Synth.Static_Oper is case Def is when Iir_Predefined_Boolean_Not | Iir_Predefined_Bit_Not => - return Create_Value_Discrete - (1 - Read_Discrete (Operand), Oper_Typ); + return Create_Memory_U8 (1 - Read_U8 (Operand), Oper_Typ); when Iir_Predefined_Integer_Negation | Iir_Predefined_Physical_Negation => - return Create_Value_Discrete (-Read_Discrete (Operand), Oper_Typ); + return Create_Memory_Discrete (-Read_Discrete (Operand), Oper_Typ); when Iir_Predefined_Integer_Absolute | Iir_Predefined_Physical_Absolute => - return Create_Value_Discrete + return Create_Memory_Discrete (abs Read_Discrete(Operand), Oper_Typ); when Iir_Predefined_Integer_Identity | Iir_Predefined_Physical_Identity => - return Create_Value_Memory (Operand); + return Operand; when Iir_Predefined_Floating_Negation => - return Create_Value_Float (-Read_Fp64 (Operand), Oper_Typ); + return Create_Memory_Fp64 (-Read_Fp64 (Operand), Oper_Typ); when Iir_Predefined_Floating_Identity => - return Create_Value_Memory (Operand); + return Operand; when Iir_Predefined_Floating_Absolute => - return Create_Value_Float (abs Read_Fp64 (Operand), Oper_Typ); + return Create_Memory_Fp64 (abs Read_Fp64 (Operand), Oper_Typ); when Iir_Predefined_Ieee_1164_Condition_Operator => -- Constant std_logic: need to convert. @@ -934,8 +932,8 @@ package body Synth.Static_Oper is Val : Uns32; Zx : Uns32; begin - From_Std_Logic (Read_Discrete (Operand), Val, Zx); - return Create_Value_Discrete + From_Std_Logic (Int64 (Read_U8 (Operand)), Val, Zx); + return Create_Memory_U8 (Boolean'Pos (Val = 1 and Zx = 0), Boolean_Type); end; @@ -948,7 +946,7 @@ package body Synth.Static_Oper is declare Res_Arr : constant Std_Logic_Vector := Neg_Sgn (Op_Arr); begin - return To_Valtyp (Res_Arr, Operand.Typ.Vec_El); + return To_Memtyp (Res_Arr, Operand.Typ.Vec_El); end; end; @@ -958,7 +956,7 @@ package body Synth.Static_Oper is return Synth_Vector_Monadic (Operand, Not_Table); when Iir_Predefined_Ieee_1164_Scalar_Not => - return Create_Value_Discrete + return Create_Memory_U8 (Std_Ulogic'Pos (Not_Table (Read_Std_Logic (Operand.Mem, 0))), Oper_Typ); @@ -1114,7 +1112,6 @@ package body Synth.Static_Oper is when Iir_Predefined_Ieee_1164_To_Stdlogicvector_Bv => declare - use Grt.Types; El_Type : constant Type_Acc := Get_Array_Element (Res_Typ); Res : Valtyp; Bnd : Type_Acc; |