byucc.jhdl.platforms.util
Class ConnectionTemplate

java.lang.Object
  extended bybyucc.jhdl.platforms.util.ConnectionTemplate
All Implemented Interfaces:
UtilConstants

public class ConnectionTemplate
extends java.lang.Object
implements UtilConstants

This class is used to create a template for connections which are made multiple times when hooking up the components on a board. This class is designed to do point to point connections only (only two cells).

You declare connections giving port names only. Cell names are supplied when the template is actually used to wire ports together. You may embed tags in the port names (denoted as %0%, %1%, etc) that can have strings substituted at association time. At association time, the user will pass an array of Strings to the call. The String at index 0 will be substituted for the tag %0%, index 1 for %1%, etc. This allows more generic templates to be created.

As an example, say there are 4 memories to hooked up to each processing element. The template could be defined as follows.

   ConnectionTemplate mem2pe = new ConnectionTemplate();
   mem2pe.addConnection(64,"Mem%1%Data","Data","PE%0%_Mem%1%Data");
   mem2pe.addConnection(20,"Mem%1%Addr","Addr","PE%0%_Mem%1%Addr");
   mem2pe.addConnection(1,"Mem%1%Write_n","Write_n","PE%0%_Mem%1%Write_n");
   mem2pe.addConnection(1,"Mem%1%Read_n","Read_n","PE%0%_Mem%1%Read_n");
   
Now say there are 2 PEs (for the example, 1 and 2). You would send the following 2D String array to the connectTemplate() call in GenericBoard.
   String memConnects[][] = { { "1", "0" },
                              { "1", "1" },
                              { "1", "2" },
                              { "1", "3" },
                              { "2", "0" },
                              { "2", "1" },
                              { "2", "2" },
                              { "2", "3" } };
   
The call to the method would need to be made as follows (assuming the cells were declared with the proper names):
   mem2pe.makeConnections(board,"pe%0%","pe%0%_Memory%1%",memConnects);
   
Chosing the first connection only, this would wire the following ports, with the specified wire. So, this sequence of calls would create 32 connections.

See Also:
GenericBoard

Field Summary
 
Fields inherited from interface byucc.jhdl.platforms.util.UtilConstants
directions, IN, NONE, OUT, TRISTATE, UNASSIGNED
 
Constructor Summary
ConnectionTemplate()
          Creates a new ConnectionTemplate and initializes its data structures.
ConnectionTemplate(ConnectionTemplate template)
          Copies an existing connection template.
 
Method Summary
 void addConnection(int width, java.lang.String cell1_port, java.lang.String cell2_port, java.lang.String wirename)
          Adds a connection to the template.
 ConnectionTemplate copy()
          Creates a copy of itself.
 java.lang.String getPort1(int index)
          Get the port1 at the specified index.
 java.lang.String getPort2(int index)
          Get the port2 at the specified index.
 java.lang.String getWireName(int index)
          Get the wire name at the specified index.
static void main(java.lang.String[] args)
           
 void makeConnections(GenericBoard board, java.lang.String cell1, java.lang.String cell2, java.lang.String[][] subs)
          This will connect all the ports defined in template.
static java.lang.String substitute(java.lang.String name, java.lang.String[] subs)
          This method will parse the String "name" and substitute the values in the array for the substitution tags.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionTemplate

public ConnectionTemplate()
Creates a new ConnectionTemplate and initializes its data structures.


ConnectionTemplate

public ConnectionTemplate(ConnectionTemplate template)
Copies an existing connection template.

Method Detail

copy

public ConnectionTemplate copy()
Creates a copy of itself.

Returns:
Copy of the current ConnectionTemplate

getPort1

public java.lang.String getPort1(int index)
Get the port1 at the specified index.

Parameters:
index - Index of the port to return.
Returns:
Port name at the specified index.

getPort2

public java.lang.String getPort2(int index)
Get the port2 at the specified index.

Parameters:
index - Index of the port to return.
Returns:
Port name at the specified index.

getWireName

public java.lang.String getWireName(int index)
Get the wire name at the specified index.

Parameters:
index - Index of the wire name to return.
Returns:
Wire name at the specified index.

addConnection

public void addConnection(int width,
                          java.lang.String cell1_port,
                          java.lang.String cell2_port,
                          java.lang.String wirename)
Adds a connection to the template.

Parameters:
width - Width of the connection.
cell1_port - String describing the template for the port on cell1.
cell2_port - String describing the template for the port on cell2. This may be set to null for single-ended connections.
wirename - Name of the wire which will connect the ports. The user must be careful to ensure that after expansion, the wirenames will all be unique.

substitute

public static java.lang.String substitute(java.lang.String name,
                                          java.lang.String[] subs)
This method will parse the String "name" and substitute the values in the array for the substitution tags.

Parameters:
name - String to parse.
subs - Strings to substitute into name.

makeConnections

public void makeConnections(GenericBoard board,
                            java.lang.String cell1,
                            java.lang.String cell2,
                            java.lang.String[][] subs)
This will connect all the ports defined in template.

Parameters:
board - GenericBoard which will get all the connection info.
cell1 - Cell name (as declared in a declareCell() call) of cell1. This name can include substitution tags (%0%, %1%, etc).
cell2 - Cell name (as declared in a declareCell() call) of cell2. This name can include substitution tags (%0%, %1%, etc). May pass in null to this argument for single-ended connections.
subs - Strings to substitute for the substitution tags declared in the ConnectionTemplate and in the cell names. The outer array is used to declare multiple connections. The inner array declares the actual substitutions. The string at ndex 0 is substituted for %0%, index 1 for %1%, etc.
See Also:
ConnectionTemplate

main

public static void main(java.lang.String[] args)

toString

public java.lang.String toString()


Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.