📄 simulatorfaultydelayle.java~
字号:
/*
* SimulatorFaultyDelayLE.java
*
* Created on 16 January 2002, 00:33
*/
package jaga.pj.circuits.fpgaft;
import jaga.pj.circuits.SimulatorLogicElement;
import jaga.pj.circuits.SimulatorDelayLE;
/** Extend this class to make Logic Elements with efficient fault modelling.
*
* For now only models SSA faults at output or input. Only a single input can be failing
* at any moment.
*
* @author Michael Garvie
* @version
*/
public class SimulatorFaultyDelayLE extends SimulatorDelayLE
{
/** Defines if this element has a Single Stuck At Fault. */
public boolean SSA = false;
/** If it has a SSA fault, what it's stuck at. */
public boolean SSAV;
public SimulatorLogicElement faultyInput = null;
public int faultyInputIndex = -1;
public void setFault( int faultID )
{
switch( faultID )
{
case FTLib.NOFAULT:
SSA = false;
if( faultyInputIndex >= 0 )
{
// Might be more efficient to always do this instead of putting in if statement...
inputs[ faultyInputIndex ] = faultyInput;
faultyInput = null;
faultyInputIndex = -1;
}
break;
case FTLib.SSAV0:
SSAV = false;
SSA = true;
currentOutput = SSAV;
break;
case FTLib.SSAV1:
SSAV = true;
SSA = true;
currentOutput = SSAV;
break;
default:
// Fault is at gate input
faultyInputIndex = faultID / 2 - 1;
int stuckAtInt = faultID % 2;
boolean stuckAt = stuckAtInt == 1;
faultyInput = inputs[ faultyInputIndex ];
inputs[ faultyInputIndex ] = new SimulatorDelayLE( 0 );
inputs[ faultyInputIndex ].setNow( stuckAt ); // and will never be refreshed
break;
}
}
/** Creates new SimulatorFaultyDelayLE */
public SimulatorFaultyDelayLE(int delay) {
super( delay );
}
public final boolean getNow( )
{
if( SSA )
{
return SSAV;
}else
{
return currentOutput; // or super.getNow();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -