/*
See https://blog.jochumzen.com/ entry 13
Demonstration: connecting a register to the bus through tri-state buffers.
Set DIP 5-8 to something, say 0011
Click Clk to latch/store the value in the register
Clik print to see that value is latched. Observe that switches output ZZZZ and bus is ZZZZ
Click E (2 on keyboard) to enable the tri-state buffers and move the data onto the bus.
While holding E, click Print and observe that switches output the value of the register
and that the bus has this value.
*/
//Library with basic gates
#include <ACELBC.h>
//Create an Arduino board
auto* ard = new ArduinoBoard();
//Define chips
auto* reg = new QuadDFlipFlop();
auto* switches = new QuadThreeStateSwitches();
auto* bus = new BusLineFour();
//Add all chips to be emulated here
Chip* chips[] = {
reg, switches, bus
};
//Add all connections here
ConnectionBase* connections[] = {
new ConnectionFour(ard, 2, reg->D, 1), //2,3,4,5 to D3, D2, D1, D0
new Connection(ard, 6, reg->Clock),
new Connection(ard, 7, switches->Enable),
new ConnectionFour(reg->Q, switches->D),
new ConnectionFour(switches->W, bus->X),
};
//Setting up the emulation. No need to change
Emulation emulation = Emulation(ard, chips, sizeof(chips)/2,
connections, sizeof(connections)/2);
void setup() {
Serial.begin(9600); Serial.println(); Serial.println("START");
Serial.println();
emulation.makePrintPin(13, 1);
}
void loop() {
emulation.emulate();
}
Print
Clk
E