From 5e1b2e4c339527e21411b56e269e1222764ec759 Mon Sep 17 00:00:00 2001 From: shodge12 <44378937+shodge12@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:22:47 -0500 Subject: [PATCH] FujiNet Update. Added slot1 transmit of $FF upon Cold Boot to Fujinet daemon. Fixed set / clear of CoCo3 SAM registers to work with both reads and writes. --- changes.txt | 26 ++++++- files.qip | 1 + rtl/UIM.v | 196 +++++++++++++++++++++++++++++++++++++++++++++++ rtl/coco3fpga.sv | 193 ++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 387 insertions(+), 29 deletions(-) create mode 100644 rtl/UIM.v diff --git a/changes.txt b/changes.txt index c5665e2..bcb021b 100644 --- a/changes.txt +++ b/changes.txt @@ -6,12 +6,30 @@ [done] 4. Routing RS-232 tx/rx lines to the SNAC port for initial serial debugging of Fuji-Net interface. [done - untested] - +5. Added Fujinet support. + a) Install Fujinet [seperate instruction document] + a) Slot 1 is now Fujunet only support. + b) You will need HDBDos 'HDBDW3S3' which will be autoloaded if named + BOOT2.ROM. Tested with ver 1.5 SY6551 @ 115,200 baud. + c) In the Debug menu on the OSD 'Swap Mister Uart:' is set to RS CART. + 'SWAP Uart to IO:' is set to 'Off'. + d) In the 'System' page of the OSD, 'Uart Mode' Should be set to 'Fujinet' + and the baud rate to '115,200'. + e) In slot 1 ONLY [Fujinet], a cold boot issued through the OSD will cause + a firewire reset command [$FF] to be transmitted to the Fujinet daemon + which will cause the Fujinet Config screem to come up after boot. + f) The SD drive in Fujinet is configured to the CoCo3 games area on the MiSTer + storage location. +6. A bug was fixed in that this core did not allow SAM registers to be set / cleared + by reads. This was fixed with the side effect of preventing older OS9 disks + from booting. [OS9 L1v1.02]. In the OSD Debug Menu, 'SAM Wrt Only Ena' should + be set to 'Off' for true CoCo3 compadibility. Turn it on if your old OS9 + disks hang. + a) This fix has moved the RTC availibility to be moved to the config data. + (see manual for details) To Do... -1. Add Fuji-Net port. -2. Add Speech / Music cart -3. Fix Castle of Tharoggad +1. Fix Castle of Tharoggad diff --git a/files.qip b/files.qip index 158d7f8..5c7a18a 100644 --- a/files.qip +++ b/files.qip @@ -36,4 +36,5 @@ set_global_assignment -name VHDL_FILE rtl/rom/coco_rom_32K.vhd set_global_assignment -name VHDL_FILE rtl/rom/coco_rom_8K.vhd set_global_assignment -name VHDL_FILE rtl/rom/coco_rom_16.vhd set_global_assignment -name VHDL_FILE rtl/OVO.vhd +set_global_assignment -name VERILOG_FILE rtl/UIM.v set_global_assignment -name SDC_FILE rtl/CoCo3FPGA.sdc diff --git a/rtl/UIM.v b/rtl/UIM.v new file mode 100644 index 0000000..7c70865 --- /dev/null +++ b/rtl/UIM.v @@ -0,0 +1,196 @@ +//////////////////////////////////////////////////////////////////////////////// +// Project Name: CoCo3FPGA Version 5.0 +// File Name: UIM.v +// +// CoCo3 in an FPGA +// +//////////////////////////////////////////////////////////////////////////////// +// +//////////////////////////////////////////////////////////////////////////////// +// +// Color Computer 3 compatible system on a chip +// +// +// Copyright (c) 2008 Gary Becker (gary_l_becker@yahoo.com) +// +// All rights reserved +// +// Redistribution and use in source and synthezised forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// Redistributions in synthesized form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// Neither the name of the author nor the names of other contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Please report bugs to the author, but before you do so, please +// make sure that this is not a derivative work and that +// you have the latest version of this file. +// +// +//////////////////////////////////////////////////////////////////////////////// +// Stan Hodge +// +// UART Injection Module by Stan Hodge 11/8/26 +// +// This module uses the AMW_END chain to cause a $FF to be written to the 6551 +// uart, then delay until that transmission has been made, then pass on the AMW_END. +// This only occurs in slot 1. In other slots, AMW_END_OUT = AMW_END_IN. +// +//////////////////////////////////////////////////////////////////////////////// + + +module UIM( +input CLK, +input RESET_N, + +input [1:0] MPI_SCS, +input PH_2, + +input AMW_END_IN, +input ENABLE_IN, +input RW_N_IN, + +input [1:0] ADDRESS_IN, +input [7:0] DATA_IN, + + +output AMW_END_OUT, +output ENABLE_OUT, +output RW_N_OUT, + +output [1:0] ADDRESS_OUT, +output [7:0] DATA_OUT + +); + +//////////////////////////////////////////////////////////// + + +localparam UIM_START = 3'd0; +localparam UIM_F1 = 3'd1; +localparam UIM_F2 = 3'd2; +localparam UIM_F3 = 3'd3; +localparam UIM_F4 = 3'd4; +localparam UIM_F5 = 3'd5; +localparam UIM_F6 = 3'd6; +localparam UIM_ST_END = 3'd7; + +reg [2:0] state; +reg mux,rw,ena,timer_ena, AMW_END_OUT_ST; +reg [13:0] timer; + +assign ADDRESS_OUT = (mux == 1'b0) ? ADDRESS_IN: + 2'b00; + +assign DATA_OUT = (mux == 1'b0) ? DATA_IN: + 8'b11111111; + +assign RW_N_OUT = (mux == 1'b0) ? RW_N_IN: + rw; + +assign ENABLE_OUT = (mux == 1'b0) ? ENABLE_IN: + ena; + +assign AMW_END_OUT = (MPI_SCS == 2'b00) ? AMW_END_OUT_ST: + AMW_END_IN; + +always @(negedge CLK or negedge RESET_N) +begin + if(!RESET_N) + begin + state <= UIM_START; + mux <= 1'b0; + rw <= 1'b1; + ena <= 1'b0; + timer <= 14'b00000000000000; + timer_ena <=1'b0; + AMW_END_OUT_ST <= 1'b0; + end + else + begin + + if (timer_ena == 1'b1) + timer <= timer + 1'b1; + + case(state) + + UIM_START: + begin + if ((MPI_SCS == 2'b00) && (AMW_END_IN == 1'b1)) + state <= UIM_F1; + end + + UIM_F1: + begin + mux <= 1'b1; + state <= UIM_F2; + end + + UIM_F2: + begin + ena <= 1'b1; + state <= UIM_F3; + end + + UIM_F3: + begin + rw <= 1'b0; + state <= UIM_F4; + end + + UIM_F4: + begin + if (PH_2) + begin + rw <= 1'b1; + state <= UIM_F5; + end + end + + UIM_F5: + begin + ena <= 1'b0; + state <= UIM_F6; + end + + UIM_F6: + begin + mux <= 1'b0; + timer_ena <= 1'b1; + state <= UIM_ST_END; + end + + UIM_ST_END: + begin + if (timer[13] == 1'b1) + begin + AMW_END_OUT_ST <= 1'b1; + timer_ena <= 1'b0; + end + end + + default:; + endcase + end +end + +endmodule diff --git a/rtl/coco3fpga.sv b/rtl/coco3fpga.sv index 38feb93..b6434ad 100644 --- a/rtl/coco3fpga.sv +++ b/rtl/coco3fpga.sv @@ -106,7 +106,7 @@ input ps2_data, input [24:0] ps2_mouse, -input Display_Debug, +input SAM_WO, // RS-232 output UART_TXD, @@ -698,6 +698,7 @@ assign BUTTON_N[3:0] = {COCO_RESET_N, 2'b1,EE_N}; wire UART_TXD_I; wire UART_RXD_I; + assign UART_TXD = SWITCH[4]? coco_rs232_out: UART_TXD_I; @@ -1024,7 +1025,7 @@ always @(negedge clk_sys or negedge RESET_N) begin if(!RESET_N) begin - Build_Info_Count <= 4'b0000; + Build_Info_Count <= 5'b00000; Build_Info <= 8'h00; Build_Info_Read <= 1'b0; Build_Info_Read_Delay <= 1'b0; @@ -1070,6 +1071,25 @@ begin 4'd13: Build_Info <= (Version_Lo + BOARD_TYPE); +// RTC Moved here so not to collide with SAM reads + + 4'd14: + Build_Info <= {3'b000, CENT}; + 4'd15: + Build_Info <= {1'b0, YEAR}; + 4'd16: + Build_Info <= {4'b0000, MNTH}; + 4'd17: + Build_Info <= {3'b000, DMTH}; + 4'd18: + Build_Info <= {5'b00000, DWK}; + 4'd19: + Build_Info <= {3'b000, HOUR}; + 4'd20: + Build_Info <= {2'b00, MIN}; + 4'd21: + Build_Info <= {2'b00, SEC}; + default: Build_Info <= 8'h00; endcase @@ -1171,16 +1191,6 @@ assign DATA_IN = (ADDRESS == 16'hFFBD) ? {2'b00, PALETTE[13][5:0]}: (ADDRESS == 16'hFFBE) ? {2'b00, PALETTE[14][5:0]}: (ADDRESS == 16'hFFBF) ? {2'b00, PALETTE[15][5:0]}: - (ADDRESS == 16'hFFC0) ? {3'b000, CENT}: - (ADDRESS == 16'hFFC1) ? {1'b0, YEAR}: - (ADDRESS == 16'hFFC2) ? {4'h0, MNTH}: - (ADDRESS == 16'hFFC3) ? {3'b000, DMTH}: - (ADDRESS == 16'hFFC4) ? {5'b00000, DWK}: - (ADDRESS == 16'hFFC5) ? {3'b000, HOUR}: - (ADDRESS == 16'hFFC6) ? {2'b00, MIN}: - (ADDRESS == 16'hFFC7) ? {2'b00, SEC}: - - (ADDRESS == 16'hFFD9) ? {5'h00, RATE_PGM}: (ADDRESS == 16'hFFEF) ? Build_Info: 8'hAA; @@ -1225,7 +1235,7 @@ wire AMW_EN; wire AMW_Ready; wire AMW_End; -assign AMW_ACK = AMW_End; +//assign AMW_ACK = AMW_End; AMW coco_AMW ( .CLK(clk_sys), @@ -3553,19 +3563,125 @@ begin end else begin - if(ADDRESS == 16'hFFE8) +// Register reads + if (~SAM_WO) + begin + case (ADDRESS) + 16'hFFC0: + begin + V[0] <= 1'b0; + end + 16'hFFC1: + begin + V[0] <= 1'b1; + end + 16'hFFC2: + begin + V[1] <= 1'b0; + end + 16'hFFC3: + begin + V[1] <= 1'b1; + end + 16'hFFC4: + begin + V[2] <= 1'b0; + end + 16'hFFC5: + begin + V[2] <= 1'b1; + end + 16'hFFC6: + begin + VERT[0] <= 1'b0; + end + 16'hFFC7: + begin + VERT[0] <= 1'b1; + end + 16'hFFC8: + begin + VERT[1] <= 1'b0; + end + 16'hFFC9: + begin + VERT[1] <= 1'b1; + end + 16'hFFCA: + begin + VERT[2] <= 1'b0; + end + 16'hFFCB: + begin + VERT[2] <= 1'b1; + end + 16'hFFCC: + begin + VERT[3] <= 1'b0; + end + 16'hFFCD: + begin + VERT[3] <= 1'b1; + end + 16'hFFCE: + begin + VERT[4] <= 1'b0; + end + 16'hFFCF: + begin + VERT[4] <= 1'b1; + end + 16'hFFD0: + begin + VERT[5] <= 1'b0; + end + 16'hFFD1: + begin + VERT[5] <= 1'b1; + end + 16'hFFD2: + begin + VERT[6] <= 1'b0; + end + 16'hFFD3: + begin + VERT[6] <= 1'b1; + end + 16'hFFD8: + begin + RATE <= 1'b0; + RATE_PGM <= 3'b010; + end + 16'hFFD9: + begin + RATE <= 1'b1; + RATE_PGM <= 3'b010; // Normal Turbo + end + 16'hFFDE: + begin + RAM <= 1'b0; + end + 16'hFFDF: + begin + RAM <= 1'b1; + end + endcase + end + + case (ADDRESS) + + 16'hFFE8: begin if(GART_INC[1]) GART_READ <= GART_READ + 1'b1; end - else + + 16'hFFE9: begin - if(ADDRESS == 16'hFFE9) - begin - if(GART_INC[1]) - GART_READ <= GART_READ + 1'b1; - end + if(GART_INC[1]) + GART_READ <= GART_READ + 1'b1; end + endcase end end end @@ -4240,6 +4356,33 @@ begin end +UIM UIM_COCO3( + .CLK(clk_sys), + .RESET_N(RESET_N), + + .MPI_SCS(MPI_SCS), + .PH_2(PH_2), + + .AMW_END_IN(AMW_End), + .ENABLE_IN(RS232_EN), + .RW_N_IN(RW_N), + + .ADDRESS_IN(ADDRESS[1:0]), + .DATA_IN(DATA_OUT), + + .AMW_END_OUT(AMW_ACK), + .ENABLE_OUT(RS232_EN_ST), + .RW_N_OUT(RW_N_ST), + + .ADDRESS_OUT(ADDRESS_ST), + .DATA_OUT(DATA_OUT_ST) +); + +wire RS232_EN_ST; +wire RW_N_ST; +wire [1:0] ADDRESS_ST; +wire [7:0] DATA_OUT_ST; + // RS232PAK UART glb6551 RS232( .RESET_N(RESET_N), @@ -4248,12 +4391,12 @@ glb6551 RS232( .RX_CLK_IN(CLK_6551_EN), // These are now enables .XTAL_CLK_IN(CLK_6551_EN), .PH_2(PH_2), -.DI(DATA_OUT), +.DI(DATA_OUT_ST), .DO(DATA_RS232), .IRQ(SER_IRQ), -.CS({1'b0, RS232_EN}), -.RW_N(RW_N), -.RS(ADDRESS[1:0]), +.CS({1'b0, RS232_EN_ST}), +.RW_N(RW_N_ST), +.RS(ADDRESS_ST[1:0]), .TXDATA_OUT(UART_TXD_I), .RXDATA_IN(UART_RXD_I), .RTS(UART_RTS), @@ -4320,7 +4463,7 @@ ovo #(.COLS(32), .LINES(23)) NOROMOVO .i_Hcount({1'b0, PIXEL_COUNT[10:1]}), .i_VCount(LINE), .o_r(CN_R), - .ena(Display_Debug || ((!rom_loaded) && SEC[0])), + .ena((!rom_loaded) && SEC[0]), .in0(NOrom1), .in1(NOrom2) );