diff --git a/circuit/Circuit Sim (Text Version).zip b/circuit/Circuit Sim (Text Version).zip new file mode 100644 index 0000000..aa64d5a Binary files /dev/null and b/circuit/Circuit Sim (Text Version).zip differ diff --git a/circuit/RunCircuitSimulation.bat b/circuit/RunCircuitSimulation.bat new file mode 100644 index 0000000..44c3ea3 --- /dev/null +++ b/circuit/RunCircuitSimulation.bat @@ -0,0 +1,6 @@ +@echo off +set /p commandLine="Enter any command line arguments: " + +"text circuit sim.exe" %commandLine% + +pause diff --git a/circuit/circuit0.txt b/circuit/circuit0.txt new file mode 100644 index 0000000..efef740 --- /dev/null +++ b/circuit/circuit0.txt @@ -0,0 +1,6 @@ +CIRCUIT SimpleCircuit +INPUT A 1 +INPUT B 2 +OUTPUT C 3 +AND 2ns 1 2 3 + diff --git a/circuit/circuit0_v.txt b/circuit/circuit0_v.txt new file mode 100644 index 0000000..cc0d56e --- /dev/null +++ b/circuit/circuit0_v.txt @@ -0,0 +1,7 @@ +VECTOR SimpleCircuit +INPUT A 0 0 +INPUT B 0 0 +INPUT A 4 1 +INPUT B 5 1 + + diff --git a/circuit/circuit1.txt b/circuit/circuit1.txt new file mode 100644 index 0000000..49b7db4 --- /dev/null +++ b/circuit/circuit1.txt @@ -0,0 +1,9 @@ +CIRCUIT Circuit1 +INPUT A 1 +INPUT B 3 +INPUT C 4 +OUTPUT D 5 +OUTPUT E 6 +NOT 2ns 1 2 +AND 3ns 2 3 5 +OR 3ns 4 5 6 diff --git a/circuit/circuit1_v.txt b/circuit/circuit1_v.txt new file mode 100644 index 0000000..934f64a --- /dev/null +++ b/circuit/circuit1_v.txt @@ -0,0 +1,7 @@ +VECTOR Circuit1 +INPUT A 0 0 +INPUT B 0 1 +INPUT C 0 0 +INPUT C 4 1 +INPUT A 6 1 +INPUT B 9 0 diff --git a/circuit/circuit2.txt b/circuit/circuit2.txt new file mode 100644 index 0000000..879da31 --- /dev/null +++ b/circuit/circuit2.txt @@ -0,0 +1,11 @@ +CIRCUIT Circuit2 +INPUT A 1 +INPUT B 3 +INPUT C 4 +INPUT D 5 +OUTPUT E 9 +NOT 2ns 1 2 +AND 5ns 2 3 6 +AND 5ns 4 5 7 +OR 4ns 6 7 8 +XOR 5ns 8 7 9 diff --git a/circuit/circuit2_v.txt b/circuit/circuit2_v.txt new file mode 100644 index 0000000..305db26 --- /dev/null +++ b/circuit/circuit2_v.txt @@ -0,0 +1,9 @@ +VECTOR Circuit2 +INPUT A 0 0 +INPUT B 0 1 +INPUT C 0 0 +INPUT D 0 1 +INPUT C 4 1 +INPUT A 6 1 +INPUT B 9 0 +INPUT D 12 X diff --git a/circuit/circuit3.txt b/circuit/circuit3.txt new file mode 100644 index 0000000..e3a19c9 --- /dev/null +++ b/circuit/circuit3.txt @@ -0,0 +1,9 @@ +CIRCUIT Circuit3 +INPUT A 1 +INPUT B 2 +INPUT C 3 +OUTPUT D 5 +OUTPUT E 6 +AND 2ns 1 2 4 +OR 3ns 4 3 5 +NOT 1ns 4 6 diff --git a/circuit/circuit3_v.txt b/circuit/circuit3_v.txt new file mode 100644 index 0000000..c6e2747 --- /dev/null +++ b/circuit/circuit3_v.txt @@ -0,0 +1,6 @@ +VECTOR Circuit3 +INPUT A 1 1 +INPUT B 1 0 +INPUT C 1 0 +INPUT B 7 1 +INPUT A 7 0 diff --git a/circuit/circuit4.txt b/circuit/circuit4.txt new file mode 100644 index 0000000..f2f5a87 --- /dev/null +++ b/circuit/circuit4.txt @@ -0,0 +1,4 @@ +CIRCUIT JacubecCircuit +INPUT A 1 +OUTPUT C 2 +NAND 2ns 1 2 2 diff --git a/circuit/circuit4_v.txt b/circuit/circuit4_v.txt new file mode 100644 index 0000000..1a0a286 --- /dev/null +++ b/circuit/circuit4_v.txt @@ -0,0 +1,3 @@ +VECTOR JacubecCircuit +INPUT A 0 0 +INPUT A 1 1 diff --git a/circuit/circuit5.txt b/circuit/circuit5.txt new file mode 100644 index 0000000..7258133 --- /dev/null +++ b/circuit/circuit5.txt @@ -0,0 +1,8 @@ +CIRCUIT SimpleCircuit +INPUT A 1 +INPUT B 2 +INPUT C 3 +OUTPUT OUT1 4 +OUTPUT OUT2 5 +AND 3ns 1 2 4 +OR 2ns 4 3 5 diff --git a/circuit/circuit5_v.txt b/circuit/circuit5_v.txt new file mode 100644 index 0000000..4f3585c --- /dev/null +++ b/circuit/circuit5_v.txt @@ -0,0 +1,6 @@ +VECTOR SimpleCircuit +INPUT A 0 1 +INPUT B 0 1 +INPUT C 0 0 + + diff --git a/circuit/circuit7.txt b/circuit/circuit7.txt new file mode 100644 index 0000000..9ebf271 --- /dev/null +++ b/circuit/circuit7.txt @@ -0,0 +1,8 @@ +CIRCUIT DrivesTwo +INPUT A 1DrivesTwo +OUTPUT B 3 +OUTPUT C 4 +NOT 2ns 1 3 +NOT 1ns 1 2 +NOT 1ns 2 4 + diff --git a/circuit/circuit7_v.txt b/circuit/circuit7_v.txt new file mode 100644 index 0000000..abba664 --- /dev/null +++ b/circuit/circuit7_v.txt @@ -0,0 +1,5 @@ +VECTOR DrivesTwo +INPUT A 0 0 +INPUT A 3 1 +INPUT A 4 0 + diff --git a/circuit/circuit8.txt b/circuit/circuit8.txt new file mode 100644 index 0000000..aa42271 --- /dev/null +++ b/circuit/circuit8.txt @@ -0,0 +1,7 @@ +CIRCUIT WhiteBoard +INPUT A 1 +INPUT B 2 +OUTPUT C 3 +AND 2ns 1 2 4 +OR 3ns 2 4 3 + diff --git a/circuit/circuit8_v.txt b/circuit/circuit8_v.txt new file mode 100644 index 0000000..c23990e --- /dev/null +++ b/circuit/circuit8_v.txt @@ -0,0 +1,5 @@ +VECTOR WhiteBoard +INPUT A 0 1 +INPUT B 0 0 +INPUT A 3 0 + diff --git a/circuit/ff.txt b/circuit/ff.txt new file mode 100644 index 0000000..d4128dd --- /dev/null +++ b/circuit/ff.txt @@ -0,0 +1,7 @@ +CIRCUIT flipflop1 +INPUT R 1 +INPUT S 2 +OUTPUT O 3 +NOR 2ns 2 3 4 +NOR 2ns 1 4 3 + diff --git a/circuit/ff_v.txt b/circuit/ff_v.txt new file mode 100644 index 0000000..719b800 --- /dev/null +++ b/circuit/ff_v.txt @@ -0,0 +1,12 @@ +VECTOR flipflop1 +INPUT R 0 1 +INPUT S 0 1 +INPUT R 1 0 +INPUT S 1 0 +INPUT S 2 1 +INPUT S 3 0 +INPUT S 5 1 +INPUT S 6 0 +INPUT R 9 1 +INPUT R 10 0 + diff --git a/circuit/text circuit sim.exe b/circuit/text circuit sim.exe new file mode 100644 index 0000000..ddc92ee Binary files /dev/null and b/circuit/text circuit sim.exe differ diff --git a/src/Simulation.cpp b/src/Simulation.cpp index f1ce7e8..edf68c4 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -22,13 +22,9 @@ bool Simulation::parseCircuit(string fileName) in >> tmpString; in >> tmp1; - if (tmpType == "INPUT") { - tmpWire = new Wire(tmp1, true, tmpString); - wires.push_back(tmpWire); - } - else if (tmpType == "OUTPUT") { - tmpWire = new Wire(tmp1, false, tmpString); - wires.push_back(tmpWire); + if (tmpType == "INPUT" || tmpType == "OUTPUT") { + tmpWire = findWire(tmp1); + tmpWire->convertToIO(tmpString); } else if (tmpType == "NOT") { in >> tmp2; @@ -126,7 +122,11 @@ Wire * Simulation::findWire(int n) for (auto i = wires.begin(); i != wires.end(); ++i) { if (n == (**i).getNumber()) return *i; } - return nullptr; + + // if wire does not exist, create it, instantiating as an intermediary wire + Wire * tmpWire = new Wire(n, false); + wires.push_back(tmpWire); + return tmpWire; } int Simulation::getDelay(string d) diff --git a/src/radec.cpp b/src/radec.cpp index cbbaa0f..dc5281c 100644 --- a/src/radec.cpp +++ b/src/radec.cpp @@ -8,6 +8,7 @@ int main() { string fileName; Simulation e; + cout << "Please enter filename: "; getline(cin, fileName); e.parseCircuit(fileName); @@ -24,4 +25,4 @@ int main() { // 4. Print the results of the simulation e.print(); -} \ No newline at end of file +}