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.
133 lines
6.2 KiB
Systemverilog
133 lines
6.2 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
|
|
// PIC7040 peripherals. VCCPlus/MAME hap, Tim Lindner; notices in LICENSE.
|
|
// TI SPND001A sections 2.2,2.5,2.6 govern DDR updates, latched/level IRQs,
|
|
// and immediate automatic timer reload, where the software reference differs.
|
|
// icount_tick is one phi clock (PIC input clock /2), NOT one fabric clock.
|
|
// GPIO uses captured held requests. Input/high-impedance output bits are zero
|
|
// on this digital glue interface; this does not model external pull resistors.
|
|
module ssc_tms7000_io(input wire clk,reset,soft_reset,
|
|
output reg initialized,
|
|
input wire request,write,input wire [7:0] address,write_data,
|
|
output reg ready,output reg [7:0] read_data,
|
|
input wire icount_tick,irq1,irq3,timer_external,
|
|
input wire irq_ack,input wire [1:0] irq_ack_index,
|
|
output wire irq_valid,output wire [1:0] irq_index,
|
|
output reg gpio_request,gpio_write,output reg [1:0] gpio_port,
|
|
output reg [7:0] gpio_write_data,input wire gpio_ready,input wire [7:0] gpio_read_data);
|
|
localparam [3:0] RESET_BEGIN=0,RESET_C=1,RESET_D=2,RESET_END=3,IDLE=4,
|
|
EXECUTE=5,READ_GPIO=6,COMPLETE=7,WAIT_RELEASE=8,GPIO_WAIT=9,GPIO_RELEASE=10;
|
|
reg [3:0] state,continuation;
|
|
reg access_write;
|
|
reg [7:0] access_address,access_data,gpio_value;
|
|
reg [7:0] latch_b,latch_c,latch_d,ddr_c,ddr_d;
|
|
reg [2:0] irq_enable,irq_latched;
|
|
reg [1:0] mode_bits;
|
|
reg previous_irq1,previous_irq3,previous_external;
|
|
reg [7:0] timer_data,timer_control,timer_current,timer_capture;
|
|
reg [4:0] timer_prescale;
|
|
reg [2:0] timer_divider;
|
|
reg timer_running;
|
|
wire [2:0] flags=irq_latched|{irq3,1'b0,irq1};
|
|
wire [2:0] pending=flags&irq_enable;
|
|
assign irq_valid=|pending;
|
|
assign irq_index=pending[0]?2'd0:pending[1]?2'd1:2'd2;
|
|
wire timer_event=timer_running && icount_tick &&
|
|
(timer_control[6]?(timer_external && !previous_external):(timer_divider==3'd7));
|
|
wire pf_write=state==EXECUTE && access_write;
|
|
task gpio(input w,input [1:0] port,input [7:0] data,input [3:0] next);
|
|
begin gpio_request<=1;gpio_write<=w;gpio_port<=port;gpio_write_data<=data;
|
|
continuation<=next;state<=GPIO_WAIT;end
|
|
endtask
|
|
always @(posedge clk)begin
|
|
if(reset)begin
|
|
state<=RESET_BEGIN;continuation<=IDLE;initialized<=0;ready<=0;read_data<=0;
|
|
access_write<=0;access_address<=0;access_data<=0;gpio_value<=0;
|
|
gpio_request<=0;gpio_write<=0;gpio_port<=0;gpio_write_data<=0;
|
|
latch_b<=0;latch_c<=0;latch_d<=0;ddr_c<=0;ddr_d<=0;
|
|
irq_enable<=0;irq_latched<=0;mode_bits<=0;previous_irq1<=0;previous_irq3<=0;
|
|
previous_external<=0;timer_data<=0;timer_control<=0;timer_current<=0;
|
|
timer_capture<=0;timer_prescale<=0;timer_divider<=0;timer_running<=0;
|
|
end else begin
|
|
previous_irq1<=irq1;previous_irq3<=irq3;
|
|
if(icount_tick)previous_external<=timer_external;
|
|
if(irq_ack && irq_ack_index<3)irq_latched[irq_ack_index]<=0;
|
|
// Pulse latches survive deassertion; active levels remain visible after ack.
|
|
// New assertions win over software clears/ack on the same fabric edge.
|
|
if(irq1 && !previous_irq1)irq_latched[0]<=1;
|
|
if(irq3 && !previous_irq3)begin irq_latched[2]<=1;timer_capture<=timer_current;end
|
|
if(initialized && timer_running && icount_tick && !timer_control[6])
|
|
timer_divider<=timer_divider+3'd1;
|
|
if(initialized && timer_event)begin
|
|
if(timer_prescale==0)begin
|
|
timer_prescale<=timer_control[4:0];
|
|
if(timer_current==0)begin timer_current<=timer_data;irq_latched[1]<=1;end
|
|
else timer_current<=timer_current-8'd1;
|
|
end else timer_prescale<=timer_prescale-5'd1;
|
|
end
|
|
case(state)
|
|
RESET_BEGIN:begin
|
|
initialized<=0;ready<=0;irq_enable<=0;mode_bits<=0;timer_running<=0;
|
|
latch_b<=8'hff;latch_c<=8'hff;latch_d<=8'hff;ddr_c<=0;ddr_d<=0;
|
|
if(!gpio_ready)gpio(1,1,8'hff,RESET_C);
|
|
end
|
|
RESET_C:gpio(1,2,0,RESET_D);
|
|
RESET_D:gpio(1,3,0,RESET_END);
|
|
RESET_END:begin initialized<=1;state<=IDLE;end
|
|
IDLE:begin
|
|
if(soft_reset)state<=RESET_BEGIN;
|
|
else if(request)begin access_write<=write;access_address<=address;
|
|
access_data<=write_data;state<=EXECUTE;end
|
|
end
|
|
EXECUTE:begin
|
|
if(access_write)begin
|
|
case(access_address)
|
|
0:begin
|
|
irq_enable<={access_data[4],access_data[2],access_data[0]};mode_bits<=access_data[7:6];
|
|
if(access_data[1])irq_latched[0]<=irq1 && !previous_irq1;
|
|
if(access_data[3])irq_latched[1]<=initialized && timer_event && timer_prescale==0 && timer_current==0;
|
|
if(access_data[5])irq_latched[2]<=irq3 && !previous_irq3;
|
|
state<=COMPLETE;
|
|
end
|
|
2:begin timer_data<=access_data;state<=COMPLETE;end
|
|
3:begin
|
|
timer_control<=access_data;timer_running<=access_data[7];
|
|
if(access_data[7])begin timer_current<=timer_data;timer_prescale<=access_data[4:0];timer_divider<=0;end
|
|
state<=COMPLETE;
|
|
end
|
|
6:begin latch_b<=access_data;gpio(1,1,access_data,COMPLETE);end
|
|
8:begin latch_c<=access_data;gpio(1,2,access_data&ddr_c,COMPLETE);end
|
|
9:begin ddr_c<=access_data;gpio(1,2,latch_c&access_data,COMPLETE);end
|
|
10:begin latch_d<=access_data;gpio(1,3,access_data&ddr_d,COMPLETE);end
|
|
11:begin ddr_d<=access_data;gpio(1,3,latch_d&access_data,COMPLETE);end
|
|
default:state<=COMPLETE;
|
|
endcase
|
|
end else case(access_address)
|
|
0:begin read_data<={mode_bits,flags[2],irq_enable[2],flags[1],irq_enable[1],flags[0],irq_enable[0]};state<=COMPLETE;end
|
|
2:begin read_data<=timer_current;state<=COMPLETE;end
|
|
3:begin read_data<=timer_capture;state<=COMPLETE;end
|
|
4:gpio(0,0,0,READ_GPIO);
|
|
6:begin read_data<=latch_b;state<=COMPLETE;end
|
|
8:gpio(0,2,0,READ_GPIO);
|
|
9:begin read_data<=ddr_c;state<=COMPLETE;end
|
|
10:gpio(0,3,0,READ_GPIO);
|
|
11:begin read_data<=ddr_d;state<=COMPLETE;end
|
|
default:begin read_data<=0;state<=COMPLETE;end
|
|
endcase
|
|
end
|
|
READ_GPIO:begin
|
|
read_data<=(access_address==4)?gpio_value:(access_address==8)?
|
|
((gpio_value&~ddr_c)|(latch_c&ddr_c)):((gpio_value&~ddr_d)|(latch_d&ddr_d));
|
|
state<=COMPLETE;
|
|
end
|
|
COMPLETE:begin ready<=1;state<=WAIT_RELEASE;end
|
|
WAIT_RELEASE:if(!request)begin ready<=0;state<=IDLE;end
|
|
GPIO_WAIT:if(gpio_ready)begin gpio_value<=gpio_read_data;gpio_request<=0;state<=GPIO_RELEASE;end
|
|
GPIO_RELEASE:if(!gpio_ready)state<=continuation;
|
|
default:state<=RESET_BEGIN;
|
|
endcase
|
|
end
|
|
end
|
|
endmodule
|