Jump to content

Photo

looking for CPU diagnostic routines

9900 vhdl

4 replies to this topic

#1 pnr OFFLINE  

pnr

    Chopper Commander

  • 107 posts

Posted Sun May 27, 2018 2:00 PM

For testing a CPU core, I'm looking for diagnostic routines that test the functionality of a 9900 CPU.

 

Maybe this was developed for one of the emulators? Or were those debugged by just throwing a lot of programs at them and fixing bugs where they did not execute as expected?

 

All suggestions welcome.

 



#2 mizapf OFFLINE  

mizapf

    River Patroller

  • 3,351 posts
  • Location:Germany

Posted Sun May 27, 2018 3:18 PM

For MAME I did not use a formal test method. As you suspected, I let it converge against the ideal behavior, with the hope that errors cannot hide too long until they show up somewhere.

 

This bit me twice:

  • In Microsurgeon, the game was over right after the start. It turned out that the Subtract instruction failed to set the Carry bit when subtracting 0, something I did not expect (subtract means to add the complement, and it actually adds the one's complement of 0 (=FFFF) and fixes the result by adding 1).
  • In a TMS9995-based arcade game, the timing was completely wrong. This was because I implemented the decrementer to subtract 1 every clock pulse, but it is only every four clock pulses.

In hindsight, I could have made good use of such a program.



#3 pnr OFFLINE  

pnr

    Chopper Commander

  • Topic Starter
  • 107 posts

Posted Mon May 28, 2018 1:27 AM

Thanks for pointing out those gotcha's!

 

The subtraction thing is a clever implementation trick, I think I will try that in the core. The ALU already needs to support "A and not B" for instructions like COC and SZC, so must have complemented B available anyway. Doing subtract as "A + not B + 1", where the "+ 1" is done by setting 'carry in' to one, means that the ALU only needs to implement an adder and not a subtractor as well.

 

The MDEX operating system ("CP/M for the Marinchip M9900") has a program "BRAINS" that does a memory and a CPU check. However, I only have the executable, not the source. I'm not sure how thorough it is, it may only check for some common failure cases (e.g. CRU drivers fried).



#4 mizapf OFFLINE  

mizapf

    River Patroller

  • 3,351 posts
  • Location:Germany

Posted Mon May 28, 2018 1:40 AM

Particularly, one can see that it is not safe to rely on the hope that a glitch will show up quickly. I only noticed it when trying one special game.

#5 Tursi ONLINE  

Tursi

    Quadrunner

  • 5,237 posts
  • HarmlessLion
  • Location:BUR

Posted Wed May 30, 2018 2:22 PM

Classic99 ran for many years with such bugs hidden in the CPU core too... some patterns are just not commonly used. :)

I did write a simple CPU test program - it's in the Classic99 archive. It tests a couple of points on each instruction but is not at all comprehensive. It still found a couple of issues in my early development and was verified against hardware.





Also tagged with one or more of these keywords: 9900, vhdl

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users