📄 generatevhdl.java
字号:
* BLOCKXNOR: only include input port "a" and output port "y".<BR> * BLOCKFLOPTS: only include input ports "i1", "ck", "preset" and output port "q".<BR> * BLOCKFLOPTR: only include input ports "i1", "ck", "clear" and output port "q".<BR> * BLOCKFLOPDS: only include input ports "i1", "ck", "preset" and output port "q".<BR> * BLOCKFLOPDR: only include input ports "i1", "ck", "clear" and output port "q".<BR> * BLOCKFLOP: include input ports "i1", "i2", "ck", "preset", "clear", and output ports "q" and "qb". */ private int getSpecial() { return special; } /** * Constructor which analyzes a primitive node. * @param no the primitive node. * @param negatedHeads map of arcs with negated head ends. * @param negatedTails map of arcs with negated tail ends. */ private AnalyzePrimitive(Nodable no, Map<ArcInst,Integer> negatedHeads, Map<ArcInst,Integer> negatedTails) { // cell instances are easy special = BLOCKNORMAL; if (no.isCellInstance()) { primName = no.getProto().getName(); return; } NodeInst ni = no.getNodeInst(); // get the primitive function PrimitiveNode.Function k = ni.getFunction(); primName = null; if (k == PrimitiveNode.Function.TRADMOS || k == PrimitiveNode.Function.TRA4DMOS) { primName = "DMOStran"; special = BLOCKMOSTRAN; } else if (k.isNTypeTransistor()) { primName = "nMOStran"; Variable var = no.getVar(Simulation.WEAK_NODE_KEY); if (var != null) primName = "nMOStranWeak"; special = BLOCKMOSTRAN; } else if (k.isPTypeTransistor()) { primName = "PMOStran"; Variable var = no.getVar(Simulation.WEAK_NODE_KEY); if (var != null) primName = "PMOStranWeak"; special = BLOCKMOSTRAN; } else if (k == PrimitiveNode.Function.TRANPN || k == PrimitiveNode.Function.TRA4NPN) { primName = "NPNtran"; } else if (k == PrimitiveNode.Function.TRAPNP || k == PrimitiveNode.Function.TRA4PNP) { primName = "PNPtran"; } else if (k == PrimitiveNode.Function.TRANJFET || k == PrimitiveNode.Function.TRA4NJFET) { primName = "NJFET"; } else if (k == PrimitiveNode.Function.TRAPJFET || k == PrimitiveNode.Function.TRA4PJFET) { primName = "PJFET"; } else if (k == PrimitiveNode.Function.TRADMES || k == PrimitiveNode.Function.TRA4DMES) { primName = "DMEStran"; } else if (k == PrimitiveNode.Function.TRAEMES || k == PrimitiveNode.Function.TRA4EMES) { primName = "EMEStran"; } else if (k == PrimitiveNode.Function.FLIPFLOPRSMS || k == PrimitiveNode.Function.FLIPFLOPRSN || k == PrimitiveNode.Function.FLIPFLOPRSP) { primName = "rsff"; special = BLOCKFLOP; } else if (k == PrimitiveNode.Function.FLIPFLOPJKMS || k == PrimitiveNode.Function.FLIPFLOPJKN || k == PrimitiveNode.Function.FLIPFLOPJKP) { primName = "jkff"; special = BLOCKFLOP; } else if (k == PrimitiveNode.Function.FLIPFLOPDMS || k == PrimitiveNode.Function.FLIPFLOPDN || k == PrimitiveNode.Function.FLIPFLOPDP) { primName = "dsff"; special = BLOCKFLOPDS; for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); ) { Connection con = it.next(); if (con.getPortInst().getPortProto().getName().equals("clear")) { primName = "drff"; special = BLOCKFLOPDR; break; } } } else if (k == PrimitiveNode.Function.FLIPFLOPTMS || k == PrimitiveNode.Function.FLIPFLOPTN || k == PrimitiveNode.Function.FLIPFLOPTP) { primName = "tsff"; special = BLOCKFLOPTS; for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); ) { Connection con = it.next(); if (con.getPortInst().getPortProto().getName().equals("clear")) { primName = "trff"; special = BLOCKFLOPTR; break; } } } else if (k == PrimitiveNode.Function.BUFFER) { primName = Schematics.tech().getVHDLNames(Schematics.tech().bufferNode); int slashPos = primName.indexOf('/'); special = BLOCKBUFFER; for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); ) { Connection con = it.next(); if (!con.getPortInst().getPortProto().getName().equals("y")) continue; if (con.isNegated()) { if (slashPos >= 0) primName = primName.substring(slashPos+1); special = BLOCKINVERTER; if (con.getEndIndex() == ArcInst.HEADEND) negatedHeads.remove(con.getArc()); else negatedTails.remove(con.getArc()); break; } } if (special == BLOCKBUFFER) { if (slashPos >= 0) primName = primName.substring(0, slashPos); } } else if (k == PrimitiveNode.Function.GATEAND) { primName = Schematics.tech().getVHDLNames(Schematics.tech().andNode); int slashPos = primName.indexOf('/'); int inPort = 0; Connection isNeg = null; for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); ) { Connection con = it.next(); if (con.getPortInst().getPortProto().getName().equals("a")) inPort++; if (!con.getPortInst().getPortProto().getName().equals("y")) continue; if (con.isNegated()) isNeg = con; } if (isNeg != null) { if (slashPos >= 0) primName = primName.substring(slashPos+1); special = BLOCKNAND; if (isNeg.getEndIndex() == ArcInst.HEADEND) negatedHeads.remove(isNeg.getArc()); else negatedTails.remove(isNeg.getArc()); } else { if (slashPos >= 0) primName = primName.substring(0, slashPos); special = BLOCKPOSLOGIC; } primName += inPort; } else if (k == PrimitiveNode.Function.GATEOR) { primName = Schematics.tech().getVHDLNames(Schematics.tech().orNode); int slashPos = primName.indexOf('/'); int inPort = 0; Connection isNeg = null; for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); ) { Connection con = it.next(); if (con.getPortInst().getPortProto().getName().equals("a")) inPort++; if (!con.getPortInst().getPortProto().getName().equals("y")) continue; if (con.isNegated()) isNeg = con; } if (isNeg != null) { if (slashPos >= 0) primName = primName.substring(slashPos+1); special = BLOCKNOR; if (isNeg.getEndIndex() == ArcInst.HEADEND) negatedHeads.remove(isNeg.getArc()); else negatedTails.remove(isNeg.getArc()); } else { if (slashPos >= 0) primName = primName.substring(0, slashPos); special = BLOCKPOSLOGIC; } primName += inPort; } else if (k == PrimitiveNode.Function.GATEXOR) { primName = Schematics.tech().getVHDLNames(Schematics.tech().xorNode); int slashPos = primName.indexOf('/'); int inPort = 0; Connection isNeg = null; for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); ) { Connection con = it.next(); if (con.getPortInst().getPortProto().getName().equals("a")) inPort++; if (!con.getPortInst().getPortProto().getName().equals("y")) continue; if (con.isNegated()) isNeg = con; } if (isNeg != null) { if (slashPos >= 0) primName = primName.substring(slashPos+1); special = BLOCKXNOR; if (isNeg.getEndIndex() == ArcInst.HEADEND) negatedHeads.remove(isNeg.getArc()); else negatedTails.remove(isNeg.getArc()); } else { if (slashPos >= 0) primName = primName.substring(0, slashPos); special = BLOCKPOSLOGIC; } primName += inPort; } else if (k == PrimitiveNode.Function.MUX) { primName = Schematics.tech().getVHDLNames(Schematics.tech().muxNode); int inPort = 0; for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); ) { Connection con = it.next(); if (con.getPortInst().getPortProto().getName().equals("a")) inPort++; } primName += inPort; } else if (k == PrimitiveNode.Function.CONPOWER) { primName = "power"; } else if (k == PrimitiveNode.Function.CONGROUND) { primName = "ground"; } if (primName == null) { // if the node has an export with power/ground, make it that for(Iterator<Export> it = ni.getExports(); it.hasNext(); ) { Export e = it.next(); if (e.isPower()) { primName = "power"; break; } if (e.isGround()) { primName = "ground"; break; } } } } } /** * Class to aggregate signal names and write them on length-limited lines. */ private class SignalNameLine { private boolean hasContent = false; public void addSignalName(String sigName) { if (!hasContent) { writeWidthLimited("\n"); writeWidthLimited(" signal "); } else { writeWidthLimited(", "); } hasContent = true; writeWidthLimited(sigName); } public void finish() { if (hasContent) writeWidthLimited(": BIT;\n"); } } /****************************** SUBCLASSED METHODS FOR THE TOPOLOGY ANALYZER ******************************/ /** * Method to adjust a cell name to be safe for Verilog output. * @param name the cell name. * @return the name, adjusted for Verilog output. */ protected String getSafeCellName(String name) { if (name.length() == 0) return name; char first = name.charAt(0); if (!Character.isLetter(first)) name = "E_" + name; for(int i=0; i<name.length(); i++) { char ch = name.charAt(i); if (Character.isLetterOrDigit(ch)) continue; if (ch == '_') continue; name = name.substring(0, i) + "_" + name.substring(i+1); } return name; } /** Method to tell the netlister to deal with all Cells. */ protected boolean skipCellAndSubcells(Cell cell) { return false; } /** Method to return the proper name of Power (just use whatever name is there) */ protected String getPowerName(Network net) { return net.getName(); } /** Method to return the proper name of Ground (just use whatever name is there) */ protected String getGroundName(Network net) { return net.getName(); } /** Method to return the proper name of a Global signal */ protected String getGlobalName(Global glob) { return "glbl." + glob.getName(); } /** * Method to tell the netlister that export names DO take precedence over * arc names when determining the name of the network. */ protected boolean isNetworksUseExportedNames() { return true; } /** Method to report that library names are not always prepended to cell names. */ protected boolean isLibraryNameAlwaysAddedToCellName() { return false; } /** Method to report that aggregate names (busses) are not used. */ protected boolean isAggregateNamesSupported() { return false; } /** Method to decide whether aggregate names (busses) can have gaps in their ranges. */ protected boolean isAggregateNameGapsSupported() { return false; } /** Method to tell netlister not to separate input and output names (this module does more detailed separation). */ protected boolean isSeparateInputAndOutput() { return false; } /** Method to tell the netlister to be case-sensitive. */ protected boolean isCaseSensitive() { return true; } /** Method to tell the netlister how to short resistors */ protected Netlist.ShortResistors getShortResistors() { return Netlist.ShortResistors.ALL; } /** Method to tell the netlister to mangle cell names that are parameterized. */ protected boolean canParameterizeNames() { return true; } /** * Method to adjust a network name to be safe for VHDL output. */ protected String getSafeNetName(String name, boolean bus) { return addString(name, null); } /** * Method to add the string "orig" to the infinite string. * If "environment" is not NONODEPROTO, it is the cell in which this signal is * to reside, and if that cell has nodes with this name, the signal must be renamed. */ private String addString(String orig, Cell environment) { // remove all nonVHDL characters while adding to current string StringBuffer sb = new StringBuffer(); boolean nonAlnum = false; for(int i=0; i<orig.length(); i++) { char chr = orig.charAt(i); if (Character.isLetterOrDigit(chr)) sb.append(chr); else { sb.append('_'); nonAlnum = true; } } // if there were nonalphanumeric characters, this cannot be a VHDL keyword if (!nonAlnum) { // check for VHDL keyword clashes if (CompileVHDL.isKeyword(orig) != null) { sb.append('_'); return sb.toString(); } // "bit" isn't a keyword, but the compiler can't handle it if (orig.equalsIgnoreCase("bit")) { sb.append('_'); return sb.toString(); } } // see if there is a name clash if (environment != null) { for(Iterator<NodeInst> it = environment.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); if (!ni.isCellInstance()) continue; if (orig.equals(ni.getProto().getName())) { sb.append('_'); break; } } } return sb.toString(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -