Verifying That Your Code Contains No Illegal Opcodes

<< Click to Display Table of Contents >>

Navigation:  eTPU Development Tool (ASH WARE, Inc.) >

Verifying That Your Code Contains No Illegal Opcodes

Previous pageReturn to chapter overviewNext page

Example Download

So your tests show your code to be functionally correct ...

... but how do you verify that your code contains no illegal instructions?

If the eTPU executes an illegal opcode ... say opcode 0x1FFFFDE ... then the thread continues executing. The one affect is that the ETPUMCR.ILF1 bit gets set indicating that an illegal instruction has occurred.

How can you verify that such an illegal opcode has not executed? The answer is to verify that the ETPUMCR.ILF1 flag has not been set. One way to do this is to execute the following script command immediately prior to terminating a test.

//--------------------------------------------------------

// Verify that there is no illegal instruction 

// The illegal instruction would: 

// - set ETPUMCR.ILF1 (bit position 25) 

verify_mem_u32(ETPU_CTRL_SPACE, 0x0, (1<<25), 0x00000000); 

//-------------------------------------------------------- 

Note that file Test.Bat can be run to verify that there are no faults when a particular piece of code executes.

In this demo, the code is loaded and executed twice.

1.The first time it is run "as is".

2.The second time an illegal opcode is injected into the code space, as follows

 

#ifdef BAD_CODE

// Replace the NOP with an ILLEGAL instruction

*((ETPU_CODE_SPACE U32 *) 0x0200 ) = 0x1FFFFDE3;

#endif // BAD_CODE

When the code executes the second time (and has the illegal opcode) then the test fails, thereby making this fault observable!