tum-ei-eda / M2-ISA-R

CoreDSL2 Parser with backend to generate simulation code for the ETISS instruction set simulator

Home Page:https://tum-ei-eda.github.io/M2-ISA-R/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory read inside if-statement not generating correct code

maltevonehren opened this issue · comments

Hello,
I have noticed that a memory access placed inside of an if statement does not generate code for actually reading the memory.

A small example:
This behavior describtion generates the following code:

behavior: {
    if ((signed<32>)MEM[0] > 0)
        X[1] = 1;
}
partInit.code() += "cpu->instructionPointer = " + std::to_string(ic.current_address_ + 4U) + ";\n";
partInit.code() += "if ((etiss_int32)(mem_val_0) > 0U) {\n";
partInit.code() += "*((RV32IMACFD*)cpu)->X[" + std::to_string(1U) + "] = 1U;\n";
partInit.code() += "}\n";

Where I would have expected it to generate the code below or throw an error.

partInit.code() += "cpu->instructionPointer = " + std::to_string(ic.current_address_ + 4U) + ";\n";
partInit.code() += "etiss_uint32 mem_val_0;\n";
partInit.code() += "exception |= (*(system->dread))(system->handle, cpu, " 
                                     + std::to_string(0U) + ", (etiss_uint8*)&mem_val_0, 4);\n";
partInit.code() += "if ((etiss_int32)(mem_val_0) > 0U) {\n";
partInit.code() += "*((RV32IMACFD*)cpu)->X[" + std::to_string(1U) + "] = 1U;\n";
partInit.code() += "}\n";

Thanks

Should be fixed in 7d6cdf8, please test and verify.

Works fine now. Thanks!