1 #ifndef __LOGIC_VM_HPP__
2 #define __LOGIC_VM_HPP__
59 std::cout <<
name <<
": " <<
state <<
" -> " << new_state << std::endl;
71 drive->set_state(
state);
105 std::cout <<
"\t" <<
name <<
" -> " <<
state;
120 std::vector<std::function<void()> >
events;
147 void add_port(std::string
const &name, std::string type) {
148 parent->
dot_file <<
id << name <<
" [label=\"" << name <<
"\" shape=\"circle\"]\n";
170 void set_port(std::string
const &name,
bool value) {
171 for(
auto &p:
input) {
172 if(p.get_name() == name) {
185 if(in.get_name() == name)
188 if(out.get_name() == name)
199 void connect(std::string
const &out,
block &b, std::string
const &in) {
202 std::cout <<
"Connect ";
203 if(this->
parent !=
nullptr)
223 std::cout <<
"ID: " <<
id << std::endl;
224 std::cout <<
"Delay: " <<
delay << std::endl;
225 std::cout <<
"Input(s): ";
226 for(
auto &in:
input) in.print();
227 std::cout << std::endl;
228 std::cout <<
"Output(s): ";
229 for(
auto &out:
output) out.print();
230 std::cout << std::endl;
253 std::list<std::pair<unsigned, std::function<void()> > >
queue;
260 std::cout <<
"Logic VM " <<
vm_name <<
" has been created." << std::endl;
272 dot_file << element->
get_id() <<
" [label=\"" << element->
get_id() <<
"\" shape=\"box\"]" <<
"\n";
294 std::cout <<
" VM informations:" << std::endl;
295 std::cout <<
"\t vm_name: \t\t" <<
vm_name << std::endl;
296 std::cout <<
"\t time_stamp: \t\t" <<
time_stamp << std::endl;
297 std::cout <<
"\t Elements in the VM: \t" <<
elements.size() << std::endl;
298 std::cout <<
"\t Events in the queue: \t" <<
queue.size() << std::endl;
310 std::cout <<
"Event at " <<
time_stamp << std::endl;
311 (
queue.front().second)();
321 for(
auto instance:
queue) {
322 std::cout <<
"Time: " << instance.first << std::endl;
329 std::cout <<
"Logic VM " <<
vm_name <<
" has been destructed." << std::endl;
333 #endif // __LOGIC_VM_HPP__