add some functionality to andGate class
This commit is contained in:
parent
bc949ffea7
commit
9d0f5beb74
@ -0,0 +1,11 @@
|
||||
#include "andGate.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
andGate::andGate(wire* wire1 = nullptr, wire* wire2 = nullptr,
|
||||
wire* wire3 = nullptr) : in1(wire1), in2(wire2), out(wire3) {}
|
||||
|
||||
int andGate::evaluate(int evTime) {
|
||||
int bool1 = in1 -> getValue();
|
||||
return ( in1 -> getValue(evTime) ) && ( in2 -> getValue(evTime) );
|
||||
}
|
@ -3,8 +3,9 @@
|
||||
|
||||
class andGate : public gate {
|
||||
public:
|
||||
andGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr);
|
||||
int evaluate();
|
||||
andGate(wire* wire1 = nullptr, wire* wire2 = nullptr,
|
||||
wire* wire3 = nullptr);
|
||||
int evaluate(int evTime);
|
||||
};
|
||||
|
||||
#endif // !AND
|
||||
|
@ -5,6 +5,7 @@ using namespace std;
|
||||
event::event(event, value, setTime, wire) : evNum(event), evValue(value),
|
||||
evTime(setTime), wireNum(wire) {}
|
||||
|
||||
// operator overload so that priority_queue will function correctly
|
||||
bool event::operator<(const event &e1, const event &e2) {
|
||||
if(e1.evTime == e2.evTime) {
|
||||
return e1.evNum > e2.evNum;
|
||||
|
@ -23,7 +23,7 @@ int main() {
|
||||
if(parseSuccess) {
|
||||
// 2. Parse the vector file to initialize the simulation Queue with initial
|
||||
// Wire state (i.e., value) changes
|
||||
queue e;
|
||||
priority_queue< e;
|
||||
parseSuccess = e.parseVector(fileName);
|
||||
|
||||
// 3. Simulate the circuit using Event-driven control
|
||||
|
Loading…
Reference in New Issue
Block a user