/*
See https://blog.jochumzen.com/ entry 18
Demonstration: 16x4 RAM. Chip is similar to 74LS189, just different pin-names
DIP 1-4 is the address bus, connected to RAM, A
DIP 5-8 is the data bus, connected to RAM, D
Load: Loads the data D into address A
Q connected to LED: Data at address A
Write: Enables tri-state buffers, makes W equal to Q.
Click Print
Note that A = D = Q = 0 and W = Z
You can also see the content at all addresses following "data:" (in decimal)
Set D = 0101 (DIP 6, 8 to ON)
Click Load
0101 is now stored as address 0
Click Print
Note Q = 0101 and W = ZZZZ
Click and hold Write, Click Print
Note Q = 0101 and W = 0101
Change address to 0001 (DIP 4 to ON)
Click Print
Note that Q = 0000 at address 1
Set D = 1010 (DIP 5, 7 to ON)
Click Load
1010 is now stored as address 1
Set the address back to 0000
Note that Q changes to 0101, the value earlier stored at address 1.
Store some other data on different addresses and confirm that the memory "remembers"
what you stored.
*/
//Library with basic gates
#include <ACELBC.h>
//Create an Arduino board
auto* ard = new ArduinoBoard();
//Define chips
auto* ram = new SixteenByFourRam((char*)("SRAM"));
//Add all chips to be emulated here
Chip* chips[] = {
ram
};
//Add all connections here
ConnectionBase* connections[] = {
new ConnectionFour(ard, 2, ram->A, 1),
new ConnectionFour(ard, 6, ram->D, 1),
new Connection(ard, 10, ram->Load),
new Connection(ard, 11, ram->Write),
new ConnectionFour(ram->Q, ard, 22, 1)
};
//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
Load
Write
Address
Data
Q