finish the program and fix when a wire goes undefined

This commit is contained in:
daniel 2017-04-25 14:38:15 -04:00
parent e7afee35aa
commit 4f3f006d0d
6 changed files with 29 additions and 6 deletions

View File

@ -1,5 +1,5 @@
CIRCUIT DrivesTwo
INPUT A 1DrivesTwo
INPUT A 1
OUTPUT B 3
OUTPUT C 4
NOT 2ns 1 3

7
Radec/Radec/ff.txt Normal file
View File

@ -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

12
Radec/Radec/ff_v.txt Normal file
View File

@ -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

View File

@ -1,5 +1,5 @@
CIRCUIT DrivesTwo
INPUT A 1DrivesTwo
INPUT A 1
OUTPUT B 3
OUTPUT C 4
NOT 2ns 1 3

View File

@ -11,7 +11,6 @@ NandGate::NandGate(int d, Wire * wire1, Wire * wire2, Wire * wire3)
Event NandGate::evaluate(int evTime)
{
cout << evTime << " " << in1->getValue(evTime) << " " << in2->getValue(evTime) << endl;
if (in1->getValue(evTime) == 0 || in2->getValue(evTime) == 0) {
return Event(1, evTime + delay, out);
}

View File

@ -110,8 +110,8 @@ bool Simulation::parseVector(string fileName) {
return false;
}
string tmpString;
int timeInt, valInt;
string tmpString, valInt;
int timeInt;
Wire *tmpWire = nullptr;
// get rid of first line
@ -129,7 +129,12 @@ bool Simulation::parseVector(string fileName) {
}
}
e.push(Event(valInt, timeInt, tmpWire));
if (valInt == "X") {
e.push(Event(-1, timeInt, tmpWire));
}
else {
e.push(Event(atoi(valInt.c_str()), timeInt, tmpWire));
}
}
}