aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-09-30 01:04:26 +0200
committerTristan Gingold <tgingold@free.fr>2019-09-30 01:04:26 +0200
commit3b1bf68837ca0bbfb7a45b0dd11edb06ae9b0885 (patch)
treeaadf22776f1adeb56e6601e0614d134553ca224e /src
parent7201b1537e396d72ace4259a8a9578eda300a6a2 (diff)
downloadghdl-3b1bf68837ca0bbfb7a45b0dd11edb06ae9b0885.tar.gz
ghdl-3b1bf68837ca0bbfb7a45b0dd11edb06ae9b0885.tar.bz2
ghdl-3b1bf68837ca0bbfb7a45b0dd11edb06ae9b0885.zip
synth: handle while-loop statement.
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-stmts.adb39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index 1fd331e85..c0b810b54 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -1587,6 +1587,43 @@ package body Synth.Stmts is
C.Cur_Loop := Lc.Prev_Loop;
end Synth_For_Loop_Statement;
+ procedure Synth_While_Loop_Statement (C : in out Seq_Context; Stmt : Node)
+ is
+ Stmts : constant Node := Get_Sequential_Statement_Chain (Stmt);
+ Cond : constant Node := Get_Condition (Stmt);
+ Val : Value_Acc;
+ Lc : aliased Loop_Context;
+ begin
+ Lc := (Prev_Loop => C.Cur_Loop,
+ Loop_Stmt => Stmt,
+ Need_Quit => False,
+ Saved_En => No_Net,
+ W_Exit => No_Wire_Id,
+ W_Quit => No_Wire_Id,
+ Wire_Mark => No_Wire_Id);
+ C.Cur_Loop := Lc'Unrestricted_Access;
+
+ Loop_Control_Init (C, Stmt);
+
+ loop
+ if Cond /= Null_Node then
+ Val := Synth_Expression_With_Type (C.Inst, Cond, Boolean_Type);
+ if not Is_Const (Val) then
+ Error_Msg_Synth (+Cond, "loop condition must be static");
+ exit;
+ end if;
+ exit when Val.Scal = 0;
+ end if;
+
+ Synth_Sequential_Statements (C, Stmts);
+
+ Loop_Control_Update (C);
+ end loop;
+ Loop_Control_Finish (C);
+
+ C.Cur_Loop := Lc.Prev_Loop;
+ end Synth_While_Loop_Statement;
+
procedure Synth_Return_Statement (C : in out Seq_Context; Stmt : Node)
is
Val : Value_Acc;
@@ -1653,6 +1690,8 @@ package body Synth.Stmts is
Synth_Case_Statement (C, Stmt);
when Iir_Kind_For_Loop_Statement =>
Synth_For_Loop_Statement (C, Stmt);
+ when Iir_Kind_While_Loop_Statement =>
+ Synth_While_Loop_Statement (C, Stmt);
when Iir_Kind_Null_Statement =>
-- Easy
null;