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.
This commit is contained in:
1 parent
8b8cf72d1f
commit
cb40fed3b9
126 files changed
+12795
-528
No files matched your search
@@ -0,0 +1,91 @@
|
||||
// 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
|
||||
// Cartridge mix and digital SAC model, based on VCCPlus/MAME Tim Lindner.
|
||||
// audio_ce must be44100Hz: the reference RC coefficients are per audio sample.
|
||||
// Q16 PCM states and Q24 coefficients approximate the software float circuit.
|
||||
// This is a digital reference model, not a measured analog transfer function.
|
||||
module ssc_audio(input wire clk,reset,audio_ce,input wire [17:0] ay_sum,
|
||||
input wire signed [15:0] speech_sample,output reg signed [15:0] mixed_sample,
|
||||
output reg sample_valid,activity,overrun,output wire busy);
|
||||
localparam [3:0] IDLE=0,MIX=1,HP_PREP=2,HP_MULT=3,HP_STORE=4,
|
||||
ENV_PREP=5,ENV_MULT=6,ENV_STORE=7,AVERAGE=8,MULT_COMBINE=9;
|
||||
reg [3:0] state;
|
||||
assign busy=state!=IDLE;
|
||||
reg [15:0] ay_average;
|
||||
reg [17:0] divide_shift,quotient;
|
||||
reg [1:0] remainder;
|
||||
reg [4:0] divide_count;
|
||||
wire [2:0] division_step={remainder,divide_shift[17]};
|
||||
wire [2:0] next_remainder=division_step>=3 ? division_step-3'd3 : division_step;
|
||||
reg signed [15:0] speech_hold;
|
||||
reg signed [20:0] mix_quarters;
|
||||
reg signed [34:0] previous_input,previous_hp,rectified,operand;
|
||||
reg [34:0] envelope;
|
||||
reg [23:0] factor;
|
||||
reg signed [59:0] product;
|
||||
reg [41:0] product_low;
|
||||
reg signed [41:0] product_high;
|
||||
reg [3:0] combine_return;
|
||||
wire signed [41:0] combined_high=product_high+$signed({18'd0,product_low[41:18]});
|
||||
wire signed [39:0] scaled_product=product>>>24;
|
||||
wire signed [39:0] envelope_next=$signed({1'b0,envelope})+scaled_product;
|
||||
wire signed [34:0] current_input=$signed({3'd0,ay_average,16'd0});
|
||||
wire signed [20:0] speech_extended={{5{speech_hold[15]}},speech_hold};
|
||||
always @(posedge clk)begin
|
||||
if(reset)begin
|
||||
state<=IDLE;ay_average<=0;speech_hold<=0;mix_quarters<=0;
|
||||
divide_shift<=0;quotient<=0;remainder<=0;divide_count<=0;
|
||||
previous_input<=0;previous_hp<=0;rectified<=0;operand<=0;envelope<=0;
|
||||
factor<=0;product<=0;product_low<=0;product_high<=0;combine_return<=IDLE;
|
||||
mixed_sample<=0;sample_valid<=0;activity<=0;overrun<=0;
|
||||
end else begin
|
||||
sample_valid<=0;
|
||||
if(audio_ce&&busy)overrun<=1;
|
||||
case(state)
|
||||
IDLE:if(audio_ce)begin
|
||||
divide_shift<=ay_sum;quotient<=0;remainder<=0;divide_count<=18;
|
||||
speech_hold<=speech_sample;state<=AVERAGE;
|
||||
end
|
||||
AVERAGE:begin
|
||||
remainder<=next_remainder[1:0];
|
||||
quotient<={quotient[16:0],division_step>=3};divide_shift<=divide_shift<<1;
|
||||
divide_count<=divide_count-5'd1;
|
||||
if(divide_count==1)begin ay_average<={quotient[14:0],division_step>=3};state<=MIX;end
|
||||
end
|
||||
MIX:begin
|
||||
mix_quarters<=$signed({2'd0,ay_average,3'd0})+(speech_extended<<<3)-speech_extended;
|
||||
state<=HP_PREP;
|
||||
end
|
||||
HP_PREP:begin
|
||||
operand<=previous_hp+current_input-previous_input;factor<=24'd16609444;
|
||||
state<=HP_MULT;
|
||||
end
|
||||
HP_MULT,ENV_MULT:begin
|
||||
product_low<=operand[17:0]*factor;
|
||||
product_high<=$signed(operand[34:18])*$signed({1'b0,factor});
|
||||
combine_return<=state==HP_MULT?HP_STORE:ENV_STORE;state<=MULT_COMBINE;
|
||||
end
|
||||
MULT_COMBINE:begin product<={combined_high,product_low[17:0]};state<=combine_return;end
|
||||
HP_STORE:begin
|
||||
previous_input<=current_input;previous_hp<=scaled_product[34:0];
|
||||
rectified<=scaled_product[39]?-scaled_product[34:0]:scaled_product[34:0];state<=ENV_PREP;
|
||||
end
|
||||
ENV_PREP:begin
|
||||
operand<=rectified-$signed(envelope);
|
||||
factor<=rectified>$signed(envelope)?24'd43621:24'd5033;state<=ENV_MULT;
|
||||
end
|
||||
ENV_STORE:begin
|
||||
envelope<=envelope_next[34:0];
|
||||
if(activity&&envelope_next<40'sd21474836)activity<=0;
|
||||
else if(!activity&&envelope_next>40'sd107374182)activity<=1;
|
||||
if(mix_quarters>21'sd131068)mixed_sample<=16'sd32767;
|
||||
else if(mix_quarters< -21'sd131072)mixed_sample<=16'sh8000;
|
||||
else mixed_sample<=mix_quarters[17:2];
|
||||
sample_valid<=1;state<=IDLE;
|
||||
end
|
||||
default:state<=IDLE;
|
||||
endcase
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
Reference in new issue
Block a user