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

75 lines
5.1 KiB
Systemverilog

// Original Coco 3 Plus contributions: Copyright (c) 2026 Brian K. Holman.
// Original component notices/terms retained; see COPYRIGHT.md and LICENSING.md.
// SPDX-License-Identifier: BSD-3-Clause
// Shared digital SSC cartridge; clocks use enables, never generated fabric clocks.
// reset is FPGA power/reconfiguration reset (clears volatile ROM loader state).
// cartridge_reset restarts chips while retaining loaded ROMs and glue SRAM.
module ssc_cartridge #(parameter integer CLOCK_HZ=114545408)(
input wire clk,reset,cartridge_reset,enable,host_read,host_write,
input wire [15:0] host_address,input wire [7:0] host_data,
output wire host_read_valid,output wire [7:0] host_read_data,output wire [7:0] status,
input wire pic_rom_begin,pic_rom_write,input wire [11:0] pic_rom_address,input wire [7:0] pic_rom_data,
input wire speech_rom_begin,speech_rom_write,input wire [10:0] speech_rom_address,input wire [7:0] speech_rom_data,
output wire pic_loaded,speech_loaded,operational,fault,
output wire signed [15:0] audio_sample,output wire audio_valid,
output wire speech_standby,sound_activity,output wire [15:0] debug_pc);
reg [31:0] ay_phase,speech_phase,audio_phase;
reg ay_ce,phi_ce,speech_ce,audio_ce,phi_half;
wire [32:0] ay_next={1'b0,ay_phase}+33'd1789772;
wire [32:0] speech_next={1'b0,speech_phase}+33'd10000;
wire [32:0] audio_next={1'b0,audio_phase}+33'd44100;
wire [32:0] ay_wrapped=ay_next>=CLOCK_HZ?ay_next-CLOCK_HZ:ay_next;
wire [32:0] speech_wrapped=speech_next>=CLOCK_HZ?speech_next-CLOCK_HZ:speech_next;
wire [32:0] audio_wrapped=audio_next>=CLOCK_HZ?audio_next-CLOCK_HZ:audio_next;
always @(posedge clk)begin
if(reset)begin
ay_phase<=0;speech_phase<=0;audio_phase<=0;ay_ce<=0;phi_ce<=0;speech_ce<=0;audio_ce<=0;phi_half<=0;
end else begin
ay_ce<=ay_next>=CLOCK_HZ;phi_ce<=0;speech_ce<=speech_next>=CLOCK_HZ;audio_ce<=audio_next>=CLOCK_HZ;
ay_phase<=ay_wrapped[31:0];speech_phase<=speech_wrapped[31:0];audio_phase<=audio_wrapped[31:0];
if(ay_next>=CLOCK_HZ)begin phi_half<=!phi_half;phi_ce<=phi_half;end
end
end
wire pic_error,speech_error,pic_initialized,glue_initialized;
wire pic_overrun,speech_overrun,speech_fault,audio_overrun;
wire [31:0] illegal;
wire [7:0] command,host_result;
wire ignored_valid,command_read,busy_line,command_irq,command_busy,controller_reset,speech_reset;
wire gpio_request,gpio_write,gpio_ready;
wire [1:0] gpio_port;
wire [7:0] gpio_write_data,gpio_read_data,ay_bus,ay_read_data;
wire ay_select,ay_write,ald,speech_ready;
wire [5:0] allophone;
wire [17:0] ay_sum;
wire signed [15:0] speech_sample;
wire speech_valid,speech_busy,audio_busy;
wire [18:0] speech_pc;
wire [31:0] speech_frames;
wire rom_ready=pic_loaded&&speech_loaded;
assign fault=pic_error||speech_error||pic_overrun||speech_overrun||speech_fault||audio_overrun||(|illegal);
assign operational=rom_ready&&pic_initialized&&glue_initialized&&!fault;
// Address-independent status lets the wrapper sample at the CPU clock edge
// without feeding live CPU address/control back through the cartridge.
assign status=operational ? {!command_busy,speech_standby,!sound_activity,5'b11111} : 8'h7f;
assign host_read_valid=enable&&host_read&&(host_address==16'hff7d||host_address==16'hff7e);
assign host_read_data=!host_read_valid ? 8'd0 : host_address==16'hff7d ? 8'hff : operational ? host_result : 8'h7f;
ssc_host host(clk,reset||!rom_ready,enable&&operational,host_read,host_write,host_address,host_data,
ignored_valid,host_result,command_read,busy_line,command,command_irq,command_busy,
speech_standby,sound_activity,controller_reset,speech_reset);
ssc_tms7000 controller(.clk(clk),.reset(reset),.controller_reset(controller_reset||cartridge_reset),
.icount_tick(phi_ce),.rom_begin(pic_rom_begin),.rom_write(pic_rom_write),.rom_address(pic_rom_address),.rom_data(pic_rom_data),
.rom_loaded(pic_loaded),.load_error(pic_error),.initialized(pic_initialized),.overrun(pic_overrun),
.debug_pc(debug_pc),.illegal_count(illegal),.irq1(speech_ready),.irq3(command_irq),.timer_external(command[7]),
.gpio_request(gpio_request),.gpio_write(gpio_write),.gpio_port(gpio_port),.gpio_write_data(gpio_write_data),
.gpio_ready(gpio_ready),.gpio_read_data(gpio_read_data));
ssc_glue glue(clk,reset,gpio_request,gpio_write,gpio_port,gpio_write_data,gpio_ready,gpio_read_data,
glue_initialized,command,command_read,busy_line,ay_select,ay_write,ay_bus,ay_read_data,ald,allophone);
ssc_ay8913 ay(clk,reset||controller_reset||cartridge_reset,ay_ce,ay_select,ay_write,ay_bus,ay_read_data,ay_sum);
ssc_sp0256 speech(.clk(clk),.reset(reset),.speech_reset(speech_reset||cartridge_reset),.sample_ce(speech_ce),
.ald(ald),.allophone(allophone),.rom_begin(speech_rom_begin),.rom_write(speech_rom_write),
.rom_address(speech_rom_address),.rom_data(speech_rom_data),.rom_loaded(speech_loaded),.load_error(speech_error),
.data_request(speech_ready),.standby(speech_standby),.sample(speech_sample),.sample_valid(speech_valid),
.busy(speech_busy),.overrun(speech_overrun),.fault(speech_fault),.debug_pc(speech_pc),.frame_count(speech_frames));
ssc_audio audio(clk,reset,audio_ce,ay_sum,speech_sample,audio_sample,audio_valid,sound_activity,audio_overrun,audio_busy);
endmodule