|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.byu.ece.edif.util.merge.EdifMergeParser
public class EdifMergeParser
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.
EdifParser| Field Summary | |
|---|---|
static boolean |
DEBUG
|
static java.lang.String[] |
EDIF_BB_UTILIZE_EXTENSIONS
|
static java.lang.String[] |
EDIF_BINARY_EXTENSIONS
|
static java.lang.String[] |
EDIF_EXTENSIONS
The types of acceptable extensions for EDIF files. |
private static int |
error_code
|
private static int |
INFER_OPEN_INPUT_PINS
|
private static int |
INFER_OPEN_OUTPUT_PINS
|
private static int |
MATCH_FOUND
|
private static int |
MATCHING_BINARY_FILE
|
private static int |
MATCHING_UTILIZATION_FILE
|
private static int |
NO_MATCHING_INSTANCE_NAME
|
private static int |
NO_MATCHING_INTERFACE
|
| Constructor Summary | |
|---|---|
EdifMergeParser()
|
|
| Method Summary | |
|---|---|
static boolean |
containsArgument(java.lang.String[] args,
java.lang.String arg)
|
static EdifCell |
copyCellDeep(EdifCell cellToCopy,
EdifLibrary targetLib,
EdifLibraryManager elm,
EdifMergingPolicy mergingPolicy)
Recursively copy an EdifCell from one EdifLibraryManager to another. |
static java.util.Set<java.lang.String> |
createDefaultDirs()
Create a Collection of "default" directories that should be searched for black box definitions. |
private static boolean |
filename_exists(java.lang.String dName,
java.lang.String file)
|
private static void |
findBinaryBlackBoxes(java.util.Collection<java.lang.String> dirs,
EdifCell blackBox,
EdifCell definition)
Find Xilinx Binary file, and tell the user that they have a possible BlackBox match |
private static void |
findBlackBoxUtilization(java.util.Collection<java.lang.String> dirs,
EdifCell blackBox,
EdifCell definition)
Find Utilization file and add it to the Utilization list on the EdifCell |
static EdifCell |
findLooseMatchingCell(EdifCell blackBox,
EdifEnvironment env)
Searches for a matching EdifCell, but allows unconnected pins on lower level definition, This method will call #findMatchingEdifCellInterface(EdifLibraryManager, EdifCell) to
perform this search. |
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,
java.io.PrintStream outstream)
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,
java.io.PrintStream outstream)
Searches for a matching EdifCell definition in an external file. |
static EdifCell |
findMatchingEdifCellInterface(EdifLibrary lib,
EdifCell cell,
boolean open)
Searches for an EdifCell object in a given library whose interface matches the interface of the EdifCell parameter. |
static EdifCell |
findMatchingEdifCellInterface(EdifLibraryManager elm,
EdifCell cell,
java.lang.Boolean open)
Searches the EdifLibraryManager parameter for an EdifCell that matches the EdifCell parameter. |
static EdifLibrary |
findMatchingLibrary(EdifLibrary inputLibrary,
EdifLibraryManager elm)
This method will investigate all EdifCell objects found within each library in the group and compare it with the passed in library (the passed in library is not necessarily a member of the manager). |
private static EdifCell |
findOpenPinBlackBoxes(java.util.Map<java.lang.String,EdifEnvironment> fileNameToEnv,
boolean openPins,
java.util.Map<EdifCell,EdifCell> blackBoxToDefinition,
EdifCell blackBox,
EdifCell definition)
Find open pins and allow them to match as blackboxes, per Xilinx rules. |
private static java.lang.String |
getErrorString(boolean quitOnFailure)
|
static java.util.Collection<EdifPort> |
getMatchingBusPorts(EdifCellInterface cellInt,
EdifPort port)
Returns an unordered Collection of EdifPorts in the cellInt interface that match the multi-bit bus port "port". |
static java.util.Map<EdifPort,java.util.Collection<EdifPort>> |
getMatchingMultiBitPorts(EdifCellInterface ref,
EdifCellInterface compare)
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.util.Collection<java.lang.String> dirs,
java.util.Collection<java.lang.String> files,
EdifLibrary primLib,
java.util.Map<java.lang.String,EdifEnvironment> fileNameToEnv)
Parse an EDIF file and recursively merge in all black boxes encountered. |
static EdifEnvironment |
getMergedEdifEnvironment(java.lang.String filename,
java.util.Collection<java.lang.String> dirs,
java.util.Iterator<java.lang.String> files_i,
EdifLibrary primLib,
java.util.Map<java.lang.String,EdifEnvironment> fileNameToEnv_param,
boolean openPins,
boolean quitOnError)
Parse an EDIF file and recursively merge in all black boxes encountered. |
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<EdifPort,java.util.Collection<EdifPort>> |
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<EdifPort,EdifPort> |
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 boolean |
matchingCellInterfaceBusExpansion(EdifCell cell1,
EdifCell cell2,
boolean open)
Performs a comparison between the port interfaces of two EdifCell objects. |
static void |
modifyPortRefsEqualize(EdifCellInstance eci,
java.util.Map<EdifPort,java.util.Collection<EdifPort>> definitionExpandedPorts,
java.util.Map<EdifPort,java.util.Collection<EdifPort>> blackBoxExpandedPorts,
java.util.Map<EdifPort,EdifPort> oneToOnePorts,
java.io.PrintStream outstream)
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 |
parseAndMergeEdif(java.lang.String topFilename,
java.util.Collection<java.lang.String> dirs,
java.util.Collection<java.lang.String> files,
EdifLibrary primLib)
|
static EdifEnvironment |
parseAndMergeEdif(java.lang.String topFilename,
java.util.Collection<java.lang.String> dirs,
java.util.Collection<java.lang.String> files,
EdifLibrary primLib,
boolean allowOpenPins,
boolean quitOnError)
This method will parse a given EDIF filename and merge any appropriate EDIF files if necessary. |
static java.util.Set<java.lang.String> |
parseArguments(java.lang.String[] args,
java.lang.String flag)
A simple method for parsing arguments. |
static java.util.Set<java.lang.String> |
parseArguments(java.lang.String[] args,
java.lang.String flag,
int numValues)
|
private static void |
parseBlackBoxInfoFile(EdifCell blackBox,
java.lang.String filename)
Parses a file named EdifCell.bb to find out information about the resources for a blackbox, that we don't have the source for. |
static void |
replaceBlackBox(EdifCell blackBox,
EdifCell definition,
java.io.PrintStream outstream,
EdifMergingPolicy mergingPolicy)
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 |
| Field Detail |
|---|
public static final java.lang.String[] EDIF_EXTENSIONS
Note that the current extensions do not include upper-case versions for windows compatibility. This should be augmented to check for the OS and add upper case extensions if necessary
public static final java.lang.String[] EDIF_BINARY_EXTENSIONS
public static final java.lang.String[] EDIF_BB_UTILIZE_EXTENSIONS
private static int error_code
private static final int MATCH_FOUND
private static final int NO_MATCHING_INSTANCE_NAME
private static final int NO_MATCHING_INTERFACE
private static final int MATCHING_BINARY_FILE
private static final int MATCHING_UTILIZATION_FILE
private static final int INFER_OPEN_OUTPUT_PINS
private static final int INFER_OPEN_INPUT_PINS
public static final boolean DEBUG
| Constructor Detail |
|---|
public EdifMergeParser()
| Method Detail |
|---|
public static EdifCell copyCellDeep(EdifCell cellToCopy,
EdifLibrary targetLib,
EdifLibraryManager elm,
EdifMergingPolicy mergingPolicy)
cellToCopy - the EdifCell object to copytargetLib - the EdifLibrary to copy the cell into. If no EdifLibrary
is specified (null), the EdifCell will be placed in an EdifLibrary with
the same name (or a new unique name if there is a clash) as it's old
EdifLibraryelm - the EdifLibraryManager to copy the cell into
public static java.util.Map<EdifPort,EdifPort> getOneToOnePortMatches(EdifCell c1,
EdifCell c2)
public static java.util.Map<EdifPort,java.util.Collection<EdifPort>> getOneToManyPortMatches(EdifCell c1,
EdifCell c2)
public static java.util.Collection<EdifPort> getMatchingBusPorts(EdifCellInterface cellInt,
EdifPort port)
If no match can be found, a null will be returned.
port - The multi-bit edif port used for the referencepolicy - The naming policy used to perform the match
public static java.util.Map<EdifPort,java.util.Collection<EdifPort>> getMatchingMultiBitPorts(EdifCellInterface ref,
EdifCellInterface compare)
public static EdifCell findMatchingEdifCellInterface(EdifLibrary lib,
EdifCell cell,
boolean open)
EdifCell.equalsInterface(EdifCell) will be
called to perform an exact match on the ports. If this fails,
matchingCellInterfaceBusExpansion(EdifCell, EdifCell) will be
called to see if the interfaces match when busses are expanded in either
of the cells.
lib - EdifLibrary in which to search for a matchcell - EdifCell to matchopen - Whether to allow open pins on matching cell
public static EdifCell findMatchingEdifCellInterface(EdifLibraryManager elm,
EdifCell cell,
java.lang.Boolean open)
#findMatchingEdifCellInterface(EdifLibrary, EdifCell, Boolean) to
perform this search.
elm - EdifLibraryManager to search.cell - EdifCell to matchopen - Whether to allow unmatched pins on matching cell
public static EdifCell findMatchingCell(EdifCell blackBox,
EdifEnvironment env)
#findMatchingEdifCellInterface(EdifLibraryManager, EdifCell) to
perform this search.
blackBox - env -
public static EdifCell findLooseMatchingCell(EdifCell blackBox,
EdifEnvironment env)
#findMatchingEdifCellInterface(EdifLibraryManager, EdifCell) to
perform this search.
blackBox - env -
public static EdifCell findMatchingCellInFile(EdifCell blackBox,
java.lang.String filename,
java.io.PrintStream outstream)
findMatchingCell(EdifCell,EdifEnvironment) to
perform this search.
blackBox - EdifCell object that this method is trying to matchfilename - The filename to open and search for a matching EdifCell.
public static EdifCell findMatchingCellInDir(EdifCell blackBox,
java.lang.String dir,
java.io.PrintStream outstream)
public static EdifLibrary findMatchingLibrary(EdifLibrary inputLibrary,
EdifLibraryManager elm)
public static void replaceBlackBox(EdifCell blackBox,
EdifCell definition,
java.io.PrintStream outstream,
EdifMergingPolicy mergingPolicy)
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.
public static void modifyPortRefsEqualize(EdifCellInstance eci,
java.util.Map<EdifPort,java.util.Collection<EdifPort>> definitionExpandedPorts,
java.util.Map<EdifPort,java.util.Collection<EdifPort>> blackBoxExpandedPorts,
java.util.Map<EdifPort,EdifPort> oneToOnePorts,
java.io.PrintStream outstream)
eci - EdifCellInstanceblackBox - EdifCell to be modifieddefinition -
public static boolean matchingCellInterfaceBusExpansion(EdifCell cell1,
EdifCell cell2)
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.
Xilinx tools allow an upper level cell to match even though the upper level cell may not reference all the ports in the lower level. It is infered that Xilix then ties these ports "open"
cell1-upper - levelcell2-lower - level
public static boolean matchingCellInterfaceBusExpansion(EdifCell cell1,
EdifCell cell2,
boolean open)
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.
Xilinx tools allow an upper level cell to match even though the upper level cell may not reference all the ports in the lower level. It is infered that Xilix then ties these ports "open"
cell1-upper - level- allowed to have less portscell2-lower - levelopen- - whether to allow cell1 to have less ports than cell2
public static EdifEnvironment parseAndMerge(java.lang.String[] args,
EdifLibrary primLib)
The following invocation of this method demonstrates the use of appropriate arguments:
java <main class> <EDIF filename> -L <search dir #1> -L <search dir #2> \
-f <external EDIF filename>
The arguments are interpreted as follows:
EdifMergeParser#parseAndMergeEdif(String, Collection, Collection, EdifLibrary, PrintStream).
If there are any errors, this method will exit rather than throwing an
exception.
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
public static EdifEnvironment parseAndMergeEdif(java.lang.String topFilename,
java.util.Collection<java.lang.String> dirs,
java.util.Collection<java.lang.String> files,
EdifLibrary primLib,
boolean allowOpenPins,
boolean quitOnError)
throws ParseException,
java.io.FileNotFoundException
EdifLibraryManager.findBlackBoxes()findMatchingCell(EdifCell, EdifEnvironment).findMatchingCellInDir(EdifCell, String, PrintStream) will search
the directory specified by the string parameter for an edif file that
matches the blackbox.replaceBlackBox(EdifCell, EdifCell, PrintStream, EdifMergingPolicy).
topFilename - Filename of "top" edif environmentdirs - 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 primitivesoutstream - PrintStream to which output during the merge process
should be directed.
ParseException
java.io.FileNotFoundException
public static EdifEnvironment parseAndMergeEdif(java.lang.String topFilename,
java.util.Collection<java.lang.String> dirs,
java.util.Collection<java.lang.String> files,
EdifLibrary primLib)
throws ParseException,
java.io.FileNotFoundException
ParseException
java.io.FileNotFoundExceptionpublic static java.util.Set<java.lang.String> createDefaultDirs()
public static java.util.Set<java.lang.String> parseArguments(java.lang.String[] args,
java.lang.String flag)
. Each time the flag
is used, the successor is added to a Collection of
Strings. A null will be returned if no parsed arguments are found. This
method uses a TreeSet to make sure that copies of the argument are not
included in the set.
public static java.util.Set<java.lang.String> parseArguments(java.lang.String[] args,
java.lang.String flag,
int numValues)
args - An array of String objects, the arguments to be parsedflag - numValues -
public static boolean containsArgument(java.lang.String[] args,
java.lang.String arg)
public static EdifEnvironment getMergedEdifEnvironment(java.lang.String filename,
java.lang.String[] args)
This particular method is currently hard coded to expect the XilinxLibrary.
filename - Filename of the top-level EDIF fileargs - The command line arguments (looking for -L directory searches
and -f file searches
public static EdifEnvironment getMergedEdifEnvironment(java.lang.String filename,
java.util.Collection<java.lang.String> dirs,
java.util.Collection<java.lang.String> files,
EdifLibrary primLib,
java.util.Map<java.lang.String,EdifEnvironment> fileNameToEnv)
throws java.io.FileNotFoundException,
ParseException
filename - Filename of the EDIF filedirs - A collection of directories to search for black boxesfiles - A collection of files to search for black boxesprimLib - A primitive library to use for tagging all primitives in
the design. Leave null for no primitive tagging.outstream - A PrintStream to direct output to.fileNameToEnv - A map of filenames to parsed EdifEnvironments used
for recursive processing. Leave null for the top-level file.
java.io.FileNotFoundException
ParseException
public static EdifEnvironment getMergedEdifEnvironment(java.lang.String filename,
java.util.Collection<java.lang.String> dirs,
java.util.Iterator<java.lang.String> files_i,
EdifLibrary primLib,
java.util.Map<java.lang.String,EdifEnvironment> fileNameToEnv_param,
boolean openPins,
boolean quitOnError)
throws java.io.FileNotFoundException,
ParseException
filename - Filename of the EDIF filedirs - A collection of directories to search for black boxesfiles - A collection of files to search for black boxesprimLib - A primitive library to use for tagging all primitives in
the design. Leave null for no primitive tagging.outstream - A PrintStream to direct output to.fileNameToEnv - A map of filenames to parsed EdifEnvironments used
for recursive processing. Leave null for the top-level file.openPins - whether or not to allow matching on open pins.
java.io.FileNotFoundException
ParseException
private static boolean filename_exists(java.lang.String dName,
java.lang.String file)
private static void findBinaryBlackBoxes(java.util.Collection<java.lang.String> dirs,
EdifCell blackBox,
EdifCell definition)
dirs - blackBox - definition -
private static void findBlackBoxUtilization(java.util.Collection<java.lang.String> dirs,
EdifCell blackBox,
EdifCell definition)
dirs - blackBox - definition -
private static void parseBlackBoxInfoFile(EdifCell blackBox,
java.lang.String filename)
blackBox - filename -
private static EdifCell findOpenPinBlackBoxes(java.util.Map<java.lang.String,EdifEnvironment> fileNameToEnv,
boolean openPins,
java.util.Map<EdifCell,EdifCell> blackBoxToDefinition,
EdifCell blackBox,
EdifCell definition)
fileNameToEnv - openPins - blackBoxToDefinition - blackBox - definition -
private static java.lang.String getErrorString(boolean quitOnFailure)
throws ParseException
ParseExceptionpublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||