aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-27 20:30:03 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-27 20:30:03 +0100
commit96fa0501d17bd6931973c61e05bc00ff24a38ce3 (patch)
treea173e938b2254f4975628b21d6fba200f212e406
parentfa01fb8ca801e7f47abbd32ca6e2cb83f207cbc1 (diff)
downloadghdl-96fa0501d17bd6931973c61e05bc00ff24a38ce3.tar.gz
ghdl-96fa0501d17bd6931973c61e05bc00ff24a38ce3.tar.bz2
ghdl-96fa0501d17bd6931973c61e05bc00ff24a38ce3.zip
synth-stmts: handle case statement for static arrays. Fix #1035
-rw-r--r--src/synth/synth-stmts.adb40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index b0b2518f7..5b400843b 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -1090,6 +1090,42 @@ package body Synth.Stmts is
Free_Net_Array (Nets);
end Synth_Case_Statement_Dynamic;
+ procedure Synth_Case_Statement_Static_Array
+ (C : in out Seq_Context; Stmt : Node; Sel : Value_Acc)
+ is
+ Choices : constant Node := Get_Case_Statement_Alternative_Chain (Stmt);
+ Choice : Node;
+ Stmts : Node;
+ Sel_Expr : Node;
+ Sel_Val : Value_Acc;
+ begin
+ -- Synth statements, extract choice value.
+ Stmts := Null_Node;
+ Choice := Choices;
+ loop
+ pragma Assert (Is_Valid (Choice));
+ if not Get_Same_Alternative_Flag (Choice) then
+ Stmts := Get_Associated_Chain (Choice);
+ end if;
+
+ case Get_Kind (Choice) is
+ when Iir_Kind_Choice_By_Expression =>
+ Sel_Expr := Get_Choice_Expression (Choice);
+ Sel_Val := Synth_Expression_With_Basetype (C.Inst, Sel_Expr);
+ if Is_Equal (Sel_Val, Sel) then
+ Synth_Sequential_Statements (C, Stmts);
+ exit;
+ end if;
+ when Iir_Kind_Choice_By_Others =>
+ Synth_Sequential_Statements (C, Stmts);
+ exit;
+ when others =>
+ raise Internal_Error;
+ end case;
+ Choice := Get_Chain (Choice);
+ end loop;
+ end Synth_Case_Statement_Static_Array;
+
procedure Synth_Case_Statement_Static_Scalar
(C : in out Seq_Context; Stmt : Node; Sel : Int64)
is
@@ -1156,8 +1192,10 @@ package body Synth.Stmts is
| Type_Logic
| Type_Discrete =>
Synth_Case_Statement_Static_Scalar (C, Stmt, Sel.Scal);
+ when Type_Vector
+ | Type_Array =>
+ Synth_Case_Statement_Static_Array (C, Stmt, Sel);
when others =>
- -- TODO: support vector/array/slice
raise Internal_Error;
end case;
else