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

58 lines
2.7 KiB
Systemverilog

`timescale 1ns/1ps
// Original Main init: reset1, FC4/5/6/9 with status polls after each transfer,
// restore saved configuration with reset1, then Main's own reset0 release.
module bh_mpi_startup_tb;
reg clk=0;always #5 clk=~clk;
reg power=1;reg [63:0] requested=0;
wire [63:0] accepted,status_in;wire status_set;
bh_mpi_config cfg(clk,power,requested,accepted,status_in,status_set);
reg pending=0;reg [63:0] pending_value;
always @(posedge clk)if(status_set)begin pending<=1;pending_value<=status_in;end
reg download=0,wr=0;reg [15:0] file_index=0;
reg [24:0] file_address=0;reg [7:0] file_data=0;
wire [7:0] flash;wire [3:0] fault;
actual_mpi_core dut(.clk_sys(clk),.SSC_POWER_RESET(power),.RESET_N(!power),
.CART_SEL(1'b1),.ROM_SEL(1'b0),.PH_2(1'b0),.RW_N(1'b1),.ADDRESS(16'hc000),
.ROM(2'b0),.SWITCH(10'd6),.DATA_OUT(8'd0),.MPI_LAYOUT(accepted[54:43]),
.MPI_BOOT_LOADING(accepted[0]),.ioctl_download(download),.ioctl_wr(wr),
.ioctl_index(file_index),.ioctl_addr(file_address),.ioctl_data(file_data),
.ext_response(1'b0),.SER_IRQ(1'b1),.AMW_Trigger(1'b0),.AMW_Ready(1'b0),
.AMW_EN(1'b0),.FLASH_DATA(flash),.MPI_ROM_FAULT(fault));
task tick;begin @(negedge clk);#1;end endtask
task host_poll;
begin
repeat(4)tick;
if(pending)begin
@(posedge clk);#1;requested=pending_value&~64'd1;pending=0;
repeat(4)tick;
end
end
endtask
task stream(input [15:0] index,input [7:0] value);
begin
@(posedge clk);#1;file_index=index;download=1;wr=1;file_address=0;file_data=value;
tick;
@(posedge clk);#1;download=0;wr=0;repeat(5)tick;
host_poll;
end
endtask
initial begin
repeat(4)tick;@(posedge clk);#1;power=0;requested=1;repeat(8)tick;
stream(4,8'h11);
if(requested[0]!==1'b1)$fatal(1,"Main status acknowledgement cleared init reset after FC4");
stream(5,8'h22);stream(6,8'ha1);stream(9,8'hd4);
if(dut.mpi_rom_valid!==4'b1001)$fatal(1,"Startup streams discarded before saved layout: valid=%b fault=%b status=%h enabled=%b",dut.mpi_rom_valid,fault,accepted,dut.mpi_rom_enabled);
// Final saved layout differs from initial defaults: FD3 and ROM4.
@(posedge clk);#1;requested=accepted;
requested[54:43]={3'd1,3'd2,3'd3,3'd6};requested[13:12]=2;
repeat(8)tick;host_poll;
if(!requested[0])$fatal(1,"Premature status acknowledgement during saved reset");
@(posedge clk);#1;requested[0]=0;repeat(10)tick;host_poll;
if(accepted[54:43]!=={3'd1,3'd2,3'd3,3'd6}||dut.mpi_rom_valid!==4'b1001||fault!==0)
$fatal(1,"Restored layout/ROMs lost or stale migration overwrote configuration");
$display("PASS actual core MPI bindings: original Main init/status polls retain FC6/FC9 through saved layout restoration");
$finish;
end
initial begin #100000;$fatal(1,"Main startup ordering watchdog");end
endmodule