aboutsummaryrefslogtreecommitdiff
path: root/Gate.cpp
blob: 0724b44927e84877aa3fcdf03b7a63427357cd94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "Gate.h"

#include <iostream>

Gate::Gate(){}
Gate::~Gate(){}
void Gate::addInput(Net* net){
   net->attach(this);
}
void Gate::setOutput(Net* net){
   this->output = net;
}

void Gate::update(){
   std::cout << "updated" << std::endl;
   this->compare();
}

/*/ Concrete Gates: /*/

void GateAnd::compare(){
   SignalLevel new_out = HIGH;

   // TODO fix segfault somewhere below
   // for (int i = 0; i < this->inputs.size(); i++){
   //    switch (this->inputs[i]->getLevel()){
   //    case LOW:
   //       new_out = LOW;
   //       break;
   //    case HIGH:
   //       continue;
   //       break;
   //    case UNDEFINED:
   //    default:
   //       new_out = UNDEFINED;
   //       exit;
   //       break;
   //    }
   // }

   // if (this->output->getLevel() == new_out){
   //    /* do nothing */
   // } else {
   //    this->output->setLevel(new_out);
   // }

}