diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-07-27 11:38:19 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-07-28 20:27:57 +0200 |
commit | b2ce3ad7385a6d3c3ddb4017f1418b60c83042c4 (patch) | |
tree | 584ce3fa3295d14dcacab94bab7f7ae0e22f49ce /src/synth/synth-values.ads | |
parent | fc5ed4cb9c73414eeb821aa5183954cee1866251 (diff) | |
download | ghdl-b2ce3ad7385a6d3c3ddb4017f1418b60c83042c4.tar.gz ghdl-b2ce3ad7385a6d3c3ddb4017f1418b60c83042c4.tar.bz2 ghdl-b2ce3ad7385a6d3c3ddb4017f1418b60c83042c4.zip |
synth: preliminary support of dynamic indexing.
Diffstat (limited to 'src/synth/synth-values.ads')
-rw-r--r-- | src/synth/synth-values.ads | 195 |
1 files changed, 111 insertions, 84 deletions
diff --git a/src/synth/synth-values.ads b/src/synth/synth-values.ads index 21eeaf0c2..9f93ab0b9 100644 --- a/src/synth/synth-values.ads +++ b/src/synth/synth-values.ads @@ -26,6 +26,80 @@ with Areapools; use Areapools; package Synth.Values is + type Discrete_Range_Type is record + -- An integer range. + Dir : Iir_Direction; + + -- Netlist representation: signed or unsigned, width of bus. + Is_Signed : Boolean; + W : Width; + + Left : Int64; + Right : Int64; + end record; + + type Float_Range_Type is record + Dir : Iir_Direction; + Left : Fp64; + Right : Fp64; + end record; + + type Bound_Type is record + Dir : Iir_Direction; + W : Width; + Left : Int32; + Right : Int32; + Len : Width; + end record; + + type Bound_Array_Type is array (Iir_Index32 range <>) of Bound_Type; + + type Bound_Array (Len : Iir_Index32) is record + D : Bound_Array_Type (1 .. Len); + end record; + + type Bound_Array_Acc is access Bound_Array; + + type Type_Kind is + ( + Type_Bit, + Type_Discrete, + Type_Float, + Type_Vector, + Type_Array, + Type_Record + ); + + type Type_Type (Kind : Type_Kind); + type Type_Acc is access Type_Type; + + type Type_Acc_Array_Type is array (Iir_Index32 range <>) of Type_Acc; + + type Type_Acc_Array (Len : Iir_Index32) is record + E : Type_Acc_Array_Type (1 .. Len); + end record; + + type Type_Acc_Array_Acc is access Type_Acc_Array; + + type Type_Type (Kind : Type_Kind) is record + case Kind is + when Type_Bit => + null; + when Type_Discrete => + Drange : Discrete_Range_Type; + when Type_Float => + Frange : Float_Range_Type; + when Type_Vector => + Vbound : Bound_Type; + Vec_El : Type_Acc; + when Type_Array => + Abounds : Bound_Array_Acc; + Arr_El : Type_Acc; + when Type_Record => + Rec : Type_Acc_Array_Acc; + end case; + end record; + -- Values is how signals and variables are decomposed. This is similar to -- values in simulation, but simplified (no need to handle files, -- accesses...) @@ -46,23 +120,17 @@ package Synth.Values is Value_Float, - Value_Range, - Value_Fp_Range, - - -- A range with a length. - Value_Bound, - - -- A vector of bounds, for arrays. - Value_Bounds, - - -- A non-vector array. + -- An array. Value_Array, -- A record. Value_Record, -- A package. - Value_Instance + Value_Instance, + + -- A subtype. + Value_Subtype ); type Value_Type (Kind : Value_Kind); @@ -78,54 +146,15 @@ package Synth.Values is type Value_Array_Acc is access Value_Array_Type; - type Value_Range_Type is record - -- An integer range. - Dir : Iir_Direction; - - -- Netlist representation: signed or unsigned, width of bus. - Is_Signed : Boolean; - W : Width; - - Left : Int64; - Right : Int64; - end record; - - type Value_Fp_Range_Type is record - Dir : Iir_Direction; - Left : Fp64; - Right : Fp64; - end record; - - type Value_Bound_Type is record - Dir : Iir_Direction; - Left : Int32; - Right : Int32; - Len : Width; - end record; - - type Value_Bound_Acc is access Value_Bound_Type; - - No_Bound : constant Value_Bound_Acc := null; - - type Value_Bound_Array_Type is array (Iir_Index32 range <>) of - Value_Bound_Acc; - - type Value_Bound_Array (Len : Iir_Index32) is record - D : Value_Bound_Array_Type (1 .. Len); - end record; - - type Value_Bound_Array_Acc is access Value_Bound_Array; - type Instance_Id is new Nat32; type Value_Type (Kind : Value_Kind) is record + Typ : Type_Acc; case Kind is when Value_Net => N : Net; - N_Bound : Value_Bound_Acc; when Value_Wire => W : Wire_Id; - W_Bound : Value_Bound_Acc; when Value_Mux2 => M_Cond : Value_Acc; M_T : Value_Acc; @@ -134,17 +163,10 @@ package Synth.Values is Scal : Int64; when Value_Float => Fp : Fp64; - when Value_Range => - Rng : Value_Range_Type; - when Value_Fp_Range => - Fp_Rng : Value_Fp_Range_Type; - when Value_Bound => - Bnd : Value_Bound_Acc; - when Value_Bounds => - Bnds : Value_Bound_Array_Acc; + when Value_Subtype => + null; when Value_Array => Arr : Value_Array_Acc; - Bounds : Value_Bound_Array_Acc; when Value_Record => Rec : Value_Array_Acc; when Value_Instance => @@ -161,56 +183,61 @@ package Synth.Values is -- Pool for objects allocated in the current instance. Instance_Pool : Areapool_Acc; + -- Types. + function Create_Discrete_Type (Rng : Discrete_Range_Type) return Type_Acc; + function Create_Float_Type (Rng : Float_Range_Type) return Type_Acc; + function Create_Vec_Type_By_Length (Len : Width; El : Type_Acc) + return Type_Acc; + function Create_Vector_Type (Bnd : Bound_Type; El_Type : Type_Acc) + return Type_Acc; + function Create_Bound_Array (Ndims : Iir_Index32) return Bound_Array_Acc; + function Create_Array_Type (Bnd : Bound_Array_Acc; El_Type : Type_Acc) + return Type_Acc; + function Is_Equal (L, R : Value_Acc) return Boolean; -- Create a Value_Net. - function Create_Value_Net (N : Net; Bnd : Value_Bound_Acc) return Value_Acc; + function Create_Value_Net (N : Net; Ntype : Type_Acc) return Value_Acc; -- Create a Value_Wire. For a bit wire, RNG must be null. - function Create_Value_Wire (W : Wire_Id; Bnd : Value_Bound_Acc) - return Value_Acc; + function Create_Value_Wire (W : Wire_Id; Wtype : Type_Acc) return Value_Acc; -- Create a mux2. function Create_Value_Mux2 (Cond : Value_Acc; T : Value_Acc; F : Value_Acc) return Value_Acc; - function Create_Value_Discrete (Val : Int64) return Value_Acc; + function Create_Value_Discrete (Val : Int64; Vtype : Type_Acc) + return Value_Acc; - function Create_Value_Float (Val : Fp64) return Value_Acc; + function Create_Value_Float (Val : Fp64; Vtype : Type_Acc) return Value_Acc; + + function Create_Value_Subtype (Typ : Type_Acc) return Value_Acc; function Create_Value_Array (Len : Iir_Index32) return Value_Array_Acc; - function Create_Value_Bound_Array (Ndim : Iir_Index32) - return Value_Bound_Array_Acc; -- Create a Value_Array. - function Create_Value_Array (Bounds : Value_Bound_Array_Acc; - Arr : Value_Array_Acc) + function Create_Value_Array (Bounds : Type_Acc; Arr : Value_Array_Acc) return Value_Acc; -- Like the previous one but automatically build the array. - function Create_Value_Array (Bounds : Value_Bound_Array_Acc) - return Value_Acc; - - function Create_Value_Bounds (Bounds : Value_Bound_Array_Acc) - return Value_Acc; + function Create_Value_Array (Bounds : Type_Acc) return Value_Acc; -- Allocate the ARR component of the Value_Type ARR, using BOUNDS. procedure Create_Array_Data (Arr : Value_Acc); function Create_Value_Instance (Inst : Instance_Id) return Value_Acc; - function Create_Value_Bound (Bnd : Value_Bound_Type) return Value_Bound_Acc; - - -- Allocate a Value_Range. - function Create_Value_Range (Rng : Value_Range_Type) return Value_Acc; - function Create_Value_Fp_Range (Rng : Value_Fp_Range_Type) return Value_Acc; - function Create_Value_Bound (Dir : Iir_Direction; Left, Right : Value_Acc) - return Value_Bound_Acc; - function Unshare (Src : Value_Acc; Pool : Areapool_Acc) return Value_Acc; - function Extract_Bound (Val : Value_Acc) return Value_Bound_Acc; + function Extract_Bound (Val : Value_Acc) return Type_Acc; + + function Get_Type_Width (Atype : Type_Acc) return Width; + + procedure Init; - function Get_Bound_Width (Bnd : Value_Bound_Acc) return Width; + -- Set by Init. + Boolean_Type : Type_Acc := null; + Logic_Type : Type_Acc := null; + Bit_Type : Type_Acc := null; end Synth.Values; |