⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 faultyoptimizedmapping.java~

📁 Java遗传算法库
💻 JAVA~
字号:
/* * OptimizedMapping.java * * Created on 25 November 2003, 15:39 */package jaga.pj.circuits.fpgaft;import jaga.BitSet;import jaga.pj.circuits.*;import java.util.Vector;import java.awt.Point;/** This will remove elements from the element array that aren't connected to the outputs * in order to optimize the circuit simulation by avoiding refreshing unused gates.  This will * obviously skew the position of these elements in the array making the getElementFromAddress * method useless. * * @author  mmg20 */public class FaultyOptimizedMapping implements CircuitMapping {        // Config    protected CircuitMapping inMap;    protected Point[] persistentFaults;        public FaultyOptimizedMapping(CircuitMapping inMap)    {        this( inMap, null );    }        /** Creates a new instance of OptimizedMapping */    public FaultyOptimizedMapping(CircuitMapping inMap, Point[] persistentFaults) {        this.inMap = inMap;        this.persistentFaults = persistentFaults;    }        public SimulatorLogicElement getElementFromAddress(SimulatorLogicElement[][] inoutels, int address) {        return inMap.getElementFromAddress( inoutels, address );    }        /** Takes and individual and an array of arrays of logic elements where this     * individual must be instantiated.     * @param individual The individual to be mapped into a circuit.     * @return Array consisting of three subarrays: The first will represent     * the inputs to the circuit and is where the inputs will be fed in.  The second     * represents the elements that are the outputs of the circuit and is where they     * will be read out from.  The last is an array with all the elements of the     * circuit.     */    public SimulatorLogicElement[][] map(BitSet individual)     {        SimulatorLogicElement[][] rv = inMap.map( individual );        SimulatorFaultyDelayLE[] elements = ( SimulatorFaultyDelayLE[] )rv[ ELEMENTS ];                for( int ql = 0; ql < rv[ 1 ].length; ql++ )        {            System.out.println("Q" + ql + " is "  + rv[ 1 ][ ql ] );        }                // Set faults if have any        if( persistentFaults != null )        {            for( int flp = 0; flp < persistentFaults.length; flp++ )            {                elements[ persistentFaults[ flp ].x ].setFault( persistentFaults[ flp ].y );            }        }                        rv[ ELEMENTS ] = trim( rv );                        return rv;    }        protected SimulatorFaultyDelayLE[] trim( SimulatorLogicElement[][] inoutels )    {        // Now optimize        int nrOuts = inoutels[ OUTPUTS ].length;        Vector added = CircuitsLib.addConnectedGates( inoutels[ OUTPUTS ] );        int nrUsed = added.size();        SimulatorFaultyDelayLE[] onlyUsedElements = new SimulatorFaultyDelayLE[ nrUsed ];                // Qs always in order for mapping without output def block        int removed = 0;        for( int ol = 0; ol < Math.min( nrOuts, nrUsed ); ol++ )        {            if( added.contains( inoutels[ OUTPUTS ][ ol ] ) ) // If it's not in added, then this output is pointing to a circuit input            {                onlyUsedElements[ removed++ ] = ( SimulatorFaultyDelayLE ) inoutels[ OUTPUTS ][ ol ];                added.remove( inoutels[ OUTPUTS ][ ol ] );            }            //System.out.println("Opt El " + ol + " is " + elements[ ol ] );        }                // The rest can go in any order        for( int ll = 0; ll < nrUsed - removed; ll++ )        {            onlyUsedElements[ ll + removed ] = ( SimulatorFaultyDelayLE ) added.get( ll );            //System.out.println("El " + ( ll + nrOuts ) + " in opt is " + jaga.ESLib.indexOf( onlyUsedLUTs[ ll + nrOuts ], elements ) + " in all " ); //D            //System.out.println("Opt El " + ( ll + nrOuts ) + " is " + onlyUsedElements[ ll + nrOuts ] );        }                return onlyUsedElements;    }            public void resetDelays(Object delayDef) {        inMap.resetDelays( delayDef );    }        public void setPersistentFaults( Point[] persistentFaults )    {        this.persistentFaults = persistentFaults;    }        public String toString()    {        String rv = "";        rv = "Fauly Optimized Mapping with internal mapping: " + inMap;        return rv;    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -