| 1 | #!/usr/bin/env python3 |
| 2 | """Check that the VERA tests cite the RTL the emulator claims to implement. |
| 3 | |
| 4 | The VERA conformance tests quote Verilog by file and line. Those citations are |
| 5 | only meaningful against one revision, and the revision that matters is the one |
| 6 | the emulator reports itself to be: guest software reads VERA_VERSION_MAJOR, |
| 7 | MINOR and PATCH back from registers 0x00-0x02 and adapts to them. Whatever |
| 8 | firmware any particular physical board carries, an emulator claiming 47.0.2 has |
| 9 | to behave like 47.0.2. |
| 10 | |
| 11 | So this fails when src/video.c and tests/fetch_vera_rtl.py stop agreeing. |
| 12 | Bumping the emulator's version is legitimate, but it invalidates every cited |
| 13 | line number, and that has to be a deliberate step rather than a silent one. |
| 14 | |
| 15 | It does not need the RTL to be present -- it compares two declarations, not the |
| 16 | Verilog itself. |
| 17 | |
| 18 | python tests/check_vera_version.py |
| 19 | |
| 20 | WHAT THIS DOES NOT CHECK, AND WHY IT MATTERS |
| 21 | -------------------------------------------- |
| 22 | The version register is a claim, and the rest of the emulator does not honour |
| 23 | it. This is a composite of several revisions rather than any one of them: |
| 24 | |
| 25 | version register R47.0.2 video.c |
| 26 | PSG saw/triangle R48 XOR with ~pulsewidth, vera_psg.c:122-123, |
| 27 | backported by #290 on 2024-08-11 -- two |
| 28 | months BEFORE the RTL change (a8135f32, |
| 29 | 2024-10-21) that shipped in R48 |
| 30 | PCM AUDIO_CTRL none bit 6 restart and bits 7+6 loop match |
| 31 | 70a03e00, which lived on trunk for five |
| 32 | weeks in 2023 and was reverted as an |
| 33 | accidental merge |
| 34 | PCM AUDIO_RATE none the 256-val fold appears in no revision |
| 35 | |
| 36 | The pattern is that this emulator tracks vera-module trunk and proposals rather |
| 37 | than releases, so it can hold behaviour that no released bitstream ever had. |
| 38 | |
| 39 | That makes "base the tests on version X" impossible to satisfy by picking a tag: |
| 40 | the emulator would diverge from any single one. Each subsystem records the |
| 41 | revision it is actually checked against instead. For PCM the choice is moot -- |
| 42 | audio_fifo.v, pcm.v and audio.v are byte-identical across v47.0.2 and v48.0.1 -- |
| 43 | but for PSG it decides the expected waveform, and R48 is what the code |
| 44 | implements. |
| 45 | |
| 46 | The tidy end state is to bump this emulator to 48.0.1: PSG already matches it, |
| 47 | PCM is unchanged between the two, and the only obstacles are the two PCM |
| 48 | behaviours above, which match no revision and are bugs independent of version. |
| 49 | """ |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | = .. |
| 56 | = / / |
| 57 | = / / |
| 58 | |
| 59 | # The vera-module tag whose RTL the VERA tests cite, and the emulator version it |
| 60 | # corresponds to. Both halves are stated so a mismatch names which side moved. |
| 61 | # |
| 62 | # One wrinkle, recorded rather than smoothed over: the RTL inside tag v47.0.2 |
| 63 | # reports 47.0.0 from its own version registers (top.v:191, 199, 207), not |
| 64 | # 47.0.2 -- the tag name and the registers disagree in the patch field. v48.0.1 |
| 65 | # introduced VERSION_MAJOR/MINOR/BUILD defines and is self-consistent. Nothing |
| 66 | # in the audio path turns on this, since audio_fifo.v, pcm.v and audio.v are |
| 67 | # byte-identical across the two tags, but it does mean that RTL reporting |
| 68 | # exactly 47.0.2 does not exist. v47.0.2 is the closest thing to what the |
| 69 | # emulator claims. |
| 70 | = |
| 71 | = |
| 72 | = |
| 73 | |
| 74 | |
| 75 | |
| 76 | = |
| 77 | = |
| 78 | |
| 79 | = |
| 80 | |
| 81 | |
| 82 | return None |
| 83 | |
| 84 | return |
| 85 | |
| 86 | |
| 87 | |
| 88 | = |
| 89 | = |
| 90 | |
| 91 | |
| 92 | return None |
| 93 | return |
| 94 | |
| 95 | |
| 96 | |
| 97 | = |
| 98 | = |
| 99 | |
| 100 | return 1 |
| 101 | |
| 102 | = True |
| 103 | |
| 104 | |
| 105 | = |
| 106 | = |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | = False |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | = False |
| 119 | |
| 120 | |
| 121 | = |
| 122 | |
| 123 | return 0 |
| 124 | |
| 125 | |
| 126 | |
| 127 | |