diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-03-17 18:45:06 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-03-17 18:45:06 +0100 |
commit | 4be07f298050ec2de183be699ad7e9650b5b5b9c (patch) | |
tree | 699e323a89e4b51bcd251b68b2284efdd864f2b6 | |
parent | 0d8f155d3c9e5413a42984f0f290c71ab89a71ba (diff) | |
download | ghdl-4be07f298050ec2de183be699ad7e9650b5b5b9c.tar.gz ghdl-4be07f298050ec2de183be699ad7e9650b5b5b9c.tar.bz2 ghdl-4be07f298050ec2de183be699ad7e9650b5b5b9c.zip |
netlists: do not remove net gates that have an attribute
-rw-r--r-- | src/synth/netlists-cleanup.adb | 45 | ||||
-rw-r--r-- | src/synth/netlists.adb | 7 | ||||
-rw-r--r-- | src/synth/netlists.ads | 9 |
3 files changed, 36 insertions, 25 deletions
diff --git a/src/synth/netlists-cleanup.adb b/src/synth/netlists-cleanup.adb index 22f02b761..2f741e3f3 100644 --- a/src/synth/netlists-cleanup.adb +++ b/src/synth/netlists-cleanup.adb @@ -128,29 +128,32 @@ package body Netlists.Cleanup is | Id_Port | Id_Enable | Id_Nop => - declare - Inp : Input; - In_Drv : Net; - O : Net; - begin - Inp := Get_Input (Inst, 0); - In_Drv := Get_Driver (Inp); - O := Get_Output (Inst, 0); - if In_Drv /= No_Net then - -- Only when the output is driven. - Disconnect (Inp); - Redirect_Inputs (O, In_Drv); - else - Disconnect (Get_First_Sink (O)); - end if; + -- Keep gates with an attribute. + if not Has_Attribute (Inst) then + declare + Inp : Input; + In_Drv : Net; + O : Net; + begin + Inp := Get_Input (Inst, 0); + In_Drv := Get_Driver (Inp); + O := Get_Output (Inst, 0); + if In_Drv /= No_Net then + -- Only when the output is driven. + Disconnect (Inp); + Redirect_Inputs (O, In_Drv); + else + Disconnect (Get_First_Sink (O)); + end if; - if Get_Id (Inst) = Id_Ioutput then - -- Disconnect the initial value. - Disconnect (Get_Input (Inst, 1)); - end if; + if Get_Id (Inst) = Id_Ioutput then + -- Disconnect the initial value. + Disconnect (Get_Input (Inst, 1)); + end if; - Remove_Instance (Inst); - end; + Remove_Instance (Inst); + end; + end if; when others => null; end case; diff --git a/src/synth/netlists.adb b/src/synth/netlists.adb index 18ca51992..24c39df50 100644 --- a/src/synth/netlists.adb +++ b/src/synth/netlists.adb @@ -1232,11 +1232,16 @@ package body Netlists is return Modules_Table.Table (M).Attrs; end Get_Attributes; + function Has_Attribute (Inst : Instance) return Boolean is + begin + return Instances_Table.Table (Inst).Has_Attr; + end Has_Attribute; + function Get_First_Attribute (Inst : Instance) return Attribute is pragma Assert (Is_Valid (Inst)); begin - if not Instances_Table.Table (Inst).Has_Attr then + if not Has_Attribute (Inst) then return No_Attribute; end if; declare diff --git a/src/synth/netlists.ads b/src/synth/netlists.ads index 2f4c604e3..a516efee4 100644 --- a/src/synth/netlists.ads +++ b/src/synth/netlists.ads @@ -343,6 +343,9 @@ package Netlists is -- Get the next attribute for the same instance. function Get_Attribute_Next (Attr : Attribute) return Attribute; + -- Return True iff INST has at least one attribute. + function Has_Attribute (Inst : Instance) return Boolean; + -- Display some usage stats on the standard error. procedure Disp_Stats; private @@ -445,9 +448,9 @@ private type Instance_Record is record -- The instance is instantiated in Parent. - Parent : Module; - Has_Attr : Boolean; -- Set when there is at least one attribute. - Flag4 : Boolean; + Parent : Module; + Has_Attr : Boolean; -- Set when there is at least one attribute. + Flag4 : Boolean; -- Instances are in a doubly-linked list. Prev_Instance : Instance; |