FlatNode node; Iterator flatNodes = ssg.getFlatNodes().iterator(); while (flatNodes.hasNext()) { node = (FlatNode)flatNodes.next(); if (node.isFilter() && !tiles.contains(layout.getTile(node))) tiles.add(layout.getTile(node)); }
    public static void dumpSchedules()     {	//this is a hash set that keeps tiles that we have already generated	//code for	HashSet tilesGenerated = new HashSet();	for (int i = 0; i < streamGraph.getStaticSubGraphs().length; i++) {	    //get all the nodes that have either init switch code	    //or steady state switch code	    HashSet tiles = new HashSet();	    //SpaceDynamicBackend.addAll(tiles, layout.getTiles());	    StaticStreamGraph ssg = streamGraph.getStaticSubGraphs()[i];	    SpaceDynamicBackend.addAll(tiles, ssg.simulator.initSchedules.keySet());	    SpaceDynamicBackend.addAll(tiles, ssg.simulator.steadySchedules.keySet());	    	    //do not generate switchcode for Tiles assigned to file readers/writers	    //they are just dummy tiles	    Iterator fs = streamGraph.getFileVisitor().fileNodes.iterator();	    while (fs.hasNext()) {		tiles.remove(layout.getTile((FlatNode)fs.next()));	    }	    	    Iterator tileIterator = tiles.iterator();				    //for each tiles dump the code	    while(tileIterator.hasNext()) {		RawTile tile = (RawTile) tileIterator.next();				assert !tilesGenerated.contains(tile) : 		    "Trying to generated switch code for a tile that has already been seen";		tilesGenerated.add(tile);				try {		    //true if we are compressing the switch code		    boolean compression = false;		    		    //get the code		    String steadyCode = "";		    String initCode = "";		    if (ssg.simulator.initSchedules.get(tile) != null)			initCode = ((StringBuffer)ssg.simulator.initSchedules.get(tile)).toString();		    if (ssg.simulator.steadySchedules.get(tile) != null)			steadyCode = ((StringBuffer)ssg.simulator.steadySchedules.get(tile)).toString();		    		    //the sequences we are going to compress if compression is needed		    Repetition[] big3init = null;		    Repetition[] big3work = null;		    		    int codeSize = getCodeLength(steadyCode + initCode);		    if (codeSize > 5000) {			System.out.println("Compression needed.  Code size = " + codeSize);			compression = true;			big3init = threeBiggestRepetitions(initCode);			big3work = threeBiggestRepetitions(steadyCode);		    }		    		    FileWriter fw =			new FileWriter("sw" + tile.getTileNumber() 				       + ".s");		    fw.write("#  Switch code\n");		    fw.write(getHeader());		    //if this tile is the north neighbor of a bc file i/o device		    //we need to send a data word to it		    printIOStartUp(tile, fw);		    //print the code to get the repetition counts from the processor		    //print the init switch code		    if (big3init != null)			getRepetitionCounts(big3init, fw);		    toASM(initCode, "i", big3init, fw);		    //loop label		    if (big3work != null)			getRepetitionCounts(big3work, fw);		    fw.write("sw_loop:\n");		    //print the steady state switch code		    if (ssg.simulator.steadySchedules.get(tile) != null)			toASM(steadyCode, "w", big3work, fw);		    //print the jump ins		    fw.write("\tj\tsw_loop\n\n");		    fw.write(getTrailer(tile, big3init, big3work));		    fw.close();		    /*if (threeBiggest != null) {		      System.out.print("Found Seqeunces of: " +		      threeBiggest[0].repetitions + " " + t" " + 		      threeBiggest[1].repetitions + " " + threeBiggest[1].length + " " + 		      threeBiggest[2].repetitions + " " + threeBiggest[2].length + "\n");		      } */		    		    System.out.println("sw" + tile.getTileNumber() 				       + ".s written");		}		catch (Exception e) {		    e.printStackTrace();		    		    Utils.fail("Error creating switch code file for tile " + 			       tile.getTileNumber());		}	    }	}    }