/*
Demonstration of the program counter.
See https://blog.jochumzen.com/p/entries.html entry 26
Click on Clock(keyboard 3) and Clear(2) to get the simulation started.
Click the clock pin repeatedly.
Observe that the count on the display increases by 1 when the clock goes high.
Remember, A=10, b = 11, C = 12, d = 13, E = 14, F = 15
Make the count 15 (F) and click Clock
Observe that the count goes back to zero.
Click Clear and observe that count becomes zero.
Set a number on the DIPs 5-8, for example 0101 (5) and click Load.
Observe that count becomes 5.
*/
//Library with basic gates
#include <ACELBC.h>
//Create an Arduino board
auto* ard = new ArduinoBoard();
//Define chips
auto* programCounter = new FourBitProgramCounter();
auto* decoder = new SevenSegmentDecoderAnode();
//Add all chips to be emulated here
Chip* chips[] = {
programCounter, decoder
};
//Add all connections here
ConnectionBase* connections[] = {
new ConnectionFour(ard, 2, programCounter->D, 1),
new Connection(ard, 6, programCounter->Load),
new Connection(ard, 12, programCounter->Count), //Count = 1
new Connection(ard, 29, programCounter->Clear),
new Connection(ard, 30, programCounter->Clock),
new ConnectionFour(programCounter->Q, decoder->Q),
new Connection(decoder->S[0], ard, 22),
new Connection(decoder->S[1], ard, 23),
new Connection(decoder->S[2], ard, 24),
new Connection(decoder->S[3], ard, 25),
new Connection(decoder->S[4], ard, 26),
new Connection(decoder->S[5], ard, 27),
new Connection(decoder->S[6], ard, 28),
};
//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();
}
D3..D0
Print
Load
Clear
Clock