aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-09-27 06:04:16 +0200
committerTristan Gingold <tgingold@free.fr>2019-09-27 06:04:16 +0200
commit58f73d250fc5165f94678738b8d9dffe6bcf3c68 (patch)
tree2406497e6fcd4fb247808c6e623041f679093cb1 /src
parentfb30460433764b495dc05d5a1a90acb724a7706a (diff)
downloadghdl-58f73d250fc5165f94678738b8d9dffe6bcf3c68.tar.gz
ghdl-58f73d250fc5165f94678738b8d9dffe6bcf3c68.tar.bz2
ghdl-58f73d250fc5165f94678738b8d9dffe6bcf3c68.zip
synth: handle range attribute; handle vhdl08 array subtype.
Fix #944
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-decls.adb44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb
index 3208a61f9..bca936229 100644
--- a/src/synth/synth-decls.adb
+++ b/src/synth/synth-decls.adb
@@ -208,15 +208,13 @@ package body Synth.Decls is
end Synth_Anonymous_Type_Definition;
function Synth_Discrete_Range_Constraint
- (Syn_Inst : Synth_Instance_Acc; Rng : Node) return Discrete_Range_Type is
+ (Syn_Inst : Synth_Instance_Acc; Rng : Node) return Discrete_Range_Type
+ is
+ W : Width;
+ Res : Discrete_Range_Type;
begin
- case Get_Kind (Rng) is
- when Iir_Kind_Range_Expression =>
- -- FIXME: check range.
- return Synth_Discrete_Range_Expression (Syn_Inst, Rng);
- when others =>
- Error_Kind ("synth_discrete_range_constraint", Rng);
- end case;
+ Synth_Discrete_Range (Syn_Inst, Rng, Res, W);
+ return Res;
end Synth_Discrete_Range_Constraint;
function Synth_Float_Range_Constraint
@@ -257,20 +255,28 @@ package body Synth.Decls is
Btyp := Get_Value_Type (Syn_Inst, Get_Base_Type (Atype));
if Btyp.Kind = Type_Unbounded_Vector then
- St_El := Get_Index_Type (St_Indexes, 0);
- return Create_Vector_Type
- (Synth_Bounds_From_Range (Syn_Inst, St_El), Btyp.Uvec_El);
+ if Get_Index_Constraint_Flag (Atype) then
+ St_El := Get_Index_Type (St_Indexes, 0);
+ return Create_Vector_Type
+ (Synth_Bounds_From_Range (Syn_Inst, St_El), Btyp.Uvec_El);
+ else
+ return Btyp;
+ end if;
else
-- FIXME: partially constrained arrays, subtype in indexes...
Etyp := Get_Value_Type (Syn_Inst, El_Type);
- Bnds := Create_Bound_Array
- (Iir_Index32 (Get_Nbr_Elements (St_Indexes)));
- for I in Flist_First .. Flist_Last (St_Indexes) loop
- St_El := Get_Index_Type (St_Indexes, I);
- Bnds.D (Iir_Index32 (I + 1)) :=
- Synth_Bounds_From_Range (Syn_Inst, St_El);
- end loop;
- return Create_Array_Type (Bnds, Etyp);
+ if Get_Index_Constraint_Flag (Atype) then
+ Bnds := Create_Bound_Array
+ (Iir_Index32 (Get_Nbr_Elements (St_Indexes)));
+ for I in Flist_First .. Flist_Last (St_Indexes) loop
+ St_El := Get_Index_Type (St_Indexes, I);
+ Bnds.D (Iir_Index32 (I + 1)) :=
+ Synth_Bounds_From_Range (Syn_Inst, St_El);
+ end loop;
+ return Create_Array_Type (Bnds, Etyp);
+ else
+ raise Internal_Error;
+ end if;
end if;
end Synth_Array_Subtype_Indication;