-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comprehensive CPU test suite #9
Comments
@bernd-ulmann Please decide, if you would like to do this step 1 "a bit more than today" in about the next 5-8 weeks (target: V1.6) or later (target: V1.7). Please use the label feature on the right side here in GitHub to label "V1.6" or "V1.7" Branch: Please use |
@MJoergen Just in case you'd like to support Bernd here: He hates this topic, but it is pretty important, though. |
I'll look into this issue. It seems like a good way for me to get to know the CPU and the ISA. |
Sounds great, Michael: V1.6 oder V1.7? |
I've now started work on this, and creaked a branch |
Cool - this is good news. |
AWESOME :-) I just looked into your commits so far and I am stunned: This CPU Test is really going to be comprehensive. Totally amazing. Thank you ;-) |
@MJoergen I was just wondering: Might it make sense to get rid of regtest.asm (find some clever way to test, if all 256 register banks are there using some better checksum mechanism that I did back in the days. Maybe CRC16?) and add the functionality of regtest.asm into your new cpu_test.asm? EDIT: One of our (yet unwritten) programming conventions is, that we use the semicolon
you would write
This is how Bernd and I did it everywhere in the project so far, includig everything in Now... ...as this is a very liberal project: This is just a suggestion. You actually do not need too change anything. 😃 |
One more thing, additionally to the long comment I wrote above ;-) As soon as you start testing this on real hardware, make sure that you turn the third switch (counted from the right of your Nexys4 DDR board), that is This will turn on the CPU Debug Mode and the address where the HALT instruction occured will be shown on the 7-segment display. |
Regarding comments: Good point about consistency. I'll change to match the existing style. |
@bernd-ulmann This subtle hardware bug might be interessting for you, too, just maybe out of academic curiosity :-) Today, while implementing the timer interrupt generator hardware, I discovered a subtle CPU bug in the hardware: When executing a
then implicitly always a
is being executed - but without messing up the status register. This does not really cost anything and in most cases you would not notice. But in my special case the following situation appeared: In a test Interrupt Service Routine (ISR) I wrote:
The timer interrupt generator device is implemented in a way, that it is being reset, when you write to any of the registers
Nobody! ... but it is happening due to the CPU bug and the implicit Next steps:
WOW! This incident shows me how important your cpu_test.asm is. I wonder, how we survived all the time without it ?! 😏 |
P.S.: My CPU bugfix for the above-mentioned subtlety nearly had a nasty side effect and nearly killed something like Well, "nearly" means I saw it and it did not happen. But this was luck. So I guess the cputest needs these kind of tests, too :-) |
…s had no visible effects but this one: When using the register of a MMIO device as a second indirect operand such as CMP 1, @r0 and if the device was sensitive to this register being re-written. Details: #9 (comment)
Very interesting. I was actually thinking about testing things like that. Specifically, I was thinking about testing that each CPU instruction performs the expected number of reads and writes and to the correct addresses. I remember something about the 6502 processor having a similar bug, where the INC instruction (if I remember correctly) did one read and TWO writes to memory. Well, something along those lines at least. I suggest that the cpu_test.asm be functional only, in that it should be a test that is independent of the hardware. And then we could make another test, e.g. cpu_bus_test.asm, that tests the correct bus functionality of the cpu. The point is, that to do this test we need some way of monitoring the bus activity of the cpu, and we need to figure out how to do that. This will probably require some extra support in the emulator and the FPGA. So for instance some debug module that records all the reads and writes to RAM and I/O. |
Thank you. Sounds like the perfect way forward. |
Just saw the huge progress you made today. Excellent! 👍 |
Thank you for the link. That is exactly the kind of thing I want to test! As of today I'm about half way done with the test suite. The plan for the test suite is to test the following two areas:
I've now completed part 1, and have just started on part 2. I'm still only running on the emulator, from the assumption that the emulator behaves correctly. And I'm still thinking about how to test the CPU bus behavior. Ideally, it should be done in a way that works identical in the emulator and the hardware, and should be fully automatic, i.e. no manual verification. Any ideas are welcome, I have not made up my mind yet on how to do that. |
Just for fun, I tried the recent version of the CPU test suite on hardware, and I've already filed an Issue #49 :-) |
I need to admit that i am a bit scared about you running this kind of super comprehensive test suite against the hardware 😅 |
Your first check-in today: 4:26 (am !) wow... impressive! Are you such an early bird or are you currently at another timezone than Denmark? |
Just woke up early this morning :-D |
I just created a separate Issue #55 to handle the bus functional test suite. The current CPU test suite is now almost complete (not counting possible changes due to Issue #53). Here is a list of the remaining tests to perform:
The register bank verification could be done using a Pseudo Random Number Generator to generate a deterministic sequence of 2056 different values that get written to each register, and then reading back each value and comparing with the expected. |
I love your idea of the Pseudo Random Number Generator with the deterministic sequence running through all 2048 registers. This is much better than my old and pretty dumb |
When testing register banking I came across a peculiarity, and I'm not sure what the intended behaviour is. After the following two instructions, carry is NOT set (at least in the emulator):
The value of R14 after these instructions is In the emulator, the addition does generate carry, which updates the register R14, but then the result of the addition is written, which overwrites the carry flag. I suppose this behavior is correct, but just want to mention it here, and hear your opinion. |
Just to note:
This was not added, because there is nothing special about the NOT instruction: It takes two operands like all other instructions. |
This behaviour is correct. SR is always updated before the write back to whatever destination register an instruction uses. This is necessary since it would be impossible otherwise to set/clear SR bits by bitwise AND/OR/XOR instructions. So in this case it is correct that the C flag is cleared in this case. |
@MJoergen YOU DID IT!! :-) This is amazing: With 3.823 lines of code, this program is even larger than Q-TRIS! ;-) I just tested it on the emulator and here is what I got: So everything is good (given the caveat described in issue #57). Now let's test it on hardware: Issue #51 is waiting... 😄 I will tomorrow be able to get my hands on an FPGA again - today I only have my laptop ;-) |
Enhance
test_programs/cpu_test.asm
to be (nearly) complete.Step 1: Do a bit more than today :-)
The text was updated successfully, but these errors were encountered: