PDA

View Full Version : Memory test algorithm



alank2
March 6th, 2018, 09:06 AM
I'm not sure if this is the best forum except to say that it is for a CP/M SBC I want to build, so maybe it is.

I'm wanting to test a 512K SRAM at startup. I'm using an AVR microcontroller to do the testing, then it will preload the SRAM with something for the Z80 to run, and release the reset and allow it to go on its way.

My question is about a decent startup memory test that is fast and thorough. It is static ram if that makes a difference, not dynamic.

What I've tried:

Technique 1:
pass 1: for each byte - fill with 0x55
pass 2: for each byte - verify it is 0x55, write it immediately to 0xAA (pass has 2 operations)
pass 3: for each byte - verify it is 0xAA, write it immediately to 0x55 (pass has 2 operations)
pass 4: for each byte - fill with 0x00

Technique 2:
pass 1: for each byte - fill with 0x55 0xAA 0xAA
pass 2: for each byte - verify with 0x55 0xAA 0xAA
pass 3: for each byte - fill with 0xAA 0xAA 0x55
pass 4: for each byte - verify with 0xAA 0xAA 0x55
pass 5: for each byte - fill with 0xAA 0x55 0xAA
pass 6: for each byte - verify with 0xAA 0x55 0xAA
pass 7: for each byte - fill with 0x00

Questions:

1) I've read about doing a data line test, whrere you write 00000001, then 00000010, and so on to test each data line. The same thing can be done with address lines. Are these worth doing if the above two type of tests are done? They would take very little time, but extra code.

2) My final fill with 0x00 is unnecessary I know, but I had a secondary idea. I could fill memory with the HALT instruction? I could then monitor for the halt condition on the AVR and if it ever executes this instruction, the AVR could report (Z80 is halted) which might be nice to know if it tries to execute code where it shouldn't.

3) What happened on real Z80 machines when HALT was executed? People thought the system was locked up?

4) I've tried to do some reaching on line about various tests and most mention march and have a lot of different ones. What I'm looking for is a technique that can (1) do as few passes as possible, and (2) preferably one operation per pass.

5) A guy on another forum recommended technique #2, but I haven't seen it anywhere on the web. Has anyone else seen/used it?

Al Kossow
March 6th, 2018, 09:25 AM
My question is about a decent startup memory test that is fast and thorough.

http://www.ee.ncu.edu.tw/~jfli/memtest/lecture/ch03.pdf

or google around for 'memory test alogrithms'

Chuck(G)
March 6th, 2018, 09:39 AM
Knowing how to do a memory test often involves knowing about the organization of the memory; e.g. how the addressing is performed and how data is buffered. Some RAM, for example, is sensitive to certain data and/or address patterns.

Simple "walking" tests don't usually do a thorough job of iit.

Here are some considerations (http://www.ganssle.com/testingram.htm)

If a Z80 executes a halt instruction, it locks up until interrupted (assuming enabled interrupts) or a TRAP condition is raised The refresh register continues to cycle, however. HALT is a useful instruction, particularly in cases where you're waiting for an interrupt to occur.

Dwight Elvey
March 6th, 2018, 10:44 AM
March C is almost as simple as the test you describe but catches many of the errors in data and addressing. For a test that doesn't know much about the design of the chips you have, it is a good test. It is used by many manufactures for the first test in a test suite as it culls out most of the simple failures early in the test. For static memory a read disturb test is always a good idea. The March C can be modified to do multiple quick reads and only check that last read to do the read disturb. Static RAM also needs a retention test as well. You can use the March C for this as well but isn't uniform at testing for failures because of the address reversal. Still a long delay between address passes should be enough. You get two test in one this way. It does have the disadvantage that it is not pushing the address decoder.
Choice of address sequence is always an issue as well. I always like to have it do a straight address sequence, a bit reversed address sequence and a grey code address sequence. These can all be used with the basic March C sequence.
Data pattern used really depends on the chip design. Many chip twizzle the bit lines making a checker board not as effective. Luckily for what you are doing on older chips, it is not likely that a there would be a bit line to bit line short. Your checkboard patterns are most likely fine.
Dwight

durgadas311
March 6th, 2018, 10:48 AM
3) What happened on real Z80 machines when HALT was executed? People thought the system was locked up?

4) I've tried to do some reaching on line about various tests and most mention march and have a lot of different ones. What I'm looking for is a technique that can (1) do as few passes as possible, and (2) preferably one operation per pass.

Re 3) HLT was used legitimately by some systems. The soft-sectored floppy controllers on the Heathkit H89 use HLT in order to provide a quick-response method of waiting for the first byte of a I/O transfer. The HLT is woken up by the DRQ interrupt, which does not actually vector to a service routine but simply forces an EI on the bus. That was the fastest way to sleep and wake up. The Kaypro Z80 computers used HLT similarly, but not identically. I'm sure there are others. But you can define HLT as you wish - it can mean a fatal error if you want.

Re 4) One memory test I recall reading about used a repeating BCD pattern (0x00...0x99). It tests all bits, and has the advantage of not repeating at "binary intervals" and thus does not hide certain types of errors that might occur at specific address ranges. Multiple passes would start at different BCD values. Older memory tests might be oriented towards arrays of RAM chips, and what you need to test is different for large single chip monolithic RAM.

alank2
March 6th, 2018, 01:10 PM
What is the point of MARCH going up and down? What difference does it make?

I was thinking about using a unique pattern, the problem is that it makes the test quite a bit longer even just to retrieve a pattern from flash or a variable in the AVR's sram. It can read or write to the external SRAM in 4 cycles, so the code around it contributes to the slowness depending on what I'm doing. I tried a PRNG and it slowed things considerably.

durgadas311
March 6th, 2018, 02:31 PM
What is the point of MARCH going up and down? What difference does it make?

I was thinking about using a unique pattern, the problem is that it makes the test quite a bit longer even just to retrieve a pattern from flash or a variable in the AVR's sram. It can read or write to the external SRAM in 4 cycles, so the code around it contributes to the slowness depending on what I'm doing. I tried a PRNG and it slowed things considerably.

It really depends on the goal of this test. If it is a power-up sanity check of memory, then you don't need too fancy an algorithm But if you are doing exhaustive memory stressing, then you probably want more than one algorithm.

I was thinking that you just wanted a quick test on power-up, for which something like the BCD pattern works well. It is simple and quick, and you could possibly even run a couple passes.

Dwight Elvey
March 6th, 2018, 03:49 PM
What is the point of MARCH going up and down? What difference does it make?

I was thinking about using a unique pattern, the problem is that it makes the test quite a bit longer even just to retrieve a pattern from flash or a variable in the AVR's sram. It can read or write to the external SRAM in 4 cycles, so the code around it contributes to the slowness depending on what I'm doing. I tried a PRNG and it slowed things considerably.

If you have an address that is stuck, and you only go one way, you will likely not notice it. Going forwards and backwards twice ensures you have no address faults.
Dwight

alank2
March 6th, 2018, 03:54 PM
Thanks durgadas311, I think I got it working pretty well. I have it checking the data lines, address lines, latch test, and all cell testing in <3 seconds so I think I can move on!

ziloo
March 8th, 2018, 10:56 AM
Do I remember correctly that there was a "walking" or "march" test program
that was called "worm" before worm became a nasty word?

ziloo :mrgreen: