use of de.neemann.digital.draw.shapes.ShapeFactory in project Digital by hneemann.
the class CircuitBuilderTest method testBuilderSequentialJK.
public void testBuilderSequentialJK() throws Exception {
Variable y0 = new Variable("Y_0");
Variable y1 = new Variable("Y_1");
// counter
Expression y0s = not(y0);
Expression y1s = or(not(y0), not(y1));
ElementLibrary library = new ElementLibrary();
Circuit circuit = new CircuitBuilder(new ShapeFactory(library), true).addSequential("Y_0", y0s).addSequential("Y_1", y1s).createCircuit();
ModelCreator m = new ModelCreator(circuit, library);
TestExecuter te = new TestExecuter(m.createModel(false)).setUp(m);
te.check(0, 0);
te.checkC(1, 1);
te.checkC(0, 0);
te.checkC(1, 1);
te.checkC(0, 0);
}
use of de.neemann.digital.draw.shapes.ShapeFactory in project Digital by hneemann.
the class CircuitTest method test64Bit.
public void test64Bit() throws IOException {
Circuit c = createCircuit();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
c.save(baos);
// check ROM
c = Circuit.loadCircuit(new ByteArrayInputStream(baos.toByteArray()), new ShapeFactory(new ElementLibrary()));
VisualElement rom = c.getElements().get(0);
DataField d = rom.getElementAttributes().get(Keys.DATA);
assertEquals(0xffff0000ffff0000L, d.getDataWord(0));
assertEquals(0x8fff0000ffff0000L, d.getDataWord(1));
// check input
VisualElement in = c.getElements().get(1);
assertEquals(0x8fff0000ffff0000L, in.getElementAttributes().get(Keys.INPUT_DEFAULT).getValue());
}
use of de.neemann.digital.draw.shapes.ShapeFactory in project Digital by hneemann.
the class FragmentVisualElementTest method testBox.
public void testBox() throws Exception {
ShapeFactory shapeFactory = new ShapeFactory(new ElementLibrary());
FragmentVisualElement ve = new FragmentVisualElement(FlipflopJK.DESCRIPTION, shapeFactory);
ve.setPos(new Vector(0, 0));
Box box = ve.doLayout();
assertEquals(SIZE * 3, box.getHeight());
assertEquals(SIZE * 3, box.getWidth());
}
Aggregations