/*
See https://blog.jochumzen.com/ entry 22
Demonstartion of a four bit adder
Set A to 0110 (decimal 6), Left DIP 6,7 ON
Set B to 0100 (decimal 4), Right DIP 6 ON
Note that Sum = 1010 (decimal 10)
Click on Cin, Carry In. This adds one, Sum = 1011 (decimal 11)
Set A to 1011 (decimal 11)
Set B to 0111 (decimal 7)
Note that Sum = 0010 but Carry out is on. The sum is therefore 10010 (18 decimal)
*/
//Library with basic gates
#include <ACELBC.h>
//Create an Arduino board
auto* ard = new ArduinoBoard();
//Define chips
auto* adder = new FourBitAdder();
//Add all chips to be emulated here
Chip* chips[] = {
adder
};
//Add all connections here
ConnectionBase* connections[] = {
//Address stuff
new ConnectionFour(ard, 3, adder->A,1),
new ConnectionFour(ard, 8, adder->B,1),
new Connection(ard,12,adder->Cin),
new ConnectionFour(adder->S, ard, 22, 1),
new Connection(adder->Cout, ard, 26),
};
//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);
//emulation.printOnArdEvent(1);
}
void loop() {
emulation.emulate();
}
Print
Cin
A
B
Cout
Sum