create_simple(link_class, endpoint_class, connector_type, class_desc, basename = None, help_categories = [])
from link_components import create_simple class datagram_link( create_simple(link_class = 'datagram_link_impl', endpoint_class = 'datagram_link_endpoint', connector_type = 'datagram-link', class_desc = "datagram link", basename = 'datagram_link')): """The datagram link component creates a datagram-link, which is a simple broadcast bus forwarding messages (as sequences of bytes) from a sender device to all other devices present of the link. The datagram-link is both an example of how to build a link with the Simics Link Library, and a simple broadcast link that can be reused when multi-cell communication between devices is necessary. Refer to the <cite>Link Library Programming Guide</cite> for more information."""
class ethernet_switch(link_components.link_component): """Ethernet switch: this component represents a switched Ethernet network, allowing any number of devices to connect and optimizing the packet routing according to what is learned about the MAC addresses talking on the link.""" _class_desc = 'an Ethernet switch component' _help_categories = ['Ethernet'] class basename(link_components.link_component.basename): val = 'ethernet_switch' def create_unconnected_endpoint(self, cnt): return create_vlan_switch_endpoint(self.get_slot('link'), None, None, True) def register_connector_templates(self): self.eth_tmpl = self.add_link_connector_template( name = 'ethernet-link-connector', type = 'ethernet-link', growing = True, create_unconnected_endpoint = self.create_unconnected_endpoint) def add_objects(self): self.add_pre_obj_with_name('link', 'eth-switch-link', self.get_link_object_name(), goal_latency = self.goal_latency.val, global_id = self.global_id.val) self.add_link_connector('device', self.eth_tmpl)
add_link_connector(self, slot_template, cnt_tmpl)
class ethernet_switch(link_components.link_component): """Ethernet switch: this component represents a switched Ethernet network, allowing any number of devices to connect and optimizing the packet routing according to what is learned about the MAC addresses talking on the link.""" _class_desc = 'an Ethernet switch component' _help_categories = ['Ethernet'] class basename(link_components.link_component.basename): val = 'ethernet_switch' def create_unconnected_endpoint(self, cnt): return create_vlan_switch_endpoint(self.get_slot('link'), None, None, True) def register_connector_templates(self): self.eth_tmpl = self.add_link_connector_template( name = 'ethernet-link-connector', type = 'ethernet-link', growing = True, create_unconnected_endpoint = self.create_unconnected_endpoint) def add_objects(self): self.add_pre_obj_with_name('link', 'eth-switch-link', self.get_link_object_name(), goal_latency = self.goal_latency.val, global_id = self.global_id.val) self.add_link_connector('device', self.eth_tmpl)
add_link_connector_template(self, name, type, growing, create_unconnected_endpoint, get_check_data = None, get_connect_data = None, check = None, connect = None, disconnect = None, allow_new_cnt = lambda: True, allow_destroy_cnt = lambda: True)
True
(connection accepted) or False
(connection refused).
The standard implementation returns always True
.True
(new connector allowed) or False
(no new connector). The default function always returns
True
(unlimited number of connectors allowed, with
always one free).True
(destroy the connector) or False
(let the connector). The endpoint object associated will be
automatically destroyed with the connector, or replaced if the
connector is left. The default function returns always
True
(unlimited number of connectors allowed, with
always one free).class ethernet_cable(link_components.link_component): """Ethernet cable: this component represents a two-points Ethernet cable, allowing two devices to connect to each other.""" _class_desc = 'an Ethernet cable component' _help_categories = ['Ethernet'] class basename(link_components.link_component.basename): val = 'ethernet_cable' class connector_count(SimpleAttribute(0, 'i')): """Total number of occupied connectors""" def allow_new_connector(self): if self.connector_count.val == 2: # all connectors are occupied return False elif self.connector_count.val == 1: # there is already one free connector self.connector_count.val += 1 return False else: self.connector_count.val += 1 return True def allow_destroy_connector(self): if self.connector_count.val == 2: # two connectors occupied, so let one become free self.connector_count.val -= 1 return False else: # one connector was occupied, one free, so destroy one self.connector_count.val -= 1 return True def create_unconnected_endpoint(self, cnt): return create_cable_endpoint(self.get_slot('link'), None) def register_connector_templates(self): self.eth_tmpl = self.add_link_connector_template( name = 'single-ethernet-link-connector', type = 'ethernet-link', growing = True, create_unconnected_endpoint = self.create_unconnected_endpoint, allow_new_cnt = self.allow_new_connector, allow_destroy_cnt = self.allow_destroy_connector) def add_objects(self): self.add_pre_obj_with_name('link', 'eth-cable-link', self.get_link_object_name(), goal_latency = self.goal_latency.val, global_id = self.global_id.val) self.add_link_connector('device', self.eth_tmpl)
add_objects(self)
class ethernet_switch(link_components.link_component): """Ethernet switch: this component represents a switched Ethernet network, allowing any number of devices to connect and optimizing the packet routing according to what is learned about the MAC addresses talking on the link.""" _class_desc = 'an Ethernet switch component' _help_categories = ['Ethernet'] class basename(link_components.link_component.basename): val = 'ethernet_switch' def create_unconnected_endpoint(self, cnt): return create_vlan_switch_endpoint(self.get_slot('link'), None, None, True) def register_connector_templates(self): self.eth_tmpl = self.add_link_connector_template( name = 'ethernet-link-connector', type = 'ethernet-link', growing = True, create_unconnected_endpoint = self.create_unconnected_endpoint) def add_objects(self): self.add_pre_obj_with_name('link', 'eth-switch-link', self.get_link_object_name(), goal_latency = self.goal_latency.val, global_id = self.global_id.val) self.add_link_connector('device', self.eth_tmpl)
get_link_object_name(self)
class ethernet_switch(link_components.link_component): """Ethernet switch: this component represents a switched Ethernet network, allowing any number of devices to connect and optimizing the packet routing according to what is learned about the MAC addresses talking on the link.""" _class_desc = 'an Ethernet switch component' _help_categories = ['Ethernet'] class basename(link_components.link_component.basename): val = 'ethernet_switch' def create_unconnected_endpoint(self, cnt): return create_vlan_switch_endpoint(self.get_slot('link'), None, None, True) def register_connector_templates(self): self.eth_tmpl = self.add_link_connector_template( name = 'ethernet-link-connector', type = 'ethernet-link', growing = True, create_unconnected_endpoint = self.create_unconnected_endpoint) def add_objects(self): self.add_pre_obj_with_name('link', 'eth-switch-link', self.get_link_object_name(), goal_latency = self.goal_latency.val, global_id = self.global_id.val) self.add_link_connector('device', self.eth_tmpl)
register_connector_templates(self)
class ethernet_switch(link_components.link_component): """Ethernet switch: this component represents a switched Ethernet network, allowing any number of devices to connect and optimizing the packet routing according to what is learned about the MAC addresses talking on the link.""" _class_desc = 'an Ethernet switch component' _help_categories = ['Ethernet'] class basename(link_components.link_component.basename): val = 'ethernet_switch' def create_unconnected_endpoint(self, cnt): return create_vlan_switch_endpoint(self.get_slot('link'), None, None, True) def register_connector_templates(self): self.eth_tmpl = self.add_link_connector_template( name = 'ethernet-link-connector', type = 'ethernet-link', growing = True, create_unconnected_endpoint = self.create_unconnected_endpoint) def add_objects(self): self.add_pre_obj_with_name('link', 'eth-switch-link', self.get_link_object_name(), goal_latency = self.goal_latency.val, global_id = self.global_id.val) self.add_link_connector('device', self.eth_tmpl)