📄 usercom.java
字号:
// * Class simulates the operation of a FIFO element in a data// * communication system. Data is stored in a block of memory of fixed// * size. Read and write counters are used to index the memory array. This// * approach was chosen because this structure will simulate much faster than a// * linked list.// *// * Calling Arguments:// * primHead = pointer to a structure containing the calling arguments for// * the user defined function. The nodes are stored in the list// * in the following order: input, output, size// */// private static final int FIFO_SIZE = 2048;//// static class FIFOMem// {// int rPtr;// int wPtr;// int [] state;// }//// static class FIFO extends ALS.UserProc// {// FIFO(ALS als) { nameMe(als, "FIFO"); }//// void simulate(ALS.Model primHead)// {// ALS.ALSExport argPtr = primHead.exList.get(0);// ALS.ALSExport inputPtr = argPtr;// argPtr = primHead.exList.get(1);// ALS.ALSExport outputPtr = argPtr;// argPtr = primHead.exList.get(2);// ALS.ALSExport sizePtr = argPtr;//// ALS.Func funcHead = (ALS.Func) primHead.ptr;// FIFOMem fifoHead = (FIFOMem) funcHead.userPtr;// if (fifoHead == null)// {// fifoHead = new FIFOMem();// fifoHead.rPtr = 0;// fifoHead.wPtr = 0;// fifoHead.state = new int[FIFO_SIZE];// funcHead.userPtr = fifoHead;// }//// if (inputPtr.nodePtr.sumState > 0)// {// scheduleNodeUpdate(primHead, inputPtr, '=',// new Integer(0), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, inputPtr, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// if (sizePtr.nodePtr.sumState >= FIFO_SIZE)// {// System.out.println("Data loss has occured: Value = " + inputPtr.nodePtr.sumState + ", Time = " + als.timeAbs);// return;// }// int newSize = sizePtr.nodePtr.sumState + 1;// scheduleNodeUpdate(primHead, sizePtr, '=',// new Integer(newSize), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, sizePtr, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// fifoHead.state[fifoHead.wPtr] = inputPtr.nodePtr.sumState;// fifoHead.wPtr = ((fifoHead.wPtr) + 1) % FIFO_SIZE;// }//// if (outputPtr.nodePtr.sumState == 0 && sizePtr.nodePtr.sumState != 0)// {// scheduleNodeUpdate(primHead, outputPtr, '=',// new Integer(fifoHead.state[fifoHead.rPtr]), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, outputPtr, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// int newSize = sizePtr.nodePtr.sumState - 1;// scheduleNodeUpdate(primHead, sizePtr, '=',// new Integer(newSize), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, sizePtr, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// fifoHead.rPtr = ((fifoHead.rPtr) + 1) % FIFO_SIZE;// }// }// }//// /**// * Class examines the bus to see if a message is destined for it.// * If so, the data value is examined to determine if the link that the data byte// * passed across is in a "congested" state. If so this element must fire an// * XOFF character to the station on the remote side of the connection. The// * data value is also passed to a gate which will examine the byte and increment// * the appropriate counter.// *// * Calling Arguments:// * primHead = pointer to a structure containing the calling arguments for// * the user defined function. The nodes are stored in the list// * in the following order: address, addIn, dataIn, dataType,// * remXOff, addOut, dataOut// */// static class RXData extends ALS.UserProc// {// RXData(ALS als) { nameMe(als, "RX_DATA"); }//// void simulate(ALS.Model primHead)// {// ALS.ALSExport address = primHead.exList.get(0);// ALS.ALSExport addIn = primHead.exList.get(1);// if (address.nodePtr.sumState != addIn.nodePtr.sumState) return;// ALS.ALSExport dataIn = primHead.exList.get(2);// ALS.ALSExport dataType = primHead.exList.get(3);// ALS.ALSExport remXOff = primHead.exList.get(4);// ALS.ALSExport addOut = primHead.exList.get(5);// ALS.ALSExport dataOut = primHead.exList.get(6);//// scheduleNodeUpdate(primHead, addIn, '=',// new Integer(0), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, addIn, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, dataIn, '=',// new Integer(0), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, dataIn, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// if (((dataIn.nodePtr.sumState) % 2) != 0)// {// scheduleNodeUpdate(primHead, dataType, '=',// new Integer(dataIn.nodePtr.sumState), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, dataType, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// if (remXOff.nodePtr.sumState != 0)// {// scheduleNodeUpdate(primHead, remXOff, '=',// new Integer(0), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, remXOff, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, addOut, '=',// new Integer(address.nodePtr.sumState), Stimuli.VDD_STRENGTH, als.timeAbs + 50e-6);// scheduleNodeUpdate(primHead, addOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs + 50e-6);// scheduleNodeUpdate(primHead, dataOut, '=',// new Integer(5), Stimuli.VDD_STRENGTH, als.timeAbs + 50e-6);// scheduleNodeUpdate(primHead, dataOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs + 50e-6);// }// } else// {// scheduleNodeUpdate(primHead, dataType, '=',// new Integer(((dataIn.nodePtr.sumState) - 1)), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, dataType, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// if (remXOff.nodePtr.sumState == 0)// {// scheduleNodeUpdate(primHead, remXOff, '=',// new Integer(1), Stimuli.VDD_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, remXOff, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs);// scheduleNodeUpdate(primHead, addOut, '=',// new Integer(address.nodePtr.sumState), Stimuli.VDD_STRENGTH, als.timeAbs + 50e-6);// scheduleNodeUpdate(primHead, addOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs + 50e-6);// scheduleNodeUpdate(primHead, dataOut, '=',// new Integer(7), Stimuli.VDD_STRENGTH, als.timeAbs + 50e-6);// scheduleNodeUpdate(primHead, dataOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.OFF_STRENGTH, als.timeAbs + 50e-6);// }// }// }// }//// static class AFRegisters extends ALS.UserProc// {// AFRegisters(ALS als) { nameMe(als, "A_F_REGISTERS"); }//// void simulate(ALS.Model primHead)// {// ALS.ALSExport ck = primHead.exList.get(0);// ALS.ALSExport aIn = primHead.exList.get(1);// ALS.ALSExport aLoad = primHead.exList.get(2);// ALS.ALSExport fIn = primHead.exList.get(3);// ALS.ALSExport fLoad = primHead.exList.get(4);// ALS.ALSExport aMid = primHead.exList.get(5);// ALS.ALSExport aOut = primHead.exList.get(6);// ALS.ALSExport fMid = primHead.exList.get(7);// ALS.ALSExport fOut = primHead.exList.get(8);//// if (ck.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// if (aLoad.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// scheduleNodeUpdate(primHead, aMid, '=',// new Integer(aIn.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// if (fLoad.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// scheduleNodeUpdate(primHead, fMid, '=',// new Integer(fIn.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// return;// }//// if (ck.nodePtr.sumState == Stimuli.LOGIC_LOW)// {// if (aLoad.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// scheduleNodeUpdate(primHead, aOut, '=',// new Integer(aMid.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// if (fLoad.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// scheduleNodeUpdate(primHead, fOut, '=',// new Integer(fMid.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// return;// }//// scheduleNodeUpdate(primHead, aMid, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// scheduleNodeUpdate(primHead, aOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// scheduleNodeUpdate(primHead, fMid, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// scheduleNodeUpdate(primHead, aOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// }//// static class ControlLogic extends ALS.UserProc// {// ControlLogic(ALS als) { nameMe(als, "CONTROL_LOGIC"); }//// void simulate(ALS.Model primHead)// {// ALS.ALSExport aIn = primHead.exList.get(0);// ALS.ALSExport fIn = primHead.exList.get(1);// ALS.ALSExport b = primHead.exList.get(2);// ALS.ALSExport msb = primHead.exList.get(3);// ALS.ALSExport aOut = primHead.exList.get(4);// ALS.ALSExport fOut = primHead.exList.get(5);//// if (b.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// scheduleNodeUpdate(primHead, aOut, '=',// new Integer(aIn.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// } else// {// if (b.nodePtr.sumState == Stimuli.LOGIC_LOW)// {// scheduleNodeUpdate(primHead, aOut, '=',// new Integer(Stimuli.LOGIC_LOW), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// } else// {// scheduleNodeUpdate(primHead, aOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// }//// if (msb.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// scheduleNodeUpdate(primHead, fOut, '=',// new Integer(fIn.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// } else// {// if (msb.nodePtr.sumState == Stimuli.LOGIC_LOW)// {// scheduleNodeUpdate(primHead, fOut, '=',// new Integer(Stimuli.LOGIC_LOW), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// } else// {// scheduleNodeUpdate(primHead, fOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// }// }// }//// static class Mod2Adder extends ALS.UserProc// {// Mod2Adder(ALS als) { nameMe(als, "MOD2_ADDER"); }//// void simulate(ALS.Model primHead)// {// ALS.ALSExport aIn = primHead.exList.get(0);// ALS.ALSExport fIn = primHead.exList.get(1);// ALS.ALSExport pIn = primHead.exList.get(2);// ALS.ALSExport ck = primHead.exList.get(3);// ALS.ALSExport out = primHead.exList.get(4);//// if (ck.nodePtr.sumState == Stimuli.LOGIC_LOW)// {// scheduleNodeUpdate(primHead, out, '=',// new Integer(Stimuli.LOGIC_LOW), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// return;// }//// int sum = 0;// if (ck.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// if (aIn.nodePtr.sumState == Stimuli.LOGIC_HIGH) ++sum;// if (fIn.nodePtr.sumState == Stimuli.LOGIC_HIGH) ++sum;// if (pIn.nodePtr.sumState == Stimuli.LOGIC_HIGH) ++sum;//// sum %= 2;// if (sum != 0)// {// scheduleNodeUpdate(primHead, out, '=',// new Integer(Stimuli.LOGIC_HIGH), Stimuli.GATE_STRENGTH, als.timeAbs + 5.0e-9);// } else// {// scheduleNodeUpdate(primHead, out, '=',// new Integer(Stimuli.LOGIC_LOW), Stimuli.GATE_STRENGTH, als.timeAbs + 5.0e-9);// }// return;// }//// scheduleNodeUpdate(primHead, out, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 5.0e-9);// }// }//// static class AboveAdder extends ALS.UserProc// {// AboveAdder(ALS als) { nameMe(als, "ABOVE_ADDER"); }//// void simulate(ALS.Model primHead)// {// ALS.ALSExport ck = primHead.exList.get(0);// ALS.ALSExport sync = primHead.exList.get(1);// ALS.ALSExport loadOSR = primHead.exList.get(2);// ALS.ALSExport sumIn = primHead.exList.get(3);// ALS.ALSExport osrIn = primHead.exList.get(4);// ALS.ALSExport osrMid = primHead.exList.get(5);// ALS.ALSExport osrOut = primHead.exList.get(6);// ALS.ALSExport pMid = primHead.exList.get(7);// ALS.ALSExport pOut = primHead.exList.get(8);//// if (ck.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// if (loadOSR.nodePtr.sumState == Stimuli.LOGIC_LOW)// {// scheduleNodeUpdate(primHead, pMid, '=',// new Integer(sumIn.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// scheduleNodeUpdate(primHead, osrMid, '=',// new Integer(osrIn.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// if (loadOSR.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// scheduleNodeUpdate(primHead, osrMid, '=',// new Integer(sumIn.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// if (sync.nodePtr.sumState == Stimuli.LOGIC_HIGH)// {// scheduleNodeUpdate(primHead, pMid, '=',// new Integer(Stimuli.LOGIC_LOW), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// return;// }//// if (ck.nodePtr.sumState == Stimuli.LOGIC_LOW)// {// if (loadOSR.nodePtr.sumState == Stimuli.LOGIC_LOW)// {// scheduleNodeUpdate(primHead, osrOut, '=',// new Integer(osrMid.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// scheduleNodeUpdate(primHead, pOut, '=',// new Integer(pMid.nodePtr.sumState), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// return;// }//// scheduleNodeUpdate(primHead, osrMid, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// scheduleNodeUpdate(primHead, osrOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// scheduleNodeUpdate(primHead, pMid, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// scheduleNodeUpdate(primHead, pOut, '=',// new Integer(Stimuli.LOGIC_X), Stimuli.GATE_STRENGTH, als.timeAbs + 3.0e-9);// }// }//// /**// * Class converts the value of 12 input bits into a state// * representation in the range. This function can be called for// * the compact representation of the state of a bus structure in hexadecimal// * format.// *// * Calling Arguments:// * primHead = pointer to a structure containing the calling arguments for// * the user defined function. The nodes are ordered b7, b6, b5,// * b4, b3, b2, b1, b0, output in this list.// */// static class Bus12ToState extends ALS.UserProc// {// Bus12ToState(ALS als) { nameMe(als, "BUS12_TO_STATE"); }//// void simulate(ALS.Model primHead)// {// Iterator it = primHead.exList.iterator();// ALS.ALSExport argPtr = it.next();// int state = 0;// for (int i = 11; i > -1; --i)// {// int bit = argPtr.nodePtr.sumState;// if (bit == Stimuli.LOGIC_HIGH) state += (0x01 << i);// argPtr = it.next();// }//// scheduleNodeUpdate(primHead, argPtr, '=',// new Integer(state), Stimuli.VDD_STRENGTH, als.timeAbs);// }// }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -