?? bistpimseqonlinefull_1.java~
字號:
/*
* BISTIM.java
*
* Created on 19 May 2002, 18:56
*/
package jaga.pj.circuits.control;
import jaga.evolve.Evolver;
import jaga.deploy.Deployment;
import jaga.experiment.*;
import jaga.control.StandardInteractionModel;
import jaga.*;
import jaga.pj.circuits.CircuitState;
import jaga.pj.circuits.fpgaft.*;
import jaga.pj.circuits.SimulatorLogicElement;
import jaga.pj.circuits.experiment.ConfigurableSequentialCircuitExperiment;
import jaga.pj.circuits.experiment.MealyFSMEdge;
import jaga.pj.circuits.experiment.MealyFSMNode;
import java.util.Random;
import java.util.Vector;
import java.util.Hashtable;
import islandev.SnapshotPainter;
import islandev.EmptySnapshotPainter;
/** Like BISTPIM but:
* <ul><li>Only On-Line BIST evaluated (must report first fault affecting outputs)</li>
* <li>Optimization in SimulatorFaultyCircuitOpt used for sequenial circuits</li>
* <li>For combinational circuits use BISTPIM</li>
* <li>Overdetecting always good.
* </ul>
*
* Could cache generated TPS per generation for use with NoisyIM
*/
public class BISTPIMSeqOnlineFull extends StandardInteractionModel
{
// Constants
final int E_HIGH = 1;
final int E_LOW_OK = 0;
final int E_LOW_ERROR = -1;
final int nrEs = 1;
// Config Vars
// Variables for finding E
protected int startAt = 0; // For each input cycle, start at ...
protected int inputResetLength = 0;
protected int eSize;
protected int DQTol;
// Variable for extracting value of output (kind of inverse of t_setup)
protected double threshold = 0.1;
//Working Vars
protected double currMaxF_e = -1;
protected SingleFaultModel faultModel;
protected SingleRandomFaultModel srfm = null; // If its randomness, its randomness will need to be controlled
protected ConfigurableSequentialCircuitExperiment scexp;
protected SimulatorFaultyCircuit circuit;
protected Hashtable TPS = new Hashtable();
/** Evaluate a sequential circuit's BIST behaviour under all State, Fault, Input combinations
* @param evo Evolver
* @param dep Deployment
* @param cir A SimulatorFaultyCircuit which must allow running a section of a test pattern
* @param exp A Configurable Sequential Circuit Experiment to know at what point in the test pattern new states are entered
* @param iss Input Sample Separation
* @param fm Fault Model
* @param es Number of consecutve highs at the error line E to trigger a "fault detected" event
* @param painter Circuit painter
* @param startAt Position within test cycle of length input sample separation until which we can ignore behaviour
* @param inputResetLength How many input cycles it takes to bring this sequential circuit to its reset state
*/
public BISTPIMSeqOnlineFull(Evolver evo, Deployment dep, SimulatorFaultyCircuit cir, ConfigurableSequentialCircuitExperiment exp, int iss, SingleFaultModel fm, int es, int DQTol, SnapshotPainter painter, int startAt, int inputResetLength) {
this( evo, dep, cir, exp, iss, fm, es, DQTol );
this.painter = painter;
this.startAt = startAt;
this.inputResetLength = inputResetLength;
}
public BISTPIMSeqOnlineFull(Evolver evo, Deployment dep, SimulatorFaultyCircuit cir, ConfigurableSequentialCircuitExperiment exp, int iss, SingleFaultModel fm, int es, int DQTol) {
super( evo, dep, exp, iss );
scexp = exp;
circuit = cir;
faultModel = fm;
if( faultModel instanceof SingleRandomFaultModel )
{
srfm = ( SingleRandomFaultModel ) fm;
}
eSize = es;
this.DQTol = DQTol;
// Build TPS: Test Patterns to apply at each state s such that all leaving arrows are tested.
MealyFSMNode[] allStates = exp.getStateGraphNodes();
int nrStates = allStates.length;
int nrIns = exp.getNumOfInputs();
int nrNoCkIns = nrIns - 1;
int nrNoCkVectors = 1 << nrNoCkIns;
for( int sl = 0; sl < nrStates; sl++ )
{
// 1. Create TP BitSets
MealyFSMNode currState = allStates[ sl ];
BitSet[] testBits = new BitSet[ nrIns ];
int nrEdges = currState.getNumOfEdges();
for( int bl = 0; bl < nrIns; bl++ )
{
testBits[ bl ] = new BitSet( nrEdges );
}
// 2. Fill up TP BitSets
int TPPos = 0;
for( int el = 0; el < nrNoCkVectors; el++ )
{
if( currState.nextStates[ el ] != null )
{
ESLib.setLine( testBits, TPPos++, el * 2 ); // * 2 because last line (clock) = 0
}
}
// 3. Generate SampleData TP from BitSets
//SampleData[] currTPS = ExperimentLib.generateInputFromTest( testBits, 1, nrEdges, inputSampleSeparation );
// 4. Store TP in TPS Hashset
TPS.put( currState, testBits );
}
}
public void evolve()
{
super.evolve();
if( srfm != null )
{
srfm.nextRandomSeries(); // Same for all per generation, but != 'tween generations.
}
currMaxF_e = -1;
}
/** Evaluates these individuals using the deployment and experiments and
* procedure of this model.
*/
synchronized public double[] evaluate(Genotype[] inds)
{
Genotype ind = inds[ 0 ];
// 1) Evaluate Ind with no faults.
deployment.program( ind );
SampleData[] input = experiment.generateInput( inputSampleSeparation );
int[] stateEnterPos = scexp.getStateEnterPos();
MealyFSMNode[] stateEnterNodes = scexp.getStateGraphNodes();
int nrStates = stateEnterPos.length;
int prevStateTPPos = 0;
CircuitState currentState;
//TI//if( !stateNoise ) {
//TI//circuit.reset();
//TI//}else{
//circuit.randomReset();
//TI//}
SampleData[] noFQWithE = deployment.run( input );
int nrOuts = noFQWithE.length - 1;
SampleData[] noFQNoE = ESLib.getLines( noFQWithE, 0, nrOuts );
double f_e = experiment.getFitness( input, noFQNoE );
double f_b = 0, f_b_t = 0;
boolean mainTaskOK = f_e > currMaxF_e - threshold;
// 2) Compute f_b now for all combinations of inputs under every fault at each state
if( mainTaskOK && !getE( noFQWithE ) ) // Check that E low for no faults! If it isn't, then discard.
{
Hashtable shuffledTPS = new Hashtable();
Hashtable TPQS = new Hashtable();
Hashtable circuitStates = new Hashtable();
Hashtable EBehaviour = new Hashtable();
currMaxF_e = Math.max( f_e, currMaxF_e );
// 2.1) Init variables.
boolean[] used = getUsed( nrOuts ); // Skipping faults in unused elements.
int nrInstances = 1; // how many faults tested for
int diagInstances = 1; // how many correctly diagnosed, including no faults.
// 2.2) Move to every state in turn
for( int sl = 0; sl < nrStates; sl++ )
{
circuit.run( input, prevStateTPPos, stateEnterPos[ sl ] + 1 ); // **
prevStateTPPos = stateEnterPos[ sl ];
MealyFSMNode currNode = stateEnterNodes[ sl ];
//TI//longStory += "\nMoving to state " + sl + "(" + currNode + ") at " + stateEnterPos[ sl ] ;
// 2.2.1) Save state
currentState = circuit.getState();
circuitStates.put( currNode, currentState );
// 2.2.2) Save no faults behaviour in current state for all inputs
BitSet[] TPSBits = ( BitSet[] ) TPS.get( currNode );
BitSet[] shuffledTPSBits = ExperimentLib.shuffleTest( TPSBits );
shuffledTPS.put( currNode, shuffledTPSBits );
SampleData[] currTPS = ExperimentLib.generateInputFromTest( shuffledTPSBits, 1, shuffledTPSBits[ 0 ].length(), inputSampleSeparation );
int nrInputCombinations = currTPS[ 0 ].length();
SampleData[] currStateQs = circuit.run( currTPS );
TPQS.put( currNode, currStateQs );
//TI//longStory += "\nBehaviour " + ESLib.sampleDatasToString( currTPS, currStateQs );
// 2.3) Iterate through faults
faultModel.reset();
while( faultModel.hasMoreElements() )
{
java.awt.Point currFault = ( java.awt.Point ) faultModel.nextElement();
if( used[ currFault.x ] ) // Skipping faults in unused elements.
{
circuit.setFault( currFault );
SampleData[] currStateFaultQs = circuit.run( currTPS );
int[] eBehaviour = new int[ nrInputCombinations ];
int newInstances = countDiagnoses( currStateQs, currStateFaultQs, eBehaviour );
Vector currStateFaultKey = new Vector();
currStateFaultKey.add( currNode );
currStateFaultKey.add( currFault );
EBehaviour.put( currStateFaultKey, eBehaviour );
diagInstances += newInstances;
nrInstances += nrInputCombinations;
// TI // longStory += currFault + ": " + newInstances + " out of " + nrInputCombinations;
circuit.removeFault( currFault );
circuit.setState( currentState );
}
}
}
f_b = 1d / ( ( nrInstances - diagInstances ) / 25d + 1d );
// 3) Compute f_b_t transitions
// For now only evalaute f_b_t if f_t = f_b = 1
if( f_e > 0.9999 && f_b > 0.9999 )
{
int incorrectTransitions = 0;
// 3.1) At every state
for( int sl = 0; sl < nrStates; sl++ )
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -