00001 00025 #ifndef OUTPUT_H_ 00026 #define OUTPUT_H_ 00027 00028 00029 #include <string> 00030 #include <cassert> 00031 00032 #include "OneInputGate.h" 00033 #include "Event.h" 00034 #include "LogicFunctions.h" 00035 00036 // may as well be inherited from OneInputGate 00040 class Output: public OneInputGate { 00041 00042 public: 00050 Output(size_t id, const std::string& outputName, const std::string& inputName) 00051 : OneInputGate (id, BUF(), outputName, inputName, 0l) 00052 {} 00053 00054 00055 00056 Output (const Output & that) 00057 : OneInputGate (that) {} 00058 00059 00060 virtual Output* clone () const { 00061 return new Output (*this); 00062 } 00063 00064 virtual const std::string getGateName() const { 00065 return "Output"; 00066 } 00067 00068 protected: 00069 00073 virtual LogicVal evalOutput() const { 00074 return this->BaseOneInputGate::inputVal; 00075 } 00076 00080 virtual void execEvent(Graph& g, GNode& myNode, const EventTy& event) { 00081 00082 if (event.getType() == EventTy::NULL_EVENT) { 00083 // do nothing 00084 } else { 00085 // update the inputs of fanout gates 00086 const LogicUpdate& lu = (LogicUpdate) event.getAction(); 00087 if (this->BaseOneInputGate::inputName == (lu.getNetName())) { 00088 this->BaseOneInputGate::inputVal = lu.getNetVal(); 00089 this->BaseOneInputGate::outputVal = this->BaseOneInputGate::inputVal; 00090 00091 } else { 00092 LogicGate::netNameMismatch(lu); 00093 } 00094 00095 } 00096 } 00097 00098 }; 00099 00100 #endif /* OUTPUT_H_ */