From 18613ebacd6a10883f6769c4587ac0c2759e710e Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 15 Jun 2022 04:56:27 +0200 Subject: netlists-rename: handle handle signal instances. Fix #2093 --- src/synth/netlists-rename.adb | 19 ++++++++++++++++++- src/synth/netlists.adb | 6 ++++++ src/synth/netlists.ads | 5 ++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/synth/netlists-rename.adb b/src/synth/netlists-rename.adb index afa0e4c83..6523d7e2a 100644 --- a/src/synth/netlists-rename.adb +++ b/src/synth/netlists-rename.adb @@ -19,6 +19,9 @@ with Name_Table; with Std_Names; +with Netlists.Gates; use Netlists.Gates; +with Netlists.Utils; use Netlists.Utils; + package body Netlists.Rename is function Rename_Sname (Name : Sname; Lang : Language_Type) return Sname is @@ -76,6 +79,7 @@ package body Netlists.Rename is procedure Rename_User_Module (M : Module; Lang : Language_Type) is Port : Port_Desc; + Inst : Instance; begin -- Rename inputs and outputs. for I in 1 .. Get_Nbr_Inputs (M) loop @@ -89,7 +93,20 @@ package body Netlists.Rename is Set_Output_Desc (M, I - 1, Port); end loop; - -- rename instances ? + -- Rename instances + Inst := Get_First_Instance (M); + while Inst /= No_Instance loop + case Get_Id (Inst) is + when Id_Signal + | Id_Isignal => + Set_Instance_Name + (Inst, Rename_Sname (Get_Instance_Name (Inst), Lang)); + when others => + null; + end case; + Inst := Get_Next_Instance (Inst); + end loop; + -- rename module name ? -- rename parameters ? end Rename_User_Module; diff --git a/src/synth/netlists.adb b/src/synth/netlists.adb index f872606e2..3a5b0b3dd 100644 --- a/src/synth/netlists.adb +++ b/src/synth/netlists.adb @@ -721,6 +721,12 @@ package body Netlists is return Instances_Table.Table (Inst).Name; end Get_Instance_Name; + procedure Set_Instance_Name (Inst : Instance; Name : Sname) is + begin + pragma Assert (Is_Valid (Inst)); + Instances_Table.Table (Inst).Name := Name; + end Set_Instance_Name; + function Get_Instance_Parent (Inst : Instance) return Module is begin pragma Assert (Is_Valid (Inst)); diff --git a/src/synth/netlists.ads b/src/synth/netlists.ads index 661c2ae3d..5d2106608 100644 --- a/src/synth/netlists.ads +++ b/src/synth/netlists.ads @@ -253,6 +253,7 @@ package Netlists is function Get_Self_Instance (M : Module) return Instance; function Get_First_Instance (M : Module) return Instance; + function Get_Next_Instance (Inst : Instance) return Instance; -- Linked list of sub-modules. -- Use Modules to iterate. @@ -280,7 +281,6 @@ package Netlists is function Get_Instance_Parent (Inst : Instance) return Module; function Get_Output (Inst : Instance; Idx : Port_Idx) return Net; function Get_Input (Inst : Instance; Idx : Port_Idx) return Input; - function Get_Next_Instance (Inst : Instance) return Instance; function Get_Param_Uns32 (Inst : Instance; Param : Param_Idx) return Uns32; procedure Set_Param_Uns32 (Inst : Instance; Param : Param_Idx; Val : Uns32); @@ -470,6 +470,9 @@ private procedure Set_Next_Instance (Inst : Instance; Next : Instance); procedure Set_Prev_Instance (Inst : Instance; Prev : Instance); + -- Used by Rename. + procedure Set_Instance_Name (Inst : Instance; Name : Sname); + -- Procedures to rewrite the list of instances of a module: -- * first extract the chain of instances from module M (and reset the -- list of instances - so there is none), -- cgit v1.2.3