Files
bholman cb40fed3b9 Introduce Coco 3 Plus for MiSTer
Add original-firmware Sound & Speech, four configurable Multi-Pak sockets,
bounded per-slot ROM allocation and a nine-page menu organized around devices
and media. Repair inherited clock/reset/CPU-memory/video paths and add explicit
conditional external-I/O timing contracts. Preserve native Main startup-file
ordering, saved layouts, stock-core separation and the coco3plus media profile.

Provide native Windows tool downloads, pinned ToolShed ROM assembly, fresh
Quartus builds, functional and fitted timing checks, reviewed release packaging
and passwordless SSH installation with backups. Retain original component
notices, document contribution copyright and keep SSC ROM inputs outside Git.

Validation: Quartus17.0.2 Build602 seed5, zero errors; 15 functional jobs,
368 both-corner timing scopes and eight tooling-integrity checks pass.
The renamed build reaches Disk BASIC, PRINT1+1 returns2 and SSC loads ready.
Physical cold power cycling and conditional board-delay assumptions remain
separate. Full original upstream histories are preserved before this single
consolidated implementation commit.
2026-11-18 16:00:45 -07:00

79 lines
5.5 KiB
Tcl

# Original Coco 3 Plus contributions: Copyright (c) 2026 Brian K. Holman.
# Original component notices/terms retained; see COPYRIGHT.md and LICENSING.md.
# MiSTer board interface profile; see docs/experiments/EXTERNAL_IO_TIMING.md.
# Alliance AS4C32M16SB -7, CL3. External round trip <= 0.50 ns;
# data-to-clock PCB skew bounded by +/-0.25 ns (SDRAM writes and HDMI).
# These are explicit design bounds, NOT measured facts about an installed kit.
# A negative result must remain negative. Read hold is never waived.
set mem_clock {emu|pll|pll_inst|altera_pll_i|general[0].gpll~PLL_OUTPUT_COUNTER|divclk}
set sys_clock {emu|pll|pll_inst|altera_pll_i|general[1].gpll~PLL_OUTPUT_COUNTER|divclk}
set hd_clock {pll_hdmi|pll_hdmi_inst|altera_pll_i|cyclonev_pll|counter[0].output_counter|divclk}
foreach n [list $mem_clock $sys_clock $hd_clock] {
if {[get_collection_size [get_pins $n]] != 1} {error "Missing exact external-interface clock pin $n"}
}
set pixel [get_registers {*|MISTER_COCOVID|PIX_CLK}]
if {[get_collection_size $pixel] != 1} {error "Expected one divide-by-four pixel register"}
create_generated_clock -name coco_pixel -source [get_pins $sys_clock] -edges {3 7 11} $pixel
create_generated_clock -name sdram_forward -source [get_pins $mem_clock] -divide_by 1 -invert [get_ports SDRAM_CLK]
set dq [get_ports {SDRAM_DQ[*]}]
if {[get_collection_size $dq] != 16} {error "Expected sixteen SDRAM DQ pins"}
set_input_delay -clock sdram_forward -max 5.90 $dq
set_input_delay -clock sdram_forward -min 2.50 $dq
# This is the preceding output-launch beat: CL3 READ T4 -> launch T6,
# receive T7. READY retains its original alignment (READ_CAPTURE_EXTRA=0).
# A setup-only edge shift intentionally tightens hold by a cycle.
# Do NOT append the usual enable-multicycle hold compensation here.
set capture [get_registers {*|coco3_sdram|dq_reg[*]}]
if {[get_collection_size $capture] != 16} {error "Expected sixteen SDRAM capture registers"}
set_multicycle_path -setup 2 -from $dq -to $capture
set mem_outputs [get_ports {SDRAM_A[*] SDRAM_BA[*] SDRAM_n* SDRAM_DQM* SDRAM_DQ[*]}]
if {[get_collection_size $mem_outputs] != 37} {error "Expected 37 SDRAM output/bidirectional pins"}
set_output_delay -clock sdram_forward -max 1.75 $mem_outputs
set_output_delay -clock sdram_forward -min -1.05 $mem_outputs
create_generated_clock -name hdmi_scaled_forward -source [get_pins $hd_clock] -divide_by 1 -invert [get_ports HDMI_TX_CLK]
create_generated_clock -name hdmi_direct_forward -source [get_pins $sys_clock] -divide_by 1 -invert -add [get_ports HDMI_TX_CLK]
# Carry the existing platform clock groups through the newly named descendants.
# HDMI data registers are clocked by the same selected mux as their DDIO clock.
set_clock_groups -exclusive \
-group [get_clocks {*|pll|pll_inst|altera_pll_i|*[*].*|divclk coco_pixel sdram_forward hdmi_direct_forward}] \
-group [get_clocks {pll_hdmi|pll_hdmi_inst|altera_pll_i|*[0].*|divclk hdmi_scaled_forward}] \
-group [get_clocks {*|pll_audio_inst|altera_pll_i|*[0].*|divclk}] \
-group [get_clocks spi_sck] -group [get_clocks hdmi_sck] \
-group [get_clocks {*|h2f_user0_clk}] \
-group [get_clocks FPGA_CLK1_50] -group [get_clocks FPGA_CLK2_50] -group [get_clocks FPGA_CLK3_50]
set video [get_ports {HDMI_TX_D[*] HDMI_TX_DE HDMI_TX_HS HDMI_TX_VS}]
if {[get_collection_size $video] != 27} {error "Expected 27 HDMI video data/control pins"}
foreach clk {hdmi_scaled_forward hdmi_direct_forward} {
set_output_delay -clock $clk -max 2.05 -add_delay $video
set_output_delay -clock $clk -min -1.55 -add_delay $video
}
# The real CE/serializer is checked by scripts/test_external_audio.py at both
# 48/96 kHz and during live switches. Data/LRCLK setup >=5 audio fabric cycles,
# hold >=3. Bound each output's absolute arrival, INCLUDING clock insertion,
# to 0..40 ns. The 40.682 ns fabric period leaves >79 ns receiver hold margin
# even at opposite output extrema, after the 2 ns/0.25 ns external allowance.
set i2s_regs [get_registers {audio_out|i2s|sclk audio_out|i2s|lrclk audio_out|i2s|sdata}]
set i2s_ports [get_ports {HDMI_SCLK HDMI_LRCLK HDMI_I2S}]
if {[get_collection_size $i2s_regs] != 3 || [get_collection_size $i2s_ports] != 3} {error "Expected three actual I2S output registers and pins"}
set_max_delay 40.0 -from $i2s_regs -to $i2s_ports
set_min_delay 0.0 -from $i2s_regs -to $i2s_ports
# MCP23009 fast-mode profile: 250 kHz, >=2 us half-periods. The independent
# protocol checker covers 0/300 ns edge extrema. A 40 ns fabric propagation
# envelope leaves low >=1660 ns and high >=1660 ns, beyond 1300/600 ns minima.
# Slave tAA <=900 ns, SDA edge <=300 ns, SCL fall <=300 ns and two fabric
# envelopes <=80 ns leave >=420 ns before the next 2 us sample slot.
# No fictitious external synchronous clock.
set io_drive [get_registers {mcp23009|i2c|I2C_CLOCK mcp23009|i2c|SCLK mcp23009|i2c|SDO[19]}]
set io_sample [get_registers {mcp23009|i2c|ACK mcp23009|i2c|rdata[*]}]
# get_registers includes fitted physical duplicates of a logical register.
# Require every logical boundary, and constrain all returned clones as well.
foreach io_role {mcp23009|i2c|I2C_CLOCK mcp23009|i2c|SCLK mcp23009|i2c|SDO[19]} {
if {[get_collection_size [get_registers $io_role]] < 1} {error "Missing MCP I2C drive boundary $io_role"}
}
if {[get_collection_size $io_drive] < 3 || [get_collection_size $io_sample] < 6} {error "MCP I2C pin boundaries changed"}
set_max_delay 40.0 -from $io_drive -to [get_ports {IO_SDA IO_SCL}]
set_min_delay 0.0 -from $io_drive -to [get_ports {IO_SDA IO_SCL}]
set_max_delay 40.0 -from [get_ports IO_SDA] -to $io_sample
set_min_delay 0.0 -from [get_ports IO_SDA] -to $io_sample
derive_clock_uncertainty