openXC7 / primitive-tests

Test designs for various primitives supported by openXC7
BSD 3-Clause "New" or "Revised" License
6 stars 1 forks source link

lutram-tests/jtag-test: Add LUTRAM INIT openocd tests #4

Closed hansemro closed 2 months ago

hansemro commented 2 months ago

This PR introduces tests.cfg with openocd test functions to validate whether LUTRAM is initialized correctly (assuming the user did not overwrite contents of LUTRAM).

For example, if I have a bitstream with RAM32M freshly loaded onto the FPGA, I can test RAM32M by running the following:

$ openocd -f digilent-hs2.cfg -f tests.cfg -c "print_test_result [test_RAM32M_init]" -c "shutdown"
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : clock speed 1 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x13636093 (mfg: 0x049 (Xilinx), part: 0x3636, ver: 0x1)
Warn : gdb services need one or more targets defined
setup.cfg loaded
tests.cfg loaded
lutram_do[0]: PASS
lutram_do[1]: PASS
lutram_do[2]: PASS
lutram_do[3]: PASS
lutram_do[4]: PASS
lutram_do[5]: PASS
lutram_do[6]: PASS
lutram_do[7]: PASS
shutdown command invoked

I can force a failure by writing to some address with a different value:

$ openocd -f digilent-hs2.cfg -f tests.cfg -c "read_lutram 0x0" \
                    -c "write_lutram 0x0 0x42" \
                    -c "print_test_result [test_RAM32M_init]" \
                    -c "shutdown"
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : clock speed 1 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x13636093 (mfg: 0x049 (Xilinx), part: 0x3636, ver: 0x1)
Warn : gdb services need one or more targets defined
setup.cfg loaded
tests.cfg loaded
0x3c
0
port group 0: got 0x76543212 but expected 0x76543210
port group 1: got 0x89abcdec but expected 0x89abcdef
port group 2: got 0xf0ffffc but expected 0xf0fffff
port group 3: got 0x150bad1 but expected 0x150bad0
lutram_do[0]: FAIL
lutram_do[1]: FAIL
lutram_do[2]: FAIL
lutram_do[3]: FAIL
lutram_do[4]: FAIL
lutram_do[5]: FAIL
lutram_do[6]: FAIL
lutram_do[7]: FAIL
shutdown command invoked
hansemro commented 2 months ago

Currently going through each LUTRAM with Vivado bitstreams to ensure they pass.

hansemro commented 2 months ago

I should also mention that I am being very conservative in terms of adapter frequency, but feel free to bump this up if you want very fast tests (and dislike flashing LEDs).

(Default) 1kHz

$ time openocd -f digilent-hs2.cfg -f tests.cfg -c "print_test_result [test_RAM256X1S_init]" -c "shutdown"
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : clock speed 1 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x13636093 (mfg: 0x049 (Xilinx), part: 0x3636, ver: 0x1)
Warn : gdb services need one or more targets defined
setup.cfg loaded
tests.cfg loaded
lutram_do[0]: PASS
shutdown command invoked

real    0m18.157s
user    0m0.016s
sys     0m0.022s

1 MHz

$ time openocd -f digilent-hs2.cfg -f tests.cfg -c "adapter speed 1000" -c "print_test_result [test_RAM256X1S_init]" -c "shutdown"
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : clock speed 1 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x13636093 (mfg: 0x049 (Xilinx), part: 0x3636, ver: 0x1)
Warn : gdb services need one or more targets defined
setup.cfg loaded
tests.cfg loaded
adapter speed: 1000 kHz

lutram_do[0]: PASS
shutdown command invoked

real    0m0.780s
user    0m0.012s
sys     0m0.017s
hansemro commented 2 months ago

@hansfbaier tests passed with Vivado (and openXC7) bitstreams.

hansfbaier commented 2 months ago

Thanks for the great work 👍