#pragma once #include #include #include #include "config.h" namespace DynamicPipeline { enum CommandType : uint16_t { ADD, SUB, MUL, DIV, POW, CMD_COUNT }; struct Command { enum CommandType t; uint16_t op1; uint16_t op2; uint16_t res; Command(enum CommandType t, uint16_t op1, uint16_t op2, uint16_t res) : t(t), op1(op1), op2(op2), res(res) { } }; struct MemCell { double v; int ready; }; class System { private: std::vector *program_memory; std::array data_memory; std::array layer_cmd {-1}; unsigned int pc {0}; unsigned int system_time; void print_program_memory(void) const; void print_pipeline(void) const; bool pipeline_empty(void) const; bool next_instruction(void) const; bool instruction_ready(void) const; void step(void); public: void init(const std::vector * const prg, const std::array& mem, const int init_mem_size); void run(void); }; }