diff options
-rw-r--r-- | Circuit.cpp | 5 | ||||
-rw-r--r-- | Net.cpp | 4 | ||||
-rw-r--r-- | Node.cpp | 1 | ||||
-rw-r--r-- | NodeInput.cpp | 26 | ||||
-rw-r--r-- | NodeInput.h | 33 | ||||
-rw-r--r-- | main.cpp | 3 |
6 files changed, 30 insertions, 42 deletions
diff --git a/Circuit.cpp b/Circuit.cpp index 8137939..d6a5375 100644 --- a/Circuit.cpp +++ b/Circuit.cpp @@ -2,6 +2,8 @@ #include "Exception.h" #include "NodeFactory.h" +#include "prut.h" + void Circuit::create(string label, vector<string> nodes) { if (nodes.size() == 1 && NodeFactory::has_type(nodes[0])) return new_node(label, nodes[0]); @@ -19,7 +21,7 @@ void Circuit::new_node(string label, string type) { nodes[label] = node; - printf("[%s] (%s)\n", label.c_str(), type.c_str()); + prutprintf("[%s] (%s)", label.c_str(), type.c_str()); } void Circuit::new_net(string src, vector<string> dests) { @@ -36,6 +38,7 @@ void Circuit::new_net(string src, vector<string> dests) { if (node == nullptr) throw CircuitException("unknown destination node \"%s\"", dest.c_str()); node->addInput(net); + prutprintf("%s -> %s", src.c_str(), dest.c_str()); } } @@ -5,10 +5,6 @@ void Net::setLevel(SignalLevel level){ this->level = level; - // std::cout << this->size() << std::endl; - prutprintf("%u", this->size()); - - this->notify(); } @@ -35,7 +35,6 @@ void Node::sim() { } void Node::update(){ - prutprint("updated"); this->sim(); } diff --git a/NodeInput.cpp b/NodeInput.cpp index fafbd3b..2d1d517 100644 --- a/NodeInput.cpp +++ b/NodeInput.cpp @@ -1,18 +1,11 @@ #include "NodeInput.h" +#include "prut.h" #include <iostream> NodeInputLow NodeInputLow::instance(NodeInputLow::type); NodeInputHigh NodeInputHigh::instance(NodeInputHigh::type); -NodeInput::NodeInput(const char * type) : Node(type) { }; - -void NodeInput::sim() { - if (this->output == nullptr) return; - // std::cout << this->level << " bar\n"; - this->output->setLevel(this->input); -} - NodeInput::NodeInput(const NodeInput * prototype) : Node() { } NodeInput * NodeInput::clone() const { @@ -20,12 +13,15 @@ NodeInput * NodeInput::clone() const { } SignalLevel NodeInput::level() { + prutprint(""); return UNDEFINED; -}; - -// NodeInputLow::NodeInputLow(const NodeInputLow * prototype) : NodeInput() { } +} +SignalLevel NodeInputLow::level() { + prutprint(""); + return LOW; +} +SignalLevel NodeInputHigh::level() { + prutprint(""); + return HIGH; +} -// // INPUT_HIGH -// NodeInputHigh NodeInputHigh::instance(NodeInputHigh::type); -// NodeInputHigh::NodeInputHigh(const char * type) : NodeInput(type) { } -// NodeInputHigh::NodeInputHigh(const NodeInputHigh * prototype) : NodeInput() { } diff --git a/NodeInput.h b/NodeInput.h index 23a5e14..7ec296b 100644 --- a/NodeInput.h +++ b/NodeInput.h @@ -2,45 +2,36 @@ #include "Node.h" +#include "prut.h" + class NodeInput : public Node { public: - NodeInput() = default; + using Node::Node; NodeInput(const NodeInput * prototype); - ~NodeInput() = default; - virtual void sim(); - SignalLevel level(); + virtual NodeInput * clone() const; protected: - NodeInput(const char * type); - -private: - SignalLevel input = UNDEFINED; + virtual SignalLevel level(); }; -// Input LOW and HIGH unicorns: - class NodeInputLow : public NodeInput { - using NodeInput::NodeInput; - public: - // NodeInputLow(const NodeInputLow * prototype); - // ~NodeInputLow() = default; - // virtual void compare(); - // virtual NodeInputLow * clone() const; + using NodeInput::NodeInput; + virtual SignalLevel level(); private: constexpr static const char * type = "input_low"; static NodeInputLow instance; - - SignalLevel input = LOW; }; class NodeInputHigh : public NodeInput { -private: +public: using NodeInput::NodeInput; + virtual SignalLevel level(); + +private: constexpr static const char * type = "input_high"; static NodeInputHigh instance; - - SignalLevel input = HIGH; }; + @@ -4,6 +4,8 @@ #include "Parser.h" #include "Circuit.h" +#include "prut.h" + using std::cout; using std::endl; using std::ifstream; @@ -23,6 +25,7 @@ int main(int argc, char** argv) { cout << "Parser error: " << e.what() << endl; return EXIT_FAILURE; } + prutprint("parsing done!"); try { circuit.sim(); |