diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-04-10 07:28:13 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-04-10 07:49:06 +0200 |
commit | 59e6f2a0a21724cbb71d55ff08ac1ecbf10695b9 (patch) | |
tree | a4fdcd44a59d0c3ff062856b1e156e4cfdfcfcef /src | |
parent | 2bea592952b8a9f9860bb646ddf72d26eac4ad29 (diff) | |
download | ghdl-59e6f2a0a21724cbb71d55ff08ac1ecbf10695b9.tar.gz ghdl-59e6f2a0a21724cbb71d55ff08ac1ecbf10695b9.tar.bz2 ghdl-59e6f2a0a21724cbb71d55ff08ac1ecbf10695b9.zip |
synth: use more memtyp in synth-static_oper.
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/synth-oper.adb | 2 | ||||
-rw-r--r-- | src/synth/synth-static_oper.adb | 107 | ||||
-rw-r--r-- | src/synth/synth-static_oper.ads | 2 | ||||
-rw-r--r-- | src/synth/synth-values.adb | 13 | ||||
-rw-r--r-- | src/synth/synth-values.ads | 1 |
5 files changed, 26 insertions, 99 deletions
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb index df04a8258..ca9782ed0 100644 --- a/src/synth/synth-oper.adb +++ b/src/synth/synth-oper.adb @@ -1358,7 +1358,7 @@ package body Synth.Oper is if Is_Static_Val (Operand.Val) then return Synth_Static_Monadic_Predefined - (Syn_Inst, Imp, Operand, Loc); + (Syn_Inst, Imp, Get_Value_Memtyp (Operand), Loc); end if; case Def is diff --git a/src/synth/synth-static_oper.adb b/src/synth/synth-static_oper.adb index 0e328f3fd..725a51dce 100644 --- a/src/synth/synth-static_oper.adb +++ b/src/synth/synth-static_oper.adb @@ -27,11 +27,9 @@ with Vhdl.Utils; use Vhdl.Utils; with Vhdl.Ieee.Std_Logic_1164; use Vhdl.Ieee.Std_Logic_1164; with Netlists; use Netlists; -with Netlists.Utils; use Netlists.Utils; with Synth.Errors; use Synth.Errors; with Synth.Source; use Synth.Source; -with Synth.Environment; with Synth.Expr; use Synth.Expr; with Synth.Oper; with Synth.Ieee.Std_Logic_1164; use Synth.Ieee.Std_Logic_1164; @@ -45,70 +43,6 @@ package body Synth.Static_Oper is type Compare_Type is (Compare_Less, Compare_Equal, Compare_Greater); - type Static_Arr_Kind is (Sarr_Value, Sarr_Net); - - type Static_Arr_Type (Kind : Static_Arr_Kind) is record - case Kind is - when Sarr_Value => - Arr : Memory_Ptr; - when Sarr_Net => - N : Net; - end case; - end record; - - function Get_Static_Array (V : Valtyp) return Static_Arr_Type - is - N : Net; - begin - case V.Val.Kind is - when Value_Const => - return (Kind => Sarr_Value, Arr => V.Val.C_Val.Mem); - when Value_Memory => - return (Kind => Sarr_Value, Arr => V.Val.Mem); - when Value_Net => - N := V.Val.N; - when Value_Wire => - return (Kind => Sarr_Value, - Arr => Synth.Environment.Get_Static_Wire (V.Val.W).Mem); - when others => - raise Internal_Error; - end case; - return (Kind => Sarr_Net, N => N); - end Get_Static_Array; - - function Logic_To_Std_Logic (Va : Uns32; Zx : Uns32) return Std_Ulogic - is - subtype Uns4 is Uns32 range 0 .. 3; - begin - case Uns4 (Va + 2 * Zx) is - when 0 => - return Std_Ulogic'Val (Vhdl.Ieee.Std_Logic_1164.Std_Logic_0_Pos); - when 1 => - return Std_Ulogic'Val (Vhdl.Ieee.Std_Logic_1164.Std_Logic_1_Pos); - when 2 => - return Std_Ulogic'Val (Vhdl.Ieee.Std_Logic_1164.Std_Logic_Z_Pos); - when 3 => - return Std_Ulogic'Val (Vhdl.Ieee.Std_Logic_1164.Std_Logic_X_Pos); - end case; - end Logic_To_Std_Logic; - - function Get_Static_Std_Logic (Sarr : Static_Arr_Type; Off : Uns32) - return Std_Ulogic is - begin - case Sarr.Kind is - when Sarr_Value => - return Std_Ulogic'Val (Read_U8 (Sarr.Arr + Size_Type (Off))); - when Sarr_Net => - declare - Va : Uns32; - Zx : Uns32; - begin - Get_Net_Element (Sarr.N, Off, Va, Zx); - return Logic_To_Std_Logic (Va, Zx); - end; - end case; - end Get_Static_Std_Logic; - function Read_Std_Logic (M : Memory_Ptr; Off : Uns32) return Std_Ulogic is begin return Std_Ulogic'Val (Read_U8 (M + Size_Type (Off))); @@ -325,24 +259,6 @@ package body Synth.Static_Oper is return Res; end Synth_Vector_Dyadic; - procedure To_Std_Logic_Vector - (Val : Valtyp; Arr : out Std_Logic_Vector) - is - Sarr : constant Static_Arr_Type := Get_Static_Array (Val); - begin - case Sarr.Kind is - when Sarr_Value => - for I in 1 .. Vec_Length (Val.Typ) loop - Arr (Natural (I)) := Std_Ulogic'Val - (Read_U8 (Sarr.Arr + Size_Type (I - 1))); - end loop; - when Sarr_Net => - for I in Arr'Range loop - Arr (Natural (I)) := Get_Static_Std_Logic (Sarr, Uns32 (I - 1)); - end loop; - end case; - end To_Std_Logic_Vector; - procedure To_Std_Logic_Vector (Val : Memtyp; Arr : out Std_Logic_Vector) is begin for I in 1 .. Uns32 (Vec_Length (Val.Typ)) loop @@ -938,16 +854,15 @@ package body Synth.Static_Oper is end Synth_Static_Dyadic_Predefined; function Synth_Vector_Monadic - (Vec : Valtyp; Op : Table_1d) return Valtyp + (Vec : Memtyp; Op : Table_1d) return Valtyp is Len : constant Iir_Index32 := Vec_Length (Vec.Typ); Res : Valtyp; begin Res := Create_Value_Memory (Create_Res_Bound (Vec.Typ)); - for I in 1 .. Len loop + for I in 1 .. Uns32 (Len) loop declare - V : constant Std_Ulogic := Std_Ulogic'Val - (Read_U8 (Vec.Val.Mem + Size_Type (I - 1))); + V : constant Std_Ulogic := Read_Std_Logic (Vec.Mem, I - 1); begin Write_U8 (Res.Val.Mem + Size_Type (I - 1), Std_Ulogic'Pos (Op (V))); @@ -957,16 +872,15 @@ package body Synth.Static_Oper is end Synth_Vector_Monadic; function Synth_Vector_Reduce - (Init : Std_Ulogic; Vec : Valtyp; Op : Table_2d) return Valtyp + (Init : Std_Ulogic; Vec : Memtyp; Op : Table_2d) return Valtyp is El_Typ : constant Type_Acc := Vec.Typ.Vec_El; Res : Std_Ulogic; begin Res := Init; - for I in 1 .. Vec_Length (Vec.Typ) loop + for I in 1 .. Uns32 (Vec_Length (Vec.Typ)) loop declare - V : constant Std_Ulogic := - Std_Ulogic'Val (Read_U8 (Vec.Val.Mem + Size_Type (I - 1))); + V : constant Std_Ulogic := Read_Std_Logic (Vec.Mem, I - 1); begin Res := Op (Res, V); end; @@ -977,7 +891,7 @@ package body Synth.Static_Oper is function Synth_Static_Monadic_Predefined (Syn_Inst : Synth_Instance_Acc; Imp : Node; - Operand : Valtyp; + Operand : Memtyp; Expr : Node) return Valtyp is Def : constant Iir_Predefined_Functions := @@ -1002,12 +916,12 @@ package body Synth.Static_Oper is (abs Read_Discrete(Operand), Oper_Typ); when Iir_Predefined_Integer_Identity | Iir_Predefined_Physical_Identity => - return Operand; + return Create_Value_Memory (Operand); when Iir_Predefined_Floating_Negation => return Create_Value_Float (-Read_Fp64 (Operand), Oper_Typ); when Iir_Predefined_Floating_Identity => - return Operand; + return Create_Value_Memory (Operand); when Iir_Predefined_Floating_Absolute => return Create_Value_Float (abs Read_Fp64 (Operand), Oper_Typ); @@ -1042,8 +956,7 @@ package body Synth.Static_Oper is when Iir_Predefined_Ieee_1164_Scalar_Not => return Create_Value_Discrete - (Std_Ulogic'Pos - (Not_Table (Std_Ulogic'Val (Get_Static_Discrete (Operand)))), + (Std_Ulogic'Pos (Not_Table (Read_Std_Logic (Operand.Mem, 0))), Oper_Typ); when Iir_Predefined_Ieee_1164_Vector_Or_Reduce => diff --git a/src/synth/synth-static_oper.ads b/src/synth/synth-static_oper.ads index 7af156f07..d1c9458e0 100644 --- a/src/synth/synth-static_oper.ads +++ b/src/synth/synth-static_oper.ads @@ -31,7 +31,7 @@ package Synth.Static_Oper is Expr : Node) return Valtyp; function Synth_Static_Monadic_Predefined (Syn_Inst : Synth_Instance_Acc; Imp : Node; - Operand : Valtyp; + Operand : Memtyp; Expr : Node) return Valtyp; function Synth_Static_Predefined_Function_Call diff --git a/src/synth/synth-values.adb b/src/synth/synth-values.adb index 481739f8f..4cda711c6 100644 --- a/src/synth/synth-values.adb +++ b/src/synth/synth-values.adb @@ -163,6 +163,19 @@ package body Synth.Values is return (Vtype, V); end Create_Value_Memory; + function Create_Value_Memory (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); + V : Value_Acc; + begin + V := To_Value_Acc + (Alloc (Current_Pool, Value_Type_Memory'(Kind => Value_Memory, + Mem => Mt.Mem))); + + return (Mt.Typ, V); + end Create_Value_Memory; + function Create_Value_File (File : File_Index) return Value_Acc is subtype Value_Type_File is Value_Type (Value_File); diff --git a/src/synth/synth-values.ads b/src/synth/synth-values.ads index 097f9fd22..8da1d74cd 100644 --- a/src/synth/synth-values.ads +++ b/src/synth/synth-values.ads @@ -120,6 +120,7 @@ package Synth.Values is function Create_Value_Wire (W : Wire_Id; Wtype : Type_Acc) return Valtyp; function Create_Value_Memory (Vtype : Type_Acc) return Valtyp; + function Create_Value_Memory (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; |