Skip to content

Commit

Permalink
fix nits, remove netlist port/connection type getters
Browse files Browse the repository at this point in the history
(the Schematic is always the place to go for those)
  • Loading branch information
mtrberzi committed Jul 25, 2014
1 parent 1f3e651 commit 850a50a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import org.manifold.compiler.UndefinedBehaviourError;

public abstract class DesignRuleCheck {
public abstract void check();
public abstract class Check {
protected abstract void verify();

protected Boolean result = null;

public boolean passed() {
public boolean run() {
if (result == null) {
check();
verify();
// ensure that the check set a result
if (result == null) {
throw new UndefinedBehaviourError(
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/manifold/compiler/back/digital/Netlist.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,9 @@
public class Netlist {

private ConnectionType digitalWireType;
public ConnectionType getDigitalWireType() {
return digitalWireType;
}
private PortTypeValue digitalInType;
public PortTypeValue getDigitalInType() {
return digitalInType;
}
private PortTypeValue digitalOutType;

public PortTypeValue getDigitalOutType() {
return digitalOutType;
}

private Map<String, Net> nets = new HashMap<>();

public Map<String, Net> getNets() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@

import org.manifold.compiler.PortTypeValue;
import org.manifold.compiler.PortValue;
import org.manifold.compiler.UndeclaredIdentifierException;
import org.manifold.compiler.UndefinedBehaviourError;
import org.manifold.compiler.middle.Schematic;


public class DRC_NoMultipleDrivers extends DesignRuleCheck {
public class NoMultipleDriversCheck extends Check {

private Schematic schematic;
private Netlist netlist;
private PortTypeValue digitalInType;
private PortTypeValue digitalOutType;

public DRC_NoMultipleDrivers(Netlist netlist) {
public NoMultipleDriversCheck(Schematic schematic, Netlist netlist) {
this.schematic = schematic;
this.netlist = netlist;
this.digitalInType = netlist.getDigitalInType();
this.digitalOutType = netlist.getDigitalOutType();
try {
this.digitalOutType = schematic.getPortType("digitalOut");
} catch (UndeclaredIdentifierException e) {
throw new UndefinedBehaviourError(
"schematic does not define digitalOut port type");
}
}

@Override
public void check() {
protected void verify() {
System.err.println("expected digital out type = "
+ digitalOutType.toString());
Map<String, Net> allNets = netlist.getNets();
Expand Down Expand Up @@ -47,6 +55,7 @@ public void check() {
* nets are multiply driven, and the ports that are driving them. This
* will be useful when showing the user the results of DRC so they can
* correct the design.
* This is described in Issue #131.
*/
}
this.result = noMultipleDrivers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import org.junit.runners.Parameterized.Parameters;
import org.manifold.compiler.ConnectionValue;
import org.manifold.compiler.NodeValue;
import org.manifold.compiler.back.digital.DRC_NoMultipleDrivers;
import org.manifold.compiler.back.digital.DesignRuleCheck;
import org.manifold.compiler.back.digital.Check;
import org.manifold.compiler.back.digital.Netlist;
import org.manifold.compiler.back.digital.NoMultipleDriversCheck;
import org.manifold.compiler.middle.Schematic;
import org.manifold.compiler.middle.SchematicException;

@RunWith(Parameterized.class)
public class TestDRC_NoMultipleDrivers {
public class TestNoMultipleDriversCheck {

@BeforeClass
public static void setupClass() {
Expand All @@ -45,7 +45,7 @@ public static Collection<Object[]> data() throws SchematicException {
case0.addConnection("in0_to_out0", in0_to_out0);

Netlist netlist_case0 = new Netlist(case0);
Object[] case0_data = new Object[] { netlist_case0, true };
Object[] case0_data = new Object[] { case0, netlist_case0, true };
testData.add(case0_data);
}
// END CASE 0
Expand All @@ -70,28 +70,29 @@ public static Collection<Object[]> data() throws SchematicException {
case1.addConnection("in1_to_out0", in1_to_out0);

Netlist netlist_case1 = new Netlist(case1);
Object[] case1_data = new Object[] { netlist_case1, false };
Object[] case1_data = new Object[] { case1, netlist_case1, false };
testData.add(case1_data);
}
// END CASE 1
return testData;
}

// test inputs
private Schematic schematic;
private Netlist netlist;
private boolean expectedCheckResult;

public TestDRC_NoMultipleDrivers(Netlist netlist,
public TestNoMultipleDriversCheck(Schematic schematic, Netlist netlist,
Boolean expectedCheckResult) {
this.schematic = schematic;
this.netlist = netlist;
this.expectedCheckResult = expectedCheckResult;
}

@Test
public void testDRC() {
DesignRuleCheck drc = new DRC_NoMultipleDrivers(netlist);
drc.check();
boolean actualCheckResult = drc.passed();
Check drc = new NoMultipleDriversCheck(schematic, netlist);
boolean actualCheckResult = drc.run();
assertEquals(expectedCheckResult, actualCheckResult);
}

Expand Down

0 comments on commit 850a50a

Please sign in to comment.