improve emulator output
This commit is contained in:
+31
-8
@@ -4,11 +4,31 @@
|
||||
|
||||
namespace DynamicPipeline {
|
||||
|
||||
int weight_op(DynamicPipeline::CommandType o)
|
||||
static int weight_op(DynamicPipeline::CommandType o)
|
||||
{
|
||||
return Expression::Token::weight_op(static_cast<Expression::Token::Operator>(o + 2));
|
||||
}
|
||||
|
||||
static const char *op_to_str(DynamicPipeline::CommandType o)
|
||||
{
|
||||
switch (o)
|
||||
{
|
||||
case ADD:
|
||||
return "ADD";
|
||||
case SUB:
|
||||
return "SUB";
|
||||
case MUL:
|
||||
return "MUL";
|
||||
case DIV:
|
||||
return "DIV";
|
||||
case POW:
|
||||
return "POW";
|
||||
default:
|
||||
pr_warn("Impossible token - this is a bug!");
|
||||
return "Impossible token";
|
||||
}
|
||||
}
|
||||
|
||||
void System::init(const std::vector<Command> * const prg, const std::array<double, DYN_PIPELINE_MEM_SIZE>& mem, const int init_mem_size)
|
||||
{
|
||||
pr_info("Dynamic Pipeline System initialized with:\n"
|
||||
@@ -40,21 +60,22 @@ void System::print_pipeline(void) const
|
||||
{
|
||||
if (layer_cmd[i] != -1)
|
||||
{
|
||||
pri_info(std::setw(3) << layer_cmd[i] << " | ");
|
||||
pri_info(std::setw(3) << layer_cmd[i] << " (" << op_to_str((*program_memory)[layer_cmd[i]].t) << ") | ");
|
||||
}
|
||||
else
|
||||
{
|
||||
pri_info("IDL | ");
|
||||
pri_info("--- (---) | ");
|
||||
}
|
||||
}
|
||||
|
||||
if (layer_cmd[DYN_PIPELINE_LAYERS - 1] != -1)
|
||||
{
|
||||
pri_info(std::setw(3) << layer_cmd[DYN_PIPELINE_LAYERS - 1] << "\n");
|
||||
int addr = layer_cmd[DYN_PIPELINE_LAYERS - 1];
|
||||
pri_info(std::setw(3) << addr << " (" << op_to_str((*program_memory)[addr].t) << ")\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
pri_info("IDL\n");
|
||||
pri_info("--- (---)\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +144,7 @@ void System::step(void)
|
||||
if (int prg_mem_addr = layer_cmd[DYN_PIPELINE_LAYERS - 1]; prg_mem_addr != -1)
|
||||
{
|
||||
Command &cmd = (*program_memory)[prg_mem_addr];
|
||||
pr_info("Instruction " << prg_mem_addr << " completes, writes output to " << cmd.res);
|
||||
pr_info("Instruction " << prg_mem_addr << " (" << op_to_str(cmd.t) << ") completes, writes output to " << cmd.res);
|
||||
|
||||
data_memory[cmd.res].ready = 1;
|
||||
}
|
||||
@@ -140,14 +161,14 @@ void System::step(void)
|
||||
if (instruction_ready())
|
||||
{
|
||||
Command &cmd = (*program_memory)[pc];
|
||||
pr_info("Instruction " << pc << " reads " << cmd.op1 << " and " << cmd.op2 << " and enters the pipeline");
|
||||
pr_info("Instruction " << pc << " (" << op_to_str(cmd.t) << ") reads " << cmd.op1 << " and " << cmd.op2 << " and enters the pipeline");
|
||||
|
||||
layer_cmd[0] = pc;
|
||||
|
||||
pc++;
|
||||
}
|
||||
|
||||
pr_info("Pipeline step took " << time_taken << " ticks");
|
||||
pr_info("Step took " << time_taken << " ticks");
|
||||
}
|
||||
|
||||
void System::run(void)
|
||||
@@ -155,6 +176,8 @@ void System::run(void)
|
||||
while (next_instruction() || !pipeline_empty())
|
||||
{
|
||||
print_pipeline();
|
||||
pri_info("\n");
|
||||
|
||||
step();
|
||||
pri_info("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user