byucc.edif.tools.merge
Class EdifMergeParser
java.lang.Object
byucc.edif.tools.merge.EdifMergeParser
public class EdifMergeParser
- extends java.lang.Object
Provides Edif parsing capability as well as the ability to
"merge" edif definitions from more than one edif file.
This class contains a number of static methods that are used
together to provide the merging capability.
TODO: Describe the control flow for "matching" (i.e. the
order the methods are called).
TODO: This class is probably mis-named. It is not a parser but
a set of classes that are used to match. A better name might
be EdifCellMatching.
- Version:
- $Id: EdifMergeParser.java,v 1.28 2006/01/10 21:14:53 wirthlin Exp $
- Author:
- Mike Wirthlin
- See Also:
EdifParser
|
Field Summary |
static boolean |
DEBUG
|
static java.lang.String[] |
EDIF_EXTENSIONS
The types of acceptable extensions for EDIF files |
|
Method Summary |
static boolean |
containsArgument(java.lang.String[] args,
java.lang.String arg)
|
static java.util.Set |
createDefaultDirs()
Create a Collection of "default" directories that
should be searched for black box definitions. |
static EdifCell |
findMatchingCell(EdifCell blackBox,
EdifEnvironment env)
Searches for a matching EdifCell definition in an existing,
unrelated EdifEnvironment object. |
static EdifCell |
findMatchingCellInDir(EdifCell blackBox,
java.lang.String dir)
Searches a given directory for an Edif file with a name
that is the same as the Cell name. |
static EdifCell |
findMatchingCellInFile(EdifCell blackBox,
java.lang.String filename)
Searches for a matching EdifCell definition in an external file. |
static EdifCell |
findMatchingEdifCellInterface(EdifLibrary lib,
EdifCell cell)
Searches for an EdifCell object whose interface matches the
interface of the EdifCell paramter. |
static EdifCell |
findMatchingEdifCellInterface(EdifLibraryManager elm,
EdifCell cell)
Searches the EdifLibraryManager parameter for an EdifCell that
matches the EdifCell parameter. |
static java.util.Collection |
getMatchingBusPorts(EdifCellInterface cellInt,
EdifPort port,
EdifBusNetNamingPolicy policy)
Returns an unordered Collection of EdifPorts in the cellInt
interface that match the multi-bit bus port "port". |
static java.util.Map |
getMatchingMultiBitPorts(EdifCellInterface ref,
EdifCellInterface compare,
EdifBusNetNamingPolicy policy)
The key of the Map is a multi-bit EdifPort in "ref" and the value
is a Collection of single-bit EdifPort objects in "compare"
that match the "ref" multi-bit EdifPort. |
static EdifEnvironment |
getMergedEdifEnvironment(java.lang.String filename,
java.lang.String[] args)
This static method will parse the top-level Edif file and merge the appropriate
EdifFiles into this object. |
static java.util.Map |
getOneToManyPortMatches(EdifCell c1,
EdifCell c2)
This method will compare the cell interfaces of c1 and c2
to see if there are any multi-bit ports in C1 that match
a group of single-bit ports in C2. |
static java.util.Map |
getOneToOnePortMatches(EdifCell c1,
EdifCell c2)
Returns a Map between matching ports in the two different
EdifCell objects. |
static void |
main(java.lang.String[] args)
Sample "main" to demonstrate the merging of edif files. |
static boolean |
matchingCellInterfaceBusExpansion(EdifCell cell1,
EdifCell cell2)
Performs a comparison between the port interfaces of two EdifCell
objects. |
static void |
modifyPortRefsEqualize(EdifCellInstance eci,
EdifCell blackBox,
EdifCell definition)
This method will modify all of the port refs to the black box
to properly reflect the change in the interface of the definition. |
static EdifEnvironment |
parseAndMerge(java.lang.String[] args,
EdifLibrary primLib)
This method will parse a given Edif filename and merge any appropriate
EDIF files as specified by arguments in the args parameter. |
static EdifEnvironment |
parseAndMerge(java.lang.String topFilename,
java.util.Collection dirs,
java.util.Collection files,
EdifLibrary primLib)
TODO:
- Modify this method to throw exception rather than exiting |
static EdifEnvironment |
parseAndMergeEdif(java.lang.String topFilename,
java.util.Collection dirs,
java.util.Collection files,
EdifLibrary primLib,
java.io.PrintStream outstream)
TODO:
- modify the use of System.out with outstream
- Provide a javadoc description of this method
- Use @{link} and @{see} tags to highlight the key
methods called from this method:
findMatchingCell
replaceBlackBox2
- Generate Exceptions rather than system.exit()
FileNotFoundException
ParseException
- Modify parseAndMerge to "exit" when these
exceptions are generated
- deprectage parseAndMerge and add a comment
that encourages use of this method. |
static java.util.Set |
parseArguments(java.lang.String[] args,
java.lang.String flag)
A simple method for parsing arguements. |
static java.util.Set |
parseArguments(java.lang.String[] args,
java.lang.String flag,
int numValues)
|
static void |
replaceBlackBox(EdifCell blackBox,
EdifCell definition)
This method will replace the "blackBox" EdifCell object with the
"definition" EdifCell object. |
static void |
replaceBlackBox2(EdifCell blackBox,
EdifCell definition)
This method will replace the "blackBox" EdifCell object with the
"definition" EdifCell object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EDIF_EXTENSIONS
public static final java.lang.String[] EDIF_EXTENSIONS
- The types of acceptable extensions for EDIF files. *
DEBUG
public static final boolean DEBUG
- See Also:
- Constant Field Values
EdifMergeParser
public EdifMergeParser()
getOneToOnePortMatches
public static java.util.Map getOneToOnePortMatches(EdifCell c1,
EdifCell c2)
- Returns a Map between matching ports in the two different
EdifCell objects. In order for these ports to match,
they must return a true on the method EdifPort.equals(EdifPort).
This is a strict match between the two ports.
The key of the Map is a Port from c1 and
the value is a Port from c2.
- Parameters:
-
getOneToManyPortMatches
public static java.util.Map getOneToManyPortMatches(EdifCell c1,
EdifCell c2)
- This method will compare the cell interfaces of c1 and c2
to see if there are any multi-bit ports in C1 that match
a group of single-bit ports in C2.
The returned map is:
Key = multi-bit edif Port in c1. Value is a Collection
of EdifPorts in c2 that match.
getMatchingBusPorts
public static java.util.Collection getMatchingBusPorts(EdifCellInterface cellInt,
EdifPort port,
EdifBusNetNamingPolicy policy)
- Returns an unordered Collection of EdifPorts in the cellInt
interface that match the multi-bit bus port "port".
The goal is to try and find a set of single-bit ports in this
interface that can be combined to match a
reference multi-bit port. In order for a match to occur,
there must be N single-bit ports whose basenames match
the multi-bit port. The multi-bit port width must be = N.
If no match can be found, a null will be returned.
- Parameters:
port - The multi-bit edif port used for the referencepolicy - The naming policy used to perform the match
- Returns:
- A collection of EdifPort objects that when combined
will match the given EdifPort object. Returns a null if
no match is found
getMatchingMultiBitPorts
public static java.util.Map getMatchingMultiBitPorts(EdifCellInterface ref,
EdifCellInterface compare,
EdifBusNetNamingPolicy policy)
- The key of the Map is a multi-bit EdifPort in "ref" and the value
is a Collection of single-bit EdifPort objects in "compare"
that match the "ref" multi-bit EdifPort.
findMatchingEdifCellInterface
public static EdifCell findMatchingEdifCellInterface(EdifLibrary lib,
EdifCell cell)
- Searches for an EdifCell object whose interface matches the
interface of the EdifCell paramter. In order for this method
to return a matching EdifCell object, the following conditions
must hold:
- The name of the EdifCell in the library
must match the name of the EdifCell parameter
- The port interface of the EdifCell must match the port
interface of the parameter. Note that two different methods will
be used to check this interface. First,
EdifCell#equalsInterface(EdifCell) will be called to perform
an exact match on the ports. If this fails,
{@link EdifMergeParser#matchingCellInterfaceBusExpansion(EdifCell, EdifCell)}
will be called to see if the interfaces match when busses are expanded
in either of the cells.
- Parameters:
lib - cell -
- Returns:
findMatchingEdifCellInterface
public static EdifCell findMatchingEdifCellInterface(EdifLibraryManager elm,
EdifCell cell)
- Searches the EdifLibraryManager parameter for an EdifCell that
matches the EdifCell parameter.
This method calls {@link findMatchingCellInterface(EdifLibrary, EdifCell)
to perform this search.
- Parameters:
elm - EdifLibraryManager to search.cell - EdifCell to match
- Returns:
- The matching EdifCell object. This method will return a null
if no match is performed.
findMatchingCell
public static EdifCell findMatchingCell(EdifCell blackBox,
EdifEnvironment env)
- Searches for a matching EdifCell definition in an existing,
unrelated EdifEnvironment object.
This method will call
{@link findMatchingCell(EdifLibraryManager,EdifCell)
to perform this search.
- Parameters:
blackBox - env -
- Returns:
findMatchingCellInFile
public static EdifCell findMatchingCellInFile(EdifCell blackBox,
java.lang.String filename)
- Searches for a matching EdifCell definition in an external file.
This method will call {@link findMatchingCell(EdifCell,EdifEnvironment)
to perform this search.
- Parameters:
blackBox - EdifCell object that this method is trying to matchfilename - The filename to open and search for a matching
EdifCell.
- Returns:
- The EdifCell object found within this file that matches
the blackBox EdifCell parameter. This method returns a null if
no match is found.
findMatchingCellInDir
public static EdifCell findMatchingCellInDir(EdifCell blackBox,
java.lang.String dir)
- Searches a given directory for an Edif file with a name
that is the same as the Cell name. Multiple extensions will
be searched if necessary.
replaceBlackBox
public static void replaceBlackBox(EdifCell blackBox,
EdifCell definition)
- This method will replace the "blackBox" EdifCell object with the
"definition" EdifCell object. Port interfaces will be equalized if necessary.
- Parameters:
blackBox - The "blackBox" EdifCell object that will be replaced. This
EdifCell should contain NO contents.definition - The EdifCell object that provides a "definition" for
the black Box EdifCell. This EdifCell MUST contain contents.
replaceBlackBox2
public static void replaceBlackBox2(EdifCell blackBox,
EdifCell definition)
- This method will replace the "blackBox" EdifCell object with the
"definition" EdifCell object. Port interfaces will be equalized if necessary.
- Parameters:
blackBox - The "blackBox" EdifCell object that will be replaced. This
EdifCell should contain NO contents.definition - The EdifCell object that provides a "definition" for
the black Box EdifCell. This EdifCell MUST contain contents.
modifyPortRefsEqualize
public static void modifyPortRefsEqualize(EdifCellInstance eci,
EdifCell blackBox,
EdifCell definition)
- This method will modify all of the port refs to the black box
to properly reflect the change in the interface of the definition.
- Parameters:
eci - blackBox - definition -
matchingCellInterfaceBusExpansion
public static boolean matchingCellInterfaceBusExpansion(EdifCell cell1,
EdifCell cell2)
- Performs a comparison between the port interfaces of two EdifCell
objects. Unlike the strict
EdifCell.equalsInterface(EdifCell)
method, this method will perform a match while allowing busses
in one EdifCell interface to be expanded into individual bits and
remain as a complete bus in the original EdifCell.
- Parameters:
cell1 - cell2 -
- Returns:
- true if the cell interfaces of the two cells match. False
if there is no match.
parseAndMerge
public static EdifEnvironment parseAndMerge(java.lang.String[] args,
EdifLibrary primLib)
- This method will parse a given Edif filename and merge any appropriate
EDIF files as specified by arguments in the args parameter. This
method can be used by main methods to parse arguments and provide
an EdifEnvironment in return.
The following invocation of this method demonstrates the use of
appropriate arguments:
java -L -L \
-f
The arguments are interpreted as follows:
- args[0] - original EDIF filename.
- Search directories - this method needs to search multiple
directories in an attempt to find matching edif files.
To add a search directories, use the "-L" flag
(one external directory for each invokation of "-L").
- A specific edif filename can be specified for merging using
the "-f" flag. Only one external filename should be specified for
each external edif file.
Once the arguments have been parsed, this method will
call parseAndMerge(String, Collection, Collection,
EdifLibrary. If there are any errors, this method will exit
rather than throwing an exception.
- Parameters:
args - String arguments that contain the filename, libraries, and
external files needed for parsing.primLib - Primitive library to use for primitive tagging. If
the library is null, do not tag library elements for primitives
- Returns:
- The merged EdifEnvironment
parseAndMerge
public static EdifEnvironment parseAndMerge(java.lang.String topFilename,
java.util.Collection dirs,
java.util.Collection files,
EdifLibrary primLib)
- TODO:
- Modify this method to throw exception rather than exiting.
- Use a generic PrintWriter for output rather than directly writing
to the System.out or System.err
- Parameters:
topFilename - Filename of "top" edif environmentsearchDirs - A Collection of String directory names used to
search for black box definitions. If this is null, no directories will
be searched.files - A Collection of String filenames that contain EdifCell
definitions. These files will be parsed and searched when black box
definitions are found.primLib - Primitive library to use for primitive tagging. If
the library is null, do not tag library elements for primitives
- Returns:
- The merged EdifEnvironment
parseAndMergeEdif
public static EdifEnvironment parseAndMergeEdif(java.lang.String topFilename,
java.util.Collection dirs,
java.util.Collection files,
EdifLibrary primLib,
java.io.PrintStream outstream)
- TODO:
- modify the use of System.out with outstream
- Provide a javadoc description of this method
- Use @{link} and @{see} tags to highlight the key
methods called from this method:
findMatchingCell
replaceBlackBox2
- Generate Exceptions rather than system.exit()
FileNotFoundException
ParseException
- Modify parseAndMerge to "exit" when these
exceptions are generated
- deprectage parseAndMerge and add a comment
that encourages use of this method.
- Parameters:
topFilename - Filename of "top" edif environmentsearchDirs - A Collection of String directory names used to
search for black box definitions. If this is null, no directories will
be searched.files - A Collection of String filenames that contain EdifCell
definitions. These files will be parsed and searched when black box
definitions are found.primLib - Primitive library to use for primitive tagging. If
the library is null, do not tag library elements for primitives
- Returns:
- The merged EdifEnvironment
createDefaultDirs
public static java.util.Set createDefaultDirs()
- Create a Collection of "default" directories that
should be searched for black box definitions. This
method will include the directory "."
- Returns:
parseArguments
public static java.util.Set parseArguments(java.lang.String[] args,
java.lang.String flag)
- A simple method for parsing arguements. This method will
search for arguments in the form . Each time
the flag is used, the successor is added to a Collection
of Strings. A null will be returned if no parsed arguements are found.
This method uses a TreeSet to make sure that copies of the argument
are not included in the set.
parseArguments
public static java.util.Set parseArguments(java.lang.String[] args,
java.lang.String flag,
int numValues)
- Parameters:
args - flag - numValues -
- Returns:
- A Set of List values
containsArgument
public static boolean containsArgument(java.lang.String[] args,
java.lang.String arg)
getMergedEdifEnvironment
public static EdifEnvironment getMergedEdifEnvironment(java.lang.String filename,
java.lang.String[] args)
- This static method will parse the top-level Edif file and merge the appropriate
EdifFiles into this object. This method will support a search path as well
as the parsing of specific auxilliary edif files.
This pariticular method is currently hard coded to expect the XilinxLibrary.
- Parameters:
filename - Filename of the top-level EDIF fileargs - The command line arguments (looking for -L directory searches and
-f file searches
- Returns:
- The merged EdifEnvironment object.
main
public static void main(java.lang.String[] args)
- Sample "main" to demonstrate the merging of edif files.