📄 bistlib.java~
字号:
int val2 = jaga.ESLib.getLine( outs, end - 1, 0, lastOut ); if( val0 == val2 ) { return val0; } } return -1; } public static int countDiagnoses( SampleData[] currStateQs, SampleData[] currStateFaultQs, int[] eBehaviour, int eSize, int nrZs, int iss, int EStartAt, int DQTol ) { int rv = 0; int patternBlocks = eBehaviour.length; for( int pl = 0; pl < patternBlocks; pl++ ) { if( getE( currStateFaultQs, pl, eSize, nrZs, iss, EStartAt ) ) { rv++; // Assume overdetecting OK eBehaviour[ pl ] = E_BEHAVIOUR_HIGH; }else { // Outputs should be the same if( getEqual( currStateQs, currStateFaultQs, pl, iss, EStartAt, DQTol ) ) { rv++; eBehaviour[ pl ] = E_BEHAVIOUR_LOW_OK; }else { eBehaviour[ pl ] = E_BEHAVIOUR_LOW_ERROR; } } } return rv; } protected static boolean getEqual( SampleData[] currStateQs, SampleData[] currStateFaultQs, int blockNum, int iss, int EStartAt, int DQTol ) { int DQ = 0; int idl = blockNum; for( int odl = EStartAt; odl < iss; odl++ ) { boolean currLineWrong = false; for( int ql = 0; ql < currStateQs.length - 1; ql++ ) { if( currStateQs[ ql ].get( idl * iss + odl ) != currStateFaultQs[ ql ].get( idl * iss + odl ) ) { currLineWrong = true; } } if( currLineWrong ) { DQ++; if( DQ == DQTol ) { return false; } } } return true; } public static ArrayList getDestinations( BitSet genotype, int ix, int lutIns, int bpv, int qDefs ) { ArrayList rv = new ArrayList(); int genotypeLen = genotype.length(); int lutSize = ( 1 << lutIns ); int geneLen = lutSize + bpv * lutIns; int qDefSize = qDefs * bpv; int nrGenes = ( genotypeLen - qDefSize ) / geneLen; for( int gl = 0; gl < nrGenes; gl++ ) { for( int il = 0; il < lutIns; il++ ) { int gPos = qDefSize + geneLen * gl + lutSize + bpv * il ; int inputAddress = genotype.bitsToInt( gPos, gPos + bpv ); if( inputAddress == ix ) { rv.add( new Integer( gl ) ); } } } return rv; } public static int getLUT( BitSet genotype, int ix, int lutIns, int bpv, int qDefs ) { int lutSize = ( 1 << lutIns ); int geneLen = lutSize + bpv * lutIns; int qDefSize = qDefs * bpv; int gPos = qDefSize + geneLen * ix; return genotype.bitsToInt( gPos, gPos + lutSize ); } public static void invertLUT( BitSet genotype, int ix, int lutIns, int bpv, int qDefs ) { int lutSize = ( 1 << lutIns ); int geneLen = lutSize + bpv * lutIns; int qDefSize = qDefs * bpv; int gPos = qDefSize + geneLen * ix; for( int bl = gPos; bl < gPos + lutSize; bl++ ) { genotype.flip( bl ); } } public static int[] getSources( BitSet genotype, int ix, int lutIns, int bpv, int qDefs ) { return getSources( genotype, ix, lutIns, bpv, qDefs, 0 ); } public static int[] getSources( BitSet genotype, int ix, int lutIns, int bpv, int qDefs, int extraGeneLen ) { int[] rv = new int[ lutIns ]; int lutSize = ( 1 << lutIns ); int geneLen = lutSize + bpv * lutIns + extraGeneLen; int qDefSize = qDefs * bpv; int gPos = qDefSize + geneLen * ix + lutSize; for( int il = 0; il < lutIns; il++ ) { rv[ il ] = genotype.bitsToInt( gPos + il * bpv, gPos + ( il + 1 ) * bpv ); } return rv; } public static BitSet xorBISTToDualRailVassilev( BitSet genotype, int bpv, int xorNrOuts, int nrIns ) { final int LUT_INS = 2; final int Q_DEFS = 0; // Gate types final int XOR = 6; final int NXOR = 9; final int BUFF_A = 3; int xorBISTLen = genotype.length(); int drNrOuts = xorNrOuts + 1; int drLen = xorBISTLen + drNrOuts * bpv; int xorIx = xorNrOuts - 1; BitSet rv = new BitSet( drLen ); for( int ql = 0; ql < xorIx; ql++ ) { rv.intToBits( ql, ql * bpv, bpv ); } int lut = getLUT( genotype, xorIx, LUT_INS, bpv, Q_DEFS ); // The following if statement checks if the E is redirected as in Locked benchmarks if( lut == BUFF_A ) { int[] buffSources = getSources( genotype, xorIx, LUT_INS, bpv, Q_DEFS ); xorIx = buffSources[ 0 ]; System.out.println("Error output Buffered from " + xorIx ); lut = getLUT( genotype, xorIx, LUT_INS, bpv, Q_DEFS ); } int[] eAdd = getSources( genotype, xorIx, LUT_INS, bpv, Q_DEFS ); rv.intToBits( eAdd[ 0 ], ( drNrOuts - 2 ) * bpv, bpv ); rv.intToBits( eAdd[ 1 ], ( drNrOuts - 1 ) * bpv, bpv ); for( int bl = 0; bl < xorBISTLen; bl++ ) { rv.setTo( drNrOuts * bpv + bl, genotype.get( bl ) ); } if( lut == XOR ) { ArrayList destE0 = getDestinations( genotype, eAdd[ 0 ], LUT_INS, bpv, Q_DEFS ); ArrayList destE1 = getDestinations( genotype, eAdd[ 1 ], LUT_INS, bpv, Q_DEFS ); int ixOfLUTToInvert; if( destE0.size() < destE1.size() ) { ixOfLUTToInvert = eAdd[ 0 ]; }else { ixOfLUTToInvert = eAdd[ 1 ]; } System.out.println("Inverting LUT address " + ixOfLUTToInvert ); invertLUT( rv, ixOfLUTToInvert, LUT_INS, bpv, drNrOuts ); }else if( lut != NXOR ) { System.out.println("E unit not XOR - Can't convert!"); return null; } return rv; } public static BitSet FPGABISTToDualRail( BitSet genotype, int bpl, int eNrOuts, int nrIns ) { int bpa = bpl + 1; int LUT_INS = 4; // default but should work with two FPGALUTAbsoluteMapping circuitMapping = new FPGALUTAbsoluteMapping( nrIns, eNrOuts, bpl, LUT_INS, new ConstantDelayModel( 0 ) ); SimulatorCircuit circuit = new SimulatorSimpleCircuit( circuitMapping ); circuit.reconfigure( genotype ); boolean[] used = CircuitsLib.getUsed( circuit ); int firstFreeIx = -1; for( int el = 0; ( firstFreeIx < 0 ) && el < used.length; el++ ) { if( !used[ el ] ) { firstFreeIx = el; } } if( firstFreeIx < 0 ) { System.out.println("No free LUT for Z1. Aborting."); return null; } int drNrOuts = eNrOuts + 1; int eIx = genotype.bitsToInt( ( eNrOuts - 1 ) * bpa, eNrOuts * bpa ); if( eIx > ( 1 << bpl ) ) { System.out.println("E source is Latch"); } int eGenLen = genotype.length(); int drGenLen = eGenLen + bpa; int LUTSize = 1 << LUT_INS; int geneLen = LUTSize + ( LUT_INS + 1 ) * bpa; BitSet rv = new BitSet( drGenLen ); // 1. Set outputs |Y|+1 as before. for( int bl = 0; bl < bpa * eNrOuts; bl++ ) { rv.setTo( bl, genotype.get( bl ) ); } // 2. Set |Y|+2 to Z1 (first unused) rv.intToBits( firstFreeIx, bpa * eNrOuts, bpa ); // 3. Copy Rest for( int bl = bpa * eNrOuts; bl < eGenLen; bl++ ) { rv.setTo( bl + bpa, genotype.get( bl ) ); } //4. Configure Z1: (a)LUT and (b) inputs int Z1GenPos = drNrOuts * bpa + geneLen * firstFreeIx; rv.intToBits( ( 1 << LUTSize ) - 1, Z1GenPos, LUTSize ); System.out.println("getting sources of lut ix" + eIx ); int[] eSources = getSources( genotype, eIx, LUT_INS, bpa, eNrOuts, bpa ); for( int il = 0; il < LUT_INS; il++ ) { System.out.println("Setting z1 source " + il + " to " + eSources[ il ] ); rv.intToBits( eSources[ il ], Z1GenPos + LUTSize + bpa * il, bpa ); } return rv; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -