edu.byu.ece.edif.util.export.jhdl
Class Edi2JHDL

java.lang.Object
  extended by edu.byu.ece.edif.util.export.jhdl.Edi2JHDL

public class Edi2JHDL
extends java.lang.Object

This class is used to generate a JHDL circuit from an EDIF object. Generates a JHDL circuit for the designated EdifCellInstance.

TO-DO:

  1. Add property support
  2. Modify according to coding standard

Version:
$Id: Edi2JHDL.java 44 2008-05-10 14:08:30Z mrspud $
Author:
Welson Sun, Tyler Anderson

Field Summary
static java.lang.String EDIF_CELL_INSTANCE_PROPERTY
          The JHDL Cell property name used for holding original EDIF instance object.
static java.lang.String EDIF_NET_PROPERTY
          The JHDL Net property name used for holding original EDIF EDIFNet.
private  java.lang.String technology
          the targeting technology name *
 
Constructor Summary
Edi2JHDL(java.lang.String techName)
          Constructs an Edi2JHDL Object with the specified name.
 
Method Summary
protected  java.lang.String _getPropertyINITString(EdifCellInstance leafCell, java.lang.String initDefault, java.lang.String initString, int argSize, int initPos, int initDepth, java.lang.Class[] arg_class, java.lang.Object[] args)
          It is important to retrieve INIT strings from the EDIF file to pass to JHDL constructors.
protected  void addCellInstanceProperties(EdifCellInstance cellInst, byucc.jhdl.base.Cell cell, boolean addEdifCellInstanceAsProperty)
          Add properties to the JHDL Cell according to the EdifCellInstance.
protected  void addNetProperties(EdifNet net, byucc.jhdl.base.Wire wire, boolean addEdifCellInstanceAsProperty)
           
private  boolean containsPortName(EdifCell cell, java.lang.String portName)
          Returns true if the EdifCell contains a port with named after the given String.
protected  byucc.jhdl.base.Cell createBlackBoxModel(byucc.jhdl.base.Cell parent, EdifCellInstance cellInstance, byucc.jhdl.base.Wire[] portWires, boolean addEdifCellInstanceAsProperty)
          Create a black box for the EDIF cell that is not in the JHDL library.
 java.util.Map createInstanceToPortRefArrayMap(EdifCell parent, EdifCellInstance mapInst)
          This method creates a mapping between an EdifCellInstance and all its corresponding EdifPortRefs.
 java.util.Map createInstanceToPortRefArrayMapDebug(EdifCell parent, EdifCellInstance thisInst, boolean debug)
          Instances to Mapping of Ports to portRef array *
protected  void createLeafCell(byucc.jhdl.base.Cell parent, EdifCellInstance leafCell, java.util.ArrayList wires, boolean addEdifCellInstanceAsProperty)
          Create the leaf cell as the sub cell of the parent cell.
protected  void createSubCellWires(EdifCellInstance subcell, EdifCellInstance parentCell, java.util.ArrayList wires, byucc.jhdl.base.Cell jhdlInstance, java.util.HashMap internalWires, java.util.Map instToMap)
          Creates an ArrayList of JHDL Wire Objects to connect with the ports of the sub cell.
 java.util.HashMap getMatchingPorts(EdifCell xilinxCell, EdifCell actualCell)
          This method will search through the EdifPorts of two EdifCells and looks for ports with the same 'base name'.
protected  java.lang.String getNetNameFromPort(EdifPort port, int busMember, EdifCellInstance subCellInstance, java.util.Map instToMap)
          Get the connected net name that the port (can be a bus port member also) of the subCellInstance connects to in the nets of the parent CellInstance.
 boolean isAlmostSameEdifCell(EdifCell xilinxCell, EdifCell actualCell)
          This method compares EdifPorts from two EdifCells to determine if they are the same.
 boolean isSameEdifCell(EdifCell xilinxCell, EdifCell actualCell)
          This method compares EdifPorts from two EdifCells to determine if they are the same.
static java.lang.String JHDL_ID(java.lang.String id)
          This method will change a name to a JHDL qualified name.
private static int parseMemDepth(java.lang.String name)
          Method used to parse the depth of the ram or rom (in ramMxN its the number associated with 'N'.
private static java.lang.String parseMemMxNPropertyLength(java.lang.String name)
          In ramMxN, this method returns the 'M' for ram or roms.
 byucc.jhdl.base.Cell toJHDLCircuit(byucc.jhdl.base.Cell parent, EdifCellInstance cellInstance, byucc.jhdl.base.Wire[] portWires)
           
 byucc.jhdl.base.Cell toJHDLCircuit(byucc.jhdl.base.Cell parent, EdifCellInstance cellInstance, byucc.jhdl.base.Wire[] portWires, boolean addEdifObjectAsProperty)
          This method will create a JHDL Cell for an EdifCellInstance object, as a sub JHDL Cell of the "parent" JHDL Cell, and connect all the passed in JHDL Wires to the created JHDL Cell's ports, and finally, it will return this created JHDL Cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EDIF_CELL_INSTANCE_PROPERTY

public static final java.lang.String EDIF_CELL_INSTANCE_PROPERTY
The JHDL Cell property name used for holding original EDIF instance object. In JHDL, the user can obtain a reference to the EDIFCellInstance object by querying this property. This property will only be added to the JHDL cell when the appropriate flags in the building methods are set.

See Also:
Constant Field Values

EDIF_NET_PROPERTY

public static final java.lang.String EDIF_NET_PROPERTY
The JHDL Net property name used for holding original EDIF EDIFNet. In JHDL, the user can obtain a reference to the EDIFNet object by querying this property. This property will only be added to the JHDL cell when the appropriate flags in the building methods are set.

See Also:
Constant Field Values

technology

private java.lang.String technology
the targeting technology name *

Constructor Detail

Edi2JHDL

public Edi2JHDL(java.lang.String techName)
Constructs an Edi2JHDL Object with the specified name.

Parameters:
techName - The technology for JHDL
Method Detail

createInstanceToPortRefArrayMapDebug

public java.util.Map createInstanceToPortRefArrayMapDebug(EdifCell parent,
                                                          EdifCellInstance thisInst,
                                                          boolean debug)
Instances to Mapping of Ports to portRef array *


createInstanceToPortRefArrayMap

public java.util.Map createInstanceToPortRefArrayMap(EdifCell parent,
                                                     EdifCellInstance mapInst)
This method creates a mapping between an EdifCellInstance and all its corresponding EdifPortRefs. The Returned Map has

For each key a Map value is returned. This map has

Parameters:
parent - - the parent EdifCell
mapInst - - the EdifCellInstance to create the Map from
Returns:

getMatchingPorts

public java.util.HashMap getMatchingPorts(EdifCell xilinxCell,
                                          EdifCell actualCell)
This method will search through the EdifPorts of two EdifCells and looks for ports with the same 'base name'. A HashMap is returned with the EdifPorts that are similar between the two EdifCells. The HashMap that is returned organizes the similar ports. The HashMap has:

This HashMap links the single multi-bit ports with the multiple single-bit ports.

Parameters:
xilinxCell - - 'xilinx' EdifCell
actualCell - - 'actual' EdifCell
Returns:
a HashMap linking similar ports

isAlmostSameEdifCell

public boolean isAlmostSameEdifCell(EdifCell xilinxCell,
                                    EdifCell actualCell)
This method compares EdifPorts from two EdifCells to determine if they are the same.

Parameters:
xilinxCell - - first EdifCell
actualCell - - second EdifCell
Returns:
- true if both have the same EdifPorts, else false

isSameEdifCell

public boolean isSameEdifCell(EdifCell xilinxCell,
                              EdifCell actualCell)
This method compares EdifPorts from two EdifCells to determine if they are the same.

Parameters:
xilinxCell - - first EdifCell
actualCell - - second EdifCell
Returns:
- true if both have the same EdifPorts, else false

JHDL_ID

public static java.lang.String JHDL_ID(java.lang.String id)
This method will change a name to a JHDL qualified name.

Parameters:
id - The String to make JHDL-valid
Returns:
A JHDL-valid String

toJHDLCircuit

public byucc.jhdl.base.Cell toJHDLCircuit(byucc.jhdl.base.Cell parent,
                                          EdifCellInstance cellInstance,
                                          byucc.jhdl.base.Wire[] portWires)

toJHDLCircuit

public byucc.jhdl.base.Cell toJHDLCircuit(byucc.jhdl.base.Cell parent,
                                          EdifCellInstance cellInstance,
                                          byucc.jhdl.base.Wire[] portWires,
                                          boolean addEdifObjectAsProperty)
This method will create a JHDL Cell for an EdifCellInstance object, as a sub JHDL Cell of the "parent" JHDL Cell, and connect all the passed in JHDL Wires to the created JHDL Cell's ports, and finally, it will return this created JHDL Cell.

Parameters:
parent - a Cell
cellInstance - an EdifCellInstance
portWires - a Wire[]
Returns:
a Cell

addCellInstanceProperties

protected void addCellInstanceProperties(EdifCellInstance cellInst,
                                         byucc.jhdl.base.Cell cell,
                                         boolean addEdifCellInstanceAsProperty)
Add properties to the JHDL Cell according to the EdifCellInstance. It retrieves the properties from the EdifCellInstance and adds them to the JHDL Cell as well.

Parameters:
cellInst - Takes all of this EdifCell's Property Objects, and adds them to the JHDL Cell
cell - The JHDL Cell that will get all of the EdifCell's Properties
addEdifCellInstanceAsProperty - If true, this flag adds a property to the JHDL cell whose key is held by the string EDIF_CELL_INSTANCE_PROPERTY, and whose value is an EdifCellInstance.

addNetProperties

protected void addNetProperties(EdifNet net,
                                byucc.jhdl.base.Wire wire,
                                boolean addEdifCellInstanceAsProperty)

createBlackBoxModel

protected byucc.jhdl.base.Cell createBlackBoxModel(byucc.jhdl.base.Cell parent,
                                                   EdifCellInstance cellInstance,
                                                   byucc.jhdl.base.Wire[] portWires,
                                                   boolean addEdifCellInstanceAsProperty)
Create a black box for the EDIF cell that is not in the JHDL library. This is done by Creating an empty JHDL Cell, EdifBlackBoxCell, inserting the ports, and connecting them to wires. On each clock, this black box cell will put 0s on each of it's out/inout wires.

Parameters:
parent - The parent cell to the black box cellInstance
cellInstance - The EdifCellInstance referring to a black box EdifCell
portWires - An ArrayList of Wire Objects
Returns:
A JHDL representation of the EdifCellInstance

createLeafCell

protected void createLeafCell(byucc.jhdl.base.Cell parent,
                              EdifCellInstance leafCell,
                              java.util.ArrayList wires,
                              boolean addEdifCellInstanceAsProperty)
Create the leaf cell as the sub cell of the parent cell. This is done by:
  1. Collecting initialization properties for block rams, flip flops luts, rams, and roms
  2. Retrieve the class to load
  3. Retrieve the class and object array for obtaining and initializing the constructor
  4. Retrieve the INIT and INIT_XX properties for the various memories
  5. Fill in the class and object arrays with the arguments to pass to the constructor for JHDL class initialization
  6. Finally, retrieve and initialize the JHDL class

Parameters:
parent - The parent of the created leaf cell
leafCell - The EdifCellInstance that represents the leafCell
wires - An ArrayList of Wire Objects

createSubCellWires

protected void createSubCellWires(EdifCellInstance subcell,
                                  EdifCellInstance parentCell,
                                  java.util.ArrayList wires,
                                  byucc.jhdl.base.Cell jhdlInstance,
                                  java.util.HashMap internalWires,
                                  java.util.Map instToMap)
Creates an ArrayList of JHDL Wire Objects to connect with the ports of the sub cell.

Parameters:
subcell - The subcell to the parentCell for creating wires
parentCell - The parent to the subcell
wires - The Collection that will contain the created Wire Objects
jhdlInstance - Used to create the JDHL Wire objects
internalWires - JHDL Wire Objects

_getPropertyINITString

protected java.lang.String _getPropertyINITString(EdifCellInstance leafCell,
                                                  java.lang.String initDefault,
                                                  java.lang.String initString,
                                                  int argSize,
                                                  int initPos,
                                                  int initDepth,
                                                  java.lang.Class[] arg_class,
                                                  java.lang.Object[] args)
It is important to retrieve INIT strings from the EDIF file to pass to JHDL constructors. There is more than one type of INIT property in EDIF so this method was created to grab different types of INIT strings (IE: INITP).

Parameters:
leafCell -
initDefault -
initString -
argSize -
initPos -
initDepth -
arg_class -
args -
Returns:

getNetNameFromPort

protected java.lang.String getNetNameFromPort(EdifPort port,
                                              int busMember,
                                              EdifCellInstance subCellInstance,
                                              java.util.Map instToMap)
Get the connected net name that the port (can be a bus port member also) of the subCellInstance connects to in the nets of the parent CellInstance.

Parameters:
port - The EdifPort Object owned by the subCellInstance
busMember - The bus member of the EdifPortRef
subCellInstance - The EdifCellInstance owning port

containsPortName

private boolean containsPortName(EdifCell cell,
                                 java.lang.String portName)
Returns true if the EdifCell contains a port with named after the given String.

Parameters:
cell - The cell whose EdifPort Objects will be checked
Returns:
True if the EdifCell contains a port named after the given String

parseMemDepth

private static int parseMemDepth(java.lang.String name)
Method used to parse the depth of the ram or rom (in ramMxN its the number associated with 'N'.

Parameters:
name - The name of the ram or rom
Returns:
The depth of the ram or rom

parseMemMxNPropertyLength

private static java.lang.String parseMemMxNPropertyLength(java.lang.String name)
In ramMxN, this method returns the 'M' for ram or roms.

Parameters:
name - The name of the class to parse
Returns:
The initialization String for this ram or rom