public void add(IntVector new_frees) { for (int i = 0; i < new_frees.size(); ++i) { free_list.push_back(new_frees[i]); } free_list.sort(); }
public void delete_index(int idx) { delete_count++; if ((double)delete_count / (double)free_list.size() > compact_ratio) { IntVector temp = new IntVector(16); for (int i = 0; i < free_list.size(); ++i) { if (idx == i) //just deleted, so won't be in free_list anymore { continue; } if (variables[free_list[i]] == null || variables[free_list[i]].type == NodeType.FREE) { temp.push_back(free_list[i]); } } free_list = temp; } }
public void write_blif(string filename) { StreamWriter outfile = new StreamWriter(filename); outfile.WriteLine(".model " + this.name); outfile.Write(".inputs"); for (int i = 0; i < primary_inputs.size(); ++i) { outfile.Write(" " + node(primary_inputs[i]).name); } outfile.WriteLine(); outfile.Write(".outputs"); for (int i = 0; i < primary_outputs.size(); ++i) { outfile.Write(" " + node(primary_outputs[i]).name); } outfile.WriteLine(); for (int i = 0; i < latches.size(); ++i) { Gate n = node(latches[i]); outfile.WriteLine(".latch " + node(n.fanins[0]).name + " " + n.name + " " + (int)n.latch_default); } for (int i = 0; i < combs.size(); ++i) { Gate n = node(combs[i]); outfile.Write(".names"); for (int j = 0; j < n.fanins.size(); ++j) { outfile.Write(" " + node(n.fanins[j]).name); } outfile.WriteLine(" " + n.name); if (n.gate_type == EGateType.G_NOT) { outfile.WriteLine("0 1"); } else if (n.gate_type == EGateType.G_AND_11) { outfile.WriteLine("11 1"); } else if (n.gate_type == EGateType.G_AND_10) { outfile.WriteLine("10 1"); } else if (n.gate_type == EGateType.G_AND_01) { outfile.WriteLine("01 1"); } else if (n.gate_type == EGateType.G_AND_00) { outfile.WriteLine("00 1"); } else if (n.gate_type == EGateType.G_OR_11) { outfile.WriteLine("1- 1" + '\n' + "-1 1"); } else if (n.gate_type == EGateType.G_OR_10) { outfile.WriteLine("1- 1" + '\n' + "-0 1"); } else if (n.gate_type == EGateType.G_OR_01) { outfile.WriteLine("0- 1" + '\n' + "-1 1"); } else if (n.gate_type == EGateType.G_OR_00) { outfile.WriteLine("0- 1" + '\n' + "-0 1"); } // else if (n.gate_type == EGateType.G_EQUAL) // outfile.WriteLine ( "11 1" + '\n' + "00 1" ); else if (n.gate_type == EGateType.G_CONST_1) { outfile.WriteLine("1 1" + '\n' + "0 1"); } else if (n.gate_type == EGateType.G_WIRE) { outfile.WriteLine("1 1" + '\n' + "0 0"); } else { fatal("Unknown gate type"); } } outfile.WriteLine(".end"); outfile.Close(); }