Skip to content

Commit 0872f7f

Browse files
author
Timothy Jones
committed
Ensure proper input order.
1 parent 7f706e3 commit 0872f7f

4 files changed

Lines changed: 36 additions & 13 deletions

File tree

cello/cello-placing/src/main/java/org/cellocad/v2/placing/algorithm/Eugene/Eugene.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private void setDevices() {
175175
while (node != null) {
176176
final Collection<StructureDevice> devices =
177177
EugeneUtils.getDevices(
178-
node, getTargetDataInstance().getGates(), getTargetDataInstance().getOutputDevices());
178+
node, getTargetDataInstance());
179179
getDevicesMap().put(node, devices);
180180
for (final StructureDevice d : devices) {
181181
getDeviceNameNetlistNodeMap().put(d.getName(), node);

cello/cello-placing/src/main/java/org/cellocad/v2/placing/algorithm/Eugene/EugeneUtils.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,12 @@ public static CObjectCollection<Part> getInputs(
234234
*/
235235
static Collection<StructureDevice> getDevices(
236236
final NetlistNode node,
237-
final CObjectCollection<Gate> gates,
238-
final CObjectCollection<OutputDevice> reporters) {
237+
final TargetDataInstance tdi) {
239238
final Collection<StructureDevice> rtn = new ArrayList<>();
240239
final String gateType = node.getResultNetlistNodeData().getDeviceName();
241240
final Integer num = node.getNumInEdge();
242-
final Gate gate = gates.findCObjectByName(gateType);
243-
final OutputDevice reporter = reporters.findCObjectByName(gateType);
241+
final Gate gate = tdi.getGates().findCObjectByName(gateType);
242+
final OutputDevice reporter = tdi.getOutputDevices().findCObjectByName(gateType);
244243
if (reporter != null) {
245244
final Collection<StructureDevice> devices = reporter.getStructure().getDevices();
246245
Integer i = 0;
@@ -271,20 +270,31 @@ static Collection<StructureDevice> getDevices(
271270
if (gate != null) {
272271
final Collection<StructureDevice> devices = gate.getStructure().getDevices();
273272
Integer i = 0;
273+
Map<Input, Part> inputMap = getInputsMap(node, tdi);
274274
for (final StructureDevice d : devices) {
275275
final StructureDevice e = new StructureDevice(d);
276276
final Collection<StructureTemplate> inputs = new ArrayList<>();
277+
final Collection<StructureTemplate> empty = new ArrayList<>();
277278
for (final StructureObject o : e.getComponents()) {
278279
if (o instanceof StructureTemplate) {
279280
i++;
280281
final StructureTemplate t = (StructureTemplate) o;
281-
if (i <= num) {
282-
continue;
282+
for (Input input : inputMap.keySet()) {
283+
if (input.getName().equals(o.getName())) {
284+
inputs.add(t);
285+
}
283286
}
284-
inputs.add(t);
285287
}
286288
}
287-
for (final StructureTemplate t : inputs) {
289+
for (final StructureObject o : e.getComponents()) {
290+
if (o instanceof StructureTemplate) {
291+
final StructureTemplate t = (StructureTemplate) o;
292+
if (!inputs.contains(t)) {
293+
empty.add(t);
294+
}
295+
}
296+
}
297+
for (StructureTemplate t : empty) {
288298
e.getComponents().remove(t);
289299
}
290300
for (final StructureObject o : e.getComponents()) {

cello/cello-placing/src/main/java/org/cellocad/v2/placing/algorithm/Eugene/target/data/data/EugeneDevice.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,18 @@ public EugeneDevice(final StructureDevice device, final Map<Input, Part> map) {
5757
super(device);
5858
List<StructureObject> components = new ArrayList<>();
5959
for (StructureObject obj : this.getComponents()) {
60+
Boolean emptyInput = false;
6061
if (obj instanceof StructureTemplate) {
6162
for (Input input : map.keySet()) {
6263
if (input.getName().equals(obj.getName())) {
6364
StructurePart p = new StructurePart();
6465
p.setName(map.get(input).getName());
6566
components.add(p);
67+
} else {
68+
emptyInput = true;
6669
}
6770
}
68-
} else {
71+
} else if (!emptyInput) {
6972
components.add(obj);
7073
}
7174
}

cello/cello-technologymapping/src/main/java/org/cellocad/v2/results/technologyMapping/CytometryPlotUtils.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ private static List<Double> getXData(final NetlistNode node) {
7474
List<Double> rtn = new ArrayList<>();
7575
AssignableDevice a = node.getResultNetlistNodeData().getDevice();
7676
Gate g = (Gate) a;
77-
BivariateLookupTableFunction c =
78-
(BivariateLookupTableFunction) g.getModel().getFunctionByName("cytometry");
79-
rtn = c.getYDataAtIdx(0);
77+
BivariateLookupTableFunction c = null;
78+
c = (BivariateLookupTableFunction) g.getModel().getFunctionByName("cytometry");
79+
if (c != null) {
80+
rtn = c.getYDataAtIdx(0);
81+
} else {
82+
rtn = null;
83+
}
8084
return rtn;
8185
}
8286

@@ -151,6 +155,9 @@ private static String getPlotScript(
151155
for (int i = 0; i < states.getNumStates(); i++) {
152156
State<NetlistNode> state = states.getStateAtIdx(i);
153157
final List<Double> x = getXData(node);
158+
if (x == null) {
159+
return null;
160+
}
154161
final List<Double> y = getYData(node, tmae, ec, state);
155162
final String fmt = "ax[%d].plot([%s], [%s])" + Utils.getNewLine();
156163
final String xArr = String.join(",", getDoubleList(x));
@@ -182,6 +189,9 @@ private static void generatePlot(
182189
final String outDir = runEnv.getOptionValue(ArgString.OUTPUTDIR);
183190
// script
184191
final String script = getPlotScript(node, lsle, tmae, ec, outDir);
192+
if (script == null) {
193+
return;
194+
}
185195
final String scriptFilename = outDir + Utils.getFileSeparator() + getPlotScriptFilename(node);
186196
Utils.writeToFile(script, scriptFilename);
187197
// plot

0 commit comments

Comments
 (0)