8 changed files with 181 additions and 5 deletions

No files matched your search

+7
View File
@@ -41,3 +41,10 @@ docs/MENUS.md for the complete tree and docs/VALIDATION.md for acceptance scope.
the earlier extensive hardware test image separately from final startup checks.
These changes do not modify the FPGA hardware implementation or timing constraints.
## Secondary joystick buttons, 2026-11-21
- Correct inherited left/right secondary-button routing at the MiSTer boundary.
- Add service-manual-based real-RTL regression covering both port-swap settings,
all button combinations, keyboard sharing and mouse primary-button behavior.
- See docs/VALIDATION.md for simulation, build and hardware qualification scope.
+2 -2
View File
@@ -596,8 +596,8 @@ coco3fpga coco3 (
.SWAP_M_J(SWAP_M_J),
// R1, L2, R2, L1
.P_SWITCH(~{coco_joy2[4],coco_joy1[5],coco_joy2[5],coco_joy1[4]}),
// Active low P_SWITCH: R1, R2, L2, L1 (PIA PA0=R1, PA1=L1, PA2=R2, PA3=L2)
.P_SWITCH(~{coco_joy2[4],coco_joy2[5],coco_joy1[5],coco_joy1[4]}),
.SWITCH(switch),
// .SOUND_OUT(cocosound),
.SOUND_LEFT(audio_left),
+15
View File
@@ -6,6 +6,21 @@ logic from new features and defects found while integrating those features.
The checks below establish their stated scopes; they do not turn source
inspection into a claim of a reproduced field failure.
## Inherited secondary joystick-button routing, 2026-11-21
The MiSTer top-level binding crossed the two joystick secondary buttons while
primary buttons and axes stayed with their selected ports. This wiring is
already present in upstream first commit f00b53c (2021-12-21), not introduced by
Plus. Correct only the P_SWITCH binding and its misleading secondary-row comments.
The Tandy 26-3334 service manual, printed page9, assigns PIA0 PA0=right primary,
PA1=left primary, PA2=right secondary and PA3=left secondary.
The extracted actual-RTL regression fails on unchanged wiring and passes524288
cases on the correction: both port-swap positions, all16 button combinations,
mouse states, keyboard column masks and keyboard-row patterns. It is included in
scripts/run_regressions.py. This is a simulation result, not a physical-controller
or CocoMan firing pass. Native fit, timing and hardware checks are pending here.
## Inherited clock, reset and memory paths
| Area and problem | Change and relevant source | Verification and limits |
+33
View File
@@ -1,5 +1,38 @@
# Validation and acceptance scope
## Secondary joystick correction, 2026-11-21
Source and extracted-RTL evidence identifies crossed secondary buttons in the
inherited MiSTer wrapper. The service-manual PIA oracle fails on the unchanged
binding and passes524288 combinations after correction, including both port
swaps, simultaneous button presses, mouse primary-button gating and keyboard
row sharing. All 16 functional regression jobs pass, including that new test.
A native Quartus Prime Lite 17.0.2 Build 602 fit at seed 5 completes with zero
errors and 73 warnings in 15:03. The build uses 19,280 ALMs (46%) and 495 RAM
blocks (90%). All summary slacks are positive; minimum setup is +0.041 ns.
Seven fitted path audits cover both timing corners: 368 report scopes, of which
288 contain paths and 80 synchronous-only recovery/removal scopes are explicitly
empty. All populated scopes are nonnegative. No illegal or unconstrained clocks
remain. Existing classified asynchronous/board pin contracts remain subject to
the documented conditional SDRAM and PCB profile, not universal electrical
qualification.
The resulting RBF is 3,963,336 bytes, SHA-256
`ec0faf3ebf90a88e76d52814f8b3abbf63f8bede7af1ad00b1cd9df6610ede9a`.
Project inputs match the committed bf36c0569a8296f3561f50d2d2c11e9c3353a673
implementation exactly. Reproducible receipts reside under ignored
`build/joystick-secondary-20261121/build.json`,
`build/joystick-secondary-timing-20261121/result.json`, and
`build/joystick-secondary-regressions-20261121/regression-logs/result.json`.
No changed core has been installed or tested with CocoMan yet. Hardware button
values, two-button gameplay, saved settings and fresh-image four-disk startup
remain pending; prior 1.0.0 hardware observations do not qualify the changed RBF.
The DE1 native GPIO contract is separate. This correction changes only the
MiSTer USB boundary binding; no DE1 RTL or hardware qualification is claimed.
## Source-tree hygiene, 2026-11-18
Removed the inherited 162-byte Word owner/lock file `docs/~$Co3FPGA.docx`
+3 -2
View File
@@ -3707,6 +3707,7 @@ end
* 1 left 2
* 2 right 2
* 3 right 1
* PIA PA0=right1, PA1=left1, PA2=right2, PA3=left2.
******************************************************************************/
assign KEYBOARD_IN[0] = !((!KEY_COLUMN[0] & KEY[0]) // @
| (!KEY_COLUMN[1] & KEY[1]) // A
@@ -3736,7 +3737,7 @@ assign KEYBOARD_IN[2] = !((!KEY_COLUMN[0] & KEY[16]) // P
| (!KEY_COLUMN[5] & KEY[21]) // U
| (!KEY_COLUMN[6] & KEY[22]) // V
| (!KEY_COLUMN[7] & KEY[23]) // W
| !P_SWITCH[2]); // Left Joystick Switch 2
| !P_SWITCH[2]); // Right Joystick Switch 2
assign KEYBOARD_IN[3] = !((!KEY_COLUMN[0] & KEY[24]) // X
| (!KEY_COLUMN[1] & KEY[25]) // Y
@@ -3746,7 +3747,7 @@ assign KEYBOARD_IN[3] = !((!KEY_COLUMN[0] & KEY[24]) // X
| (!KEY_COLUMN[5] & KEY[29]) // Backspace & left
| (!KEY_COLUMN[6] & KEY[30]) // right
| (!KEY_COLUMN[7] & KEY[31]) // space
| !P_SWITCH[1]); // Right Joystick Switch 2
| !P_SWITCH[1]); // Left Joystick Switch 2
assign KEYBOARD_IN[4] = !((!KEY_COLUMN[0] & KEY[32]) // 0
| (!KEY_COLUMN[1] & KEY[33]) // 1
+1
View File
@@ -40,6 +40,7 @@ def main():
('test_registered_interfaces.py', 'registered-functional', [str(project)]),
('test_reset_domains.py', 'reset-functional', [str(project)]),
('test_keyboard_control_phase.py', 'keyboard-functional', [str(project)]),
('test_joystick_button_routing.py', 'joystick-buttons-functional', [str(project)]),
('test_peripheral_phase.py', 'peripheral-functional', [str(project)]),
('test_external_sdram_commands.py', 'commands-functional', [str(project)]),
('test_external_sdram.py', 'delayed-functional', [str(project)]),
+118
View File
@@ -0,0 +1,118 @@
#!/usr/bin/env python3
"""Simulate actual MiSTer pad routing and keyboard rows against CoCo 3 PIA wiring.
Copyright (c) 2026 Brian K. Holman. Original contribution.
Hardware oracle: Tandy 26-3334 service manual, printed p9: PA0 right1,
PA1 left1, PA2 right2, PA3 left2. No FPGA deployment or game execution.
"""
import argparse
import hashlib
import json
import os
from pathlib import Path
import re
import subprocess
ROOT = Path(__file__).resolve().parents[1]
BENCH = r"""
`timescale 1ns/1ps
module joystick_button_tb;
reg clk_sys=0;
always #5 clk_sys=~clk_sys;
reg [31:0] joy1=0,joy2=0;
reg [63:0] status=0;
reg [72:0] KEY=0;
reg [7:0] KEY_COLUMN=8'hff;
reg ps2_button=1,SWAP_M_J=0;
wire [3:0] rows;
actual_buttons dut(clk_sys,joy1,joy2,status,KEY,KEY_COLUMN,ps2_button,SWAP_M_J,rows);
reg [3:0] want,pressed;
reg [31:0] left_pad,right_pad;
integer sw,b,mouse,cols,keys,r,c,cases=0;
initial begin
for(sw=0;sw<2;sw=sw+1)
for(b=0;b<16;b=b+1) begin
@(posedge clk_sys);
status[6]=sw;joy1=0;joy2=0;
joy1[4]=b[0];joy1[5]=b[1];joy2[4]=b[2];joy2[5]=b[3];
@(negedge clk_sys);#1;
left_pad=sw?joy2:joy1;right_pad=sw?joy1:joy2;
for(mouse=0;mouse<4;mouse=mouse+1)
for(cols=0;cols<256;cols=cols+1)
for(keys=0;keys<16;keys=keys+1) begin
ps2_button=mouse[0];SWAP_M_J=mouse[1];KEY_COLUMN=cols;KEY=0;
for(r=0;r<4;r=r+1)
for(c=0;c<8;c=c+1) KEY[r*8+c]=keys[r];
// Independent service-manual PA bit order, plus existing mouse1.
pressed[0]=right_pad[4] | (!ps2_button & SWAP_M_J);
pressed[1]=left_pad[4];pressed[2]=right_pad[5];pressed[3]=left_pad[5];
want=~pressed;
for(r=0;r<4;r=r+1)
for(c=0;c<8;c=c+1)
if(!KEY_COLUMN[c] && KEY[r*8+c]) want[r]=0;
#1;
if(rows!==want)
$fatal(1,"PIA routing mismatch swap=%0d buttons=%h mouse=%0d columns=%h keys=%h got=%h expected=%h",sw,b,mouse,KEY_COLUMN,keys,rows,want);
cases=cases+1;
end
end
$display("PASS %0d PIA comparisons: 16 button combinations, 2 port swaps, 4 mouse states, 256 column masks, 16 keyboard-row patterns",cases);
$finish;
end
endmodule
"""
def digest(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
def main():
p = argparse.ArgumentParser(description=__doc__)
p.add_argument('project', type=Path)
p.add_argument('output', type=Path)
p.add_argument('--suite', type=Path, required=True)
a = p.parse_args()
a.suite = a.suite.resolve()
output = a.output.resolve()
if not output.is_relative_to(ROOT / 'build') or output.exists():
p.error('Use a fresh directory under this repository build/')
top_path = a.project / 'CoCo3.sv'
core_path = a.project / 'rtl/coco3fpga.sv'
top = top_path.read_text()
core = core_path.read_text()
pad_state = top[top.index('reg [31:0] coco_joy1'):top.index('reg [15:0] coco_ajoy1')]
binding = re.findall(r'\.P_SWITCH\(([^\n]+)\),', top)
if len(binding) != 1:
raise ValueError('Require one literal P_SWITCH binding')
rows = core[core.index('assign KEYBOARD_IN[0]'):core.index('assign KEYBOARD_IN[4]')]
output.mkdir(parents=True)
actual = output / 'actual-buttons.sv'
actual.write_text('module actual_buttons(input clk_sys,input [31:0] joy1,joy2,'
'input [63:0] status,input [72:0] KEY,input [7:0] KEY_COLUMN,'
'input ps2_button,SWAP_M_J,output [3:0] rows);\n'
'wire [3:0] P_SWITCH;wire [7:0] KEYBOARD_IN;\n' + pad_state +
'\nassign P_SWITCH=' + binding[0] + ';\n' + rows +
'\nassign rows=KEYBOARD_IN[3:0];endmodule\n', encoding='utf-8')
bench = output / 'test.sv'
bench.write_text(BENCH, encoding='utf-8')
env = os.environ.copy()
env['PATH'] = os.pathsep.join([str(a.suite / 'bin'), str(a.suite / 'lib'), env['PATH']])
ext = '.exe' if os.name == 'nt' else ''
with (output / 'compile.log').open('w') as log:
subprocess.run([str(a.suite / 'bin' / ('iverilog' + ext)), '-g2012',
'-s', 'joystick_button_tb', '-o', str(output / 'test.vvp'), str(actual), str(bench)],
env=env, stdout=log, stderr=subprocess.STDOUT, check=True)
with (output / 'test.log').open('w') as log:
result = subprocess.run([str(a.suite / 'bin' / ('vvp' + ext)), str(output / 'test.vvp')],
env=env, stdout=log, stderr=subprocess.STDOUT)
record = dict(passed=result.returncode == 0, exit_code=result.returncode,
hardware_tested=False, scope='Extracted actual routing and keyboard rows, service-manual oracle',
sha256={str(x): digest(x) for x in (top_path, core_path, Path(__file__), actual, bench, output / 'test.log')})
(output / 'test-result.json').write_text(json.dumps(record, indent=2) + '\n', encoding='utf-8')
print((output / 'test.log').read_text())
raise SystemExit(result.returncode)
if __name__ == '__main__':
main()
+2 -1
View File
@@ -67,7 +67,8 @@
"scripts/nmi_timing_paths.tcl",
"scripts/reset_cpu_timing_paths.tcl",
"scripts/rom_inputs.py",
"scripts/run_regressions.py",
"scripts/run_regressions.py",
"scripts/test_joystick_button_routing.py",
"scripts/source_snapshot.py",
"scripts/ssc_integrated_timing.tcl",
"scripts/test_bh_menu.py",