aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-09-30 20:09:45 +0200
committerTristan Gingold <tgingold@free.fr>2019-09-30 20:09:45 +0200
commit6b16e955ce1b41e88f825de3e9922ca11dd1037d (patch)
tree49a47627c2a33284911f9e3899fb34693d3070d7
parent65a096b1cd73dc30a6849fe1ff7b368d944515d9 (diff)
downloadghdl-6b16e955ce1b41e88f825de3e9922ca11dd1037d.tar.gz
ghdl-6b16e955ce1b41e88f825de3e9922ca11dd1037d.tar.bz2
ghdl-6b16e955ce1b41e88f825de3e9922ca11dd1037d.zip
synth-expr: minor factorisation.
-rw-r--r--src/synth/synth-expr.adb44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 5fdf30067..376ce6740 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -905,6 +905,7 @@ package body Synth.Expr is
Idx_Expr : constant Node := Get_Nth_Element (Indexes, 0);
Idx_Val : Value_Acc;
Idx_Type : Type_Acc;
+ Bnd : Bound_Type;
begin
if Get_Nbr_Elements (Indexes) /= 1 then
Error_Msg_Synth (+Name, "multi-dim arrays not yet supported");
@@ -916,32 +917,25 @@ package body Synth.Expr is
(Syn_Inst, Get_Base_Type (Get_Type (Idx_Expr)));
Idx_Val := Synth_Expression_With_Type (Syn_Inst, Idx_Expr, Idx_Type);
- if Pfx_Type.Kind = Type_Vector then
- W := 1;
- if Idx_Val.Kind = Value_Discrete then
- Voff := No_Net;
- Mul := 0;
- Off := Index_To_Offset (Pfx_Type.Vbound, Idx_Val.Scal, Name);
- else
- Voff := Dyn_Index_To_Offset (Pfx_Type.Vbound, Idx_Val, Name);
- Off := 0;
- Mul := 1;
- end if;
- elsif Pfx_Type.Kind = Type_Array then
- W := Get_Type_Width (Pfx_Type.Arr_El);
- if Idx_Val.Kind = Value_Discrete then
- Voff := No_Net;
- Off := Index_To_Offset
- (Pfx_Type.Abounds.D (1), Idx_Val.Scal, Name);
- Mul := 0;
- else
- Voff := Dyn_Index_To_Offset
- (Pfx_Type.Abounds.D (1), Idx_Val, Name);
- Mul := W;
- Off := 0;
- end if;
+ case Pfx_Type.Kind is
+ when Type_Vector =>
+ W := 1;
+ Bnd := Pfx_Type.Vbound;
+ when Type_Array =>
+ W := Get_Type_Width (Pfx_Type.Arr_El);
+ Bnd := Pfx_Type.Abounds.D (1);
+ when others =>
+ raise Internal_Error;
+ end case;
+
+ if Idx_Val.Kind = Value_Discrete then
+ Voff := No_Net;
+ Mul := 0;
+ Off := Index_To_Offset (Bnd, Idx_Val.Scal, Name);
else
- raise Internal_Error;
+ Voff := Dyn_Index_To_Offset (Bnd, Idx_Val, Name);
+ Off := 0;
+ Mul := W;
end if;
end Synth_Indexed_Name;