diff options
| author | Tristan Gingold <tgingold@free.fr> | 2019-11-01 18:45:54 +0100 | 
|---|---|---|
| committer | Tristan Gingold <tgingold@free.fr> | 2019-11-01 18:45:54 +0100 | 
| commit | a4b5dd0fb373bf785abfc1f6666ce8d6a32a6e08 (patch) | |
| tree | 34b89267870865f41946735c3bce8000f5ebaa73 | |
| parent | c4cdce922e246bdd41a8f405bc28846333385aba (diff) | |
| download | ghdl-a4b5dd0fb373bf785abfc1f6666ce8d6a32a6e08.tar.gz ghdl-a4b5dd0fb373bf785abfc1f6666ce8d6a32a6e08.tar.bz2 ghdl-a4b5dd0fb373bf785abfc1f6666ce8d6a32a6e08.zip | |
synth: handle nested if generate statements.
| -rw-r--r-- | src/synth/synth-insts.adb | 2 | ||||
| -rw-r--r-- | src/synth/synth-stmts.adb | 48 | 
2 files changed, 29 insertions, 21 deletions
| diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb index 69af4a015..62229a85b 100644 --- a/src/synth/synth-insts.adb +++ b/src/synth/synth-insts.adb @@ -798,8 +798,10 @@ package body Synth.Insts is     is        Item : Node;     begin +      --  Be sure CFG applies to BLK.        pragma Assert (Get_Block_From_Block_Specification                         (Get_Block_Specification (Cfg)) = Blk); +        Item := Get_Configuration_Item_Chain (Cfg);        while Item /= Null_Node loop           case Get_Kind (Item) is diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index 819413c93..cd4ef9a97 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -2321,6 +2321,32 @@ package body Synth.Stmts is        Instance_Pool := Prev_Instance_Pool;     end Synth_Generate_Statement_Body; +   procedure Synth_If_Generate_Statement +     (Syn_Inst : Synth_Instance_Acc; Stmt : Node) +   is +      Gen : Node; +      Bod : Node; +      Cond : Value_Acc; +      Name : Sname; +   begin +      Gen := Stmt; +      Name := New_Sname (Get_Sname (Syn_Inst), +                         Get_Identifier (Stmt)); +      loop +         Cond := Synth_Expression (Syn_Inst, Get_Condition (Gen)); +         pragma Assert (Cond.Kind = Value_Discrete); +         if Cond.Scal = 1 then +            Bod := Get_Generate_Statement_Body (Gen); +            Apply_Block_Configuration +              (Get_Generate_Block_Configuration (Bod), Bod); +            Synth_Generate_Statement_Body (Syn_Inst, Bod, Name); +            exit; +         end if; +         Gen := Get_Generate_Else_Clause (Gen); +         exit when Gen = Null_Node; +      end loop; +   end Synth_If_Generate_Statement; +     procedure Synth_For_Generate_Statement       (Syn_Inst : Synth_Instance_Acc; Stmt : Node)     is @@ -2399,27 +2425,7 @@ package body Synth.Stmts is              Synth_Process_Statement (Syn_Inst, Stmt);              Pop_And_Merge_Phi (Build_Context, Stmt);           when Iir_Kind_If_Generate_Statement => -            declare -               Gen : Node; -               Bod : Node; -               Cond : Value_Acc; -               Name : Sname; -            begin -               Gen := Stmt; -               Name := New_Sname (Get_Sname (Syn_Inst), -                                  Get_Identifier (Stmt)); -               loop -                  Cond := Synth_Expression (Syn_Inst, Get_Condition (Gen)); -                  pragma Assert (Cond.Kind = Value_Discrete); -                  if Cond.Scal = 1 then -                     Bod := Get_Generate_Statement_Body (Gen); -                     Synth_Generate_Statement_Body (Syn_Inst, Bod, Name); -                     exit; -                  end if; -                  Gen := Get_Generate_Else_Clause (Gen); -                  exit when Gen = Null_Node; -               end loop; -            end; +            Synth_If_Generate_Statement (Syn_Inst, Stmt);           when Iir_Kind_For_Generate_Statement =>              Synth_For_Generate_Statement (Syn_Inst, Stmt);           when Iir_Kind_Component_Instantiation_Statement => | 
