Interfaces and buses / Networking / Switch_Four_X_One
Block Name: Switch_Four_X_One
- public class Switch_Four_X_One
- extends TypedAtomicActor
- This block has four input ports, for incoming data tokens, and one control port to select the output data path. If the value on the control port matches the Relative Address range (Relative Address 0 includes 0, 1, 2, 3 and Relative_Address 4 means 4, 5, 6, 7) in the Switch_Address parameter then the token on the four input token ports is placed on the Switch_output. If the value on the control port is outside the range, then the incoming token is placed on the no_output port. If two or more inputs arrive on separate ports before a control port value, the input port values are sent to switch_output port in the order of arrival for each control port value. If two arrive on a single port before the control value, then the first is overwritten. The input token can be of any data type (int, long, double, boolean, string, data structure).
- For example, if the Relative_Address is 0, then control token must be 0, 1, 2 or 3. The input token will be routed to the port 0, 1, 2 or 3 based on this control token value. If the control token is not one of these values, the input token is placed on the no_output port. If the Relative Address is 4-7 and the control value is 1, then the DS is placed on the no_output port. The address range support can extend from 0-31. The no_output port can be connected to the input port of another Four_X_One blocks. In this way, 8 blocks can be connected in cascade to create a 32 port system.
Note:It is not good model design to have multiple data arrive before control, as tokens can go to the wrong port. The best would be to have a queue with a field of the Data Structure designating the destination, then the dest stays with the token
zero_input
public TypedIOPort zero_input
- input port Zero for data tokens. This token can be of any data type (int, long, double, boolean, string, data structure).
one_input
public TypedIOPort one_input
- input port One for data tokens. This token can be of any data type (int, long, double, boolean, string, data structure).
two_input
public TypedIOPort two_input
- input port Twofor data tokens. This token can be of any data type (int, long, double, boolean, string, data structure).
three_input
public TypedIOPort three_input
- input port Three for data tokens. This token can be of any data type (int, long, double, boolean, string, data structure).
control
public TypedIOPort control
- Input port for control tokens, which selects the output based on the matching with the relative switch address. The type is integer.
switch_output
public TypedIOPort switch_output
- If the control port value is out of the Switch_Address range, then the incoming token is placed on this port. The type is same as input.
no_output
public TypedIOPort no_output
- If the control port value is out of the Switch_Address range, then the incoming token is placed on this port. The type is same as input.
Switch_Address_
public StringAttribute Switch_Address_
- The relative address operator. This is a string-valued attribute that defaults to "Relative Address = 0". If the Relative_Address = 0, then the acceptable control port values are 0, 1, 2, 3. If the address is 4, then values are 4, 5, 6, 7. This way, the address can be built for 32 from 0-31.
Created with the Personal Edition of HelpNDoc: News and information about help authoring tools and software