aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-05-23 17:48:54 +0200
committerTristan Gingold <tgingold@free.fr>2020-05-23 17:48:54 +0200
commitef0164a6e0bb466c29bf6d9abba0d315b0ae9fd3 (patch)
tree6fee721718021ee0fd46be590b73f85967df71b4 /src/synth/netlists.adb
parent5ebeb5e2277b550b12614642522fd1c86fd580b0 (diff)
downloadghdl-ef0164a6e0bb466c29bf6d9abba0d315b0ae9fd3.tar.gz
ghdl-ef0164a6e0bb466c29bf6d9abba0d315b0ae9fd3.tar.bz2
ghdl-ef0164a6e0bb466c29bf6d9abba0d315b0ae9fd3.zip
netlists: complete support of attributes. For #1318
Diffstat (limited to 'src/synth/netlists.adb')
-rw-r--r--src/synth/netlists.adb67
1 files changed, 65 insertions, 2 deletions
diff --git a/src/synth/netlists.adb b/src/synth/netlists.adb
index 807d53298..59c77e831 100644
--- a/src/synth/netlists.adb
+++ b/src/synth/netlists.adb
@@ -479,7 +479,8 @@ package body Netlists is
end if;
Instances_Table.Table (Res) := ((Parent => Parent,
- Flag3 | Flag4 => False,
+ Has_Attr => False,
+ Flag4 => False,
Next_Instance => No_Instance,
Prev_Instance => No_Instance,
Klass => M,
@@ -1213,6 +1214,9 @@ package body Netlists is
Attribute_Maps.Init (Module_Rec.Attrs.all);
end if;
+ -- There is now at least one attribute for INST.
+ Instances_Table.Table (Inst).Has_Attr := True;
+
Attribute_Maps.Get_Index (Module_Rec.Attrs.all, Inst, Idx);
Prev := Attribute_Maps.Get_Value (Module_Rec.Attrs.all, Idx);
@@ -1225,6 +1229,64 @@ package body Netlists is
Attribute_Maps.Set_Value (Module_Rec.Attrs.all, Idx, Attr);
end Set_Attribute;
+ function Get_Attributes (M : Module) return Attribute_Map_Acc is
+ begin
+ return Modules_Table.Table (M).Attrs;
+ end Get_Attributes;
+
+ function Get_First_Attribute (Inst : Instance) return Attribute
+ is
+ pragma Assert (Is_Valid (Inst));
+ begin
+ if not Instances_Table.Table (Inst).Has_Attr then
+ return No_Attribute;
+ end if;
+ declare
+ M : constant Module := Get_Instance_Parent (Inst);
+ Attrs : constant Attribute_Map_Acc := Get_Attributes (M);
+ Idx : Attribute_Maps.Index_Type;
+ Res : Attribute;
+ begin
+ pragma Assert (Attrs /= null);
+ Attribute_Maps.Get_Index (Attrs.all, Inst, Idx);
+ Res := Attribute_Maps.Get_Value (Attrs.all, Idx);
+ return Res;
+ end;
+ end Get_First_Attribute;
+
+ function Is_Valid (Attr : Attribute) return Boolean is
+ begin
+ return Attr > No_Attribute and then Attr <= Attributes_Table.Last;
+ end Is_Valid;
+
+ function Get_Attribute_Name (Attr : Attribute) return Name_Id
+ is
+ pragma Assert (Is_Valid (Attr));
+ begin
+ return Attributes_Table.Table (Attr).Name;
+ end Get_Attribute_Name;
+
+ function Get_Attribute_Type (Attr : Attribute) return Param_Type
+ is
+ pragma Assert (Is_Valid (Attr));
+ begin
+ return Attributes_Table.Table (Attr).Typ;
+ end Get_Attribute_Type;
+
+ function Get_Attribute_Pval (Attr : Attribute) return Pval
+ is
+ pragma Assert (Is_Valid (Attr));
+ begin
+ return Attributes_Table.Table (Attr).Val;
+ end Get_Attribute_Pval;
+
+ function Get_Attribute_Next (Attr : Attribute) return Attribute
+ is
+ pragma Assert (Is_Valid (Attr));
+ begin
+ return Attributes_Table.Table (Attr).Chain;
+ end Get_Attribute_Next;
+
-- Statistics
function Count_Free_Inputs (Head : Input) return Natural
@@ -1384,7 +1446,8 @@ begin
pragma Assert (Modules_Table.Last = Free_Module);
Instances_Table.Append ((Parent => No_Module,
- Flag3 | Flag4 => False,
+ Has_Attr => False,
+ Flag4 => False,
Next_Instance => No_Instance,
Prev_Instance => No_Instance,
Klass => No_Module,