tum-ei-eda / etiss

Extendable Translating Instruction Set Simulator
https://tum-ei-eda.github.io/etiss/
Other
29 stars 36 forks source link

Decoding logic can not resolve instructions truly #111

Closed togulcan closed 7 months ago

togulcan commented 2 years ago

Hello,

the node::compile and node::resolve mechanism does not work at all for the following pattern of instruction sets:

encoding: OPCODE[a:0] :: R[b:0] :: OPCODE[d:0]:: Imm[e:0];

I believe this is mostly because of the fact that it is AND'ing the masks of the instructions here: https://github.com/tum-ei-eda/etiss/blob/master/src/Instruction.cpp#L641 This results in the wrong set of masks for the parse tree.

As an example:

LDR_imm_T4 encoding: 0b111110000101 :: n[3:0] :: t[3:0] :: 0b1 :: P[0:0] :: U[0:0] :: W[0:0] :: imm[7:0]; LDR_lit_T2 encoding: 0b11111000 :: U[0:0] :: 0b1011111 :: t[3:0] :: imm[13:2];

where the mask of LDR_immT4 is 11111111111100000000100000000000 and the mask of LDR_lit_T2 is 11111111011111110000000000000000

where the bold bits of LDR_imm_t4 are filtered out due to the mask of the LDR_lit_T2. This results in the wrong compilation of the instruction set and hence the encoded bit arrays can not be resolved into the corresponding instruction set during decoding and giving exceptions. I debugged this, indeed the parse three does not check the 11th and 23rd bits of LDR_immT4.

The exception I am receiving when LDR_imm_T4 is to be resolved is: ETISS: Fatal Error: etiss::instr::Node::resolve called without a previous valid compilation call.

Thanks

wysiwyng commented 7 months ago

merged #112