summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'ast-to-instr/src/VHDLComponent.java')
-rw-r--r--ast-to-instr/src/VHDLComponent.java191
1 files changed, 178 insertions, 13 deletions
diff --git a/ast-to-instr/src/VHDLComponent.java b/ast-to-instr/src/VHDLComponent.java
index a9f2cae..2d594f1 100644
--- a/ast-to-instr/src/VHDLComponent.java
+++ b/ast-to-instr/src/VHDLComponent.java
@@ -11,9 +11,13 @@ public class VHDLComponent extends ParsableXML
{
private static final XPathExpression XPE_FIND_INST_UNIT;
private static final XPathExpression XPE_FIND_BASE_NAME;
+ private static final XPathExpression XPE_FIND_ENTITY_NAME;
+ private static final XPathExpression XPE_FIND_LIBRARY_NAME;
private static final XPathExpression XPE_FIND_PORT_MAPS;
private static final XPathExpression XPE_FIND_REAL_PORTS;
+ private static final XPathExpression XPE_FIND_ACTUAL_NE;
+ private static final XPathExpression XPE_FIND_FORMAL;
private static final XPathExpression XPE_FIND_GENERIC_MAPS;
@@ -22,10 +26,21 @@ public class VHDLComponent extends ParsableXML
XPE_FIND_INST_UNIT = XMLManager.compile_or_die("./instantiated_unit");
XPE_FIND_BASE_NAME = XMLManager.compile_or_die("./base_name");
+ XPE_FIND_ENTITY_NAME = XMLManager.compile_or_die
+ (
+ "./entity_name[@kind=\"selected_name\"]"
+ );
+
+ XPE_FIND_LIBRARY_NAME = XMLManager.compile_or_die
+ (
+ "./prefix[@kind=\"simple_name\"]"
+ );
+
XPE_FIND_PORT_MAPS =
XMLManager.compile_or_die
(
- "./el[@kind=\"association_element_by_expression\"]"
+ "./port_map_aspect_chain/el"
+ + "[@kind=\"association_element_by_expression\"]"
);
XPE_FIND_REAL_PORTS =
@@ -34,6 +49,9 @@ public class VHDLComponent extends ParsableXML
"./port_chain/el[@kind=\"interface_signal_declaration\"]"
);
+ XPE_FIND_ACTUAL_NE = XMLManager.compile_or_die("./actual/named_entity");
+ XPE_FIND_FORMAL = XMLManager.compile_or_die("./formal");
+
XPE_FIND_GENERIC_MAPS = null; /* TODO */
}
@@ -55,6 +73,7 @@ public class VHDLComponent extends ParsableXML
{
final String xml_id;
final IDs local_id;
+ final Node linked_entity;
xml_id = XMLManager.get_attribute(xml_node, "id");
@@ -62,7 +81,7 @@ public class VHDLComponent extends ParsableXML
/** Parent **************************************************************/
handle_link_to_architecture(local_id);
- handle_link_to_entity(local_id);
+ linked_entity = handle_link_to_entity(local_id);
/** Functions ***********************************************************/
handle_function_line(local_id);
@@ -70,8 +89,12 @@ public class VHDLComponent extends ParsableXML
handle_function_label(local_id);
/** Predicates **********************************************************/
- handle_predicate_port_maps(local_id);
- handle_predicate_generic_maps(local_id);
+
+ if (linked_entity != (Node) null)
+ {
+ handle_predicate_port_maps(local_id, linked_entity);
+ handle_predicate_generic_maps(local_id, linked_entity);
+ }
}
/***************************************************************************/
@@ -129,12 +152,50 @@ public class VHDLComponent extends ParsableXML
return
(Node) current_query.evaluate
(
- current_node,
+ Main.get_xml_root(),
+ XPathConstants.NODE
+ );
+ }
+
+ private Node find_entity_from_direct_ref (final Node source_node)
+ throws XPathExpressionException
+ {
+ final XPathExpression xpe_get_matching_entity;
+ final Node entity_ref, library_ref;
+
+ entity_ref =
+ (Node) XPE_FIND_ENTITY_NAME.evaluate
+ (
+ source_node,
+ XPathConstants.NODE
+ );
+
+ library_ref =
+ (Node) XPE_FIND_ENTITY_NAME.evaluate
+ (
+ entity_ref,
+ XPathConstants.NODE
+ );
+
+ xpe_get_matching_entity =
+ XMLManager.compile_or_die
+ (
+ "./el[@kind=\"library_declaration\"][@identifier=\""
+ + XMLManager.get_attribute(library_ref, "identifier")
+ + "\"]//library_unit[@kind=\"entity_declaration\"][@identifier=\""
+ + XMLManager.get_attribute(entity_ref, "identifier")
+ + "\"]"
+ );
+
+ return
+ (Node) xpe_get_matching_entity.evaluate
+ (
+ Main.get_xml_root(),
XPathConstants.NODE
);
}
- private void handle_link_to_entity
+ private Node handle_link_to_entity
(
final IDs local_id
)
@@ -158,8 +219,7 @@ public class VHDLComponent extends ParsableXML
}
else if (kind.equals("entity_aspect_entity"))
{
- /* TODO */
- //current_node = find_entity_from_external_ref(current_node);
+ current_node = find_entity_from_direct_ref(current_node);
}
else
{
@@ -172,7 +232,7 @@ public class VHDLComponent extends ParsableXML
+ ")."
);
- return;
+ return null;
}
if (current_node == (Node) null)
@@ -186,7 +246,7 @@ public class VHDLComponent extends ParsableXML
+ ")."
);
- return;
+ return null;
}
Predicates.add_entry
@@ -199,6 +259,8 @@ public class VHDLComponent extends ParsableXML
"entity"
)
);
+
+ return current_node;
}
/***************************************************************************/
@@ -257,16 +319,119 @@ public class VHDLComponent extends ParsableXML
/***************************************************************************/
private void handle_predicate_port_maps
(
- final IDs local_id
+ final IDs local_id,
+ final Node linked_entity
)
+ throws XPathExpressionException
{
- /* TODO */
+ final NodeList port_maps, real_ports;
+ final int port_maps_length;
+
+ port_maps =
+ (NodeList) XPE_FIND_PORT_MAPS.evaluate
+ (
+ xml_node,
+ XPathConstants.NODESET
+ );
+
+ real_ports =
+ (NodeList) XPE_FIND_REAL_PORTS.evaluate
+ (
+ linked_entity,
+ XPathConstants.NODESET
+ );
+
+ port_maps_length = port_maps.getLength();
+
+ for (int i = 0; i < port_maps_length; ++i)
+ {
+ final Node mapping, formal_name, actual_waveform;
+
+ mapping = port_maps.item(i);
+
+ actual_waveform =
+ (Node) XPE_FIND_ACTUAL_NE.evaluate
+ (
+ mapping,
+ XPathConstants.NODE
+ );
+
+ formal_name =
+ (Node) XPE_FIND_FORMAL.evaluate
+ (
+ mapping,
+ XPathConstants.NODE
+ );
+
+ if (formal_name == null)
+ {
+ Predicates.add_entry
+ (
+ "port_maps",
+ local_id,
+ Waveforms.get_associated_waveform_id
+ (
+ IDs.get_id_from_xml_id
+ (
+ XMLManager.get_attribute(actual_waveform, "ref"),
+ null
+ )
+ ),
+ IDs.get_id_from_xml_id
+ (
+ XMLManager.get_attribute(real_ports.item(i), "id"),
+ "port"
+ )
+ );
+ }
+ else
+ {
+ final XPathExpression xpe_find_true_port;
+ final Node true_port;
+
+ xpe_find_true_port =
+ XMLManager.compile_or_die
+ (
+ "./port_chain/el[@identifier=\""
+ + XMLManager.get_attribute(formal_name, "identifier")
+ + "\"]"
+ );
+
+ true_port =
+ (Node) xpe_find_true_port.evaluate
+ (
+ linked_entity,
+ XPathConstants.NODE
+ );
+
+ Predicates.add_entry
+ (
+ "port_maps",
+ local_id,
+ Waveforms.get_associated_waveform_id
+ (
+ IDs.get_id_from_xml_id
+ (
+ XMLManager.get_attribute(actual_waveform, "ref"),
+ null
+ )
+ ),
+ IDs.get_id_from_xml_id
+ (
+ XMLManager.get_attribute(true_port, "id"),
+ "port"
+ )
+ );
+ }
+ }
}
private void handle_predicate_generic_maps
(
- final IDs local_id
+ final IDs local_id,
+ final Node linked_entity
)
+ throws XPathExpressionException
{
/* TODO */
}