Add Verilator simulation (ImGui + headless)

verilator/ runs the core on the host with the shared FM-7 / Apple-IIgs sim
framework: windowed (ImGui/SDL2) or --headless, typing on a frame schedule,
screenshots, text-screen dump, 6809 disassembly trace, floppy/SDC/cart/cassette,
and RS-232 Pak serial debugging (TXD decoder, RXD driver, pty bridge, ACIA
trace) with a minimal DriveWire server and a script to run the real FujiNet
daemon against the sim. See verilator/README.md.

- The VHDL the build uses (ROMs, RAMs, font) is converted to Verilog in
  verilator/rtl/; the VHDL CPU is not instantiated (CoCo3_CYC_ACC_6809).
- sdram2.sv is simulated with its own controller logic and an SDR chip model.
- run_tests.sh: boot, keyboard, disk, WIDTH 80 and HSCREEN tests, judged on
  the text screen and byte-for-byte against test-ref/ screenshots.

rtl/wd1793.sv: spt_addr and buff_wr are declared at module scope instead of
inside generate blocks. They are assigned outside those blocks; Quartus
accepted it, Verilator rejected spt_addr and silently split buff_wr into a
separate net. No change on the FPGA (FM-7 made the same fix).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Alan SterembergandClaude Opus 5.5 committed 2026-10-02 07:15:44 -04:00
1 parent aae1ceabf1
commit 874f4f3083
79 files changed
+81058 -2

No files matched your search

+102
View File
@@ -0,0 +1,102 @@
//============================================================================
// Verilog conversions of the CoCo3 ROM entities in rtl/rom/*.vhd.
//
// Line-for-line translations: same entity names, same ports, same clocking.
// The three loadable ROMs are single-clock RAMs filled over ioctl; while a
// write is in progress the read register holds its previous value, exactly as
// the VHDL `if WRITE = '1' ... else DATA <= ...` does.
//============================================================================
// rtl/rom/coco_rom_32K.vhd -- CoCo3 system ROM (boot0.rom, ioctl index 0)
module COCO_ROM_32K
(
input [14:0] ADDR,
output reg [7:0] DATA,
input CLK,
input [14:0] WR_ADDR,
input [7:0] WR_DATA,
input WRITE
);
reg [7:0] ROM [0:32767];
always @(posedge CLK) begin
if (WRITE) ROM[WR_ADDR] <= WR_DATA;
else DATA <= ROM[ADDR];
end
endmodule
// rtl/rom/coco_rom_8K.vhd -- Disk BASIC ROM (boot1.rom, ioctl index 64)
module COCO_ROM_8K
(
input [12:0] ADDR,
output reg [7:0] DATA,
input CLK,
input [12:0] WR_ADDR,
input [7:0] WR_DATA,
input WRITE
);
reg [7:0] ROM [0:8191];
always @(posedge CLK) begin
if (WRITE) ROM[WR_ADDR] <= WR_DATA;
else DATA <= ROM[ADDR];
end
endmodule
// rtl/rom/coco_rom_cart.vhd -- Program Pak, up to 128K (ioctl index 1)
module COCO_ROM_CART
(
input [16:0] ADDR,
output reg [7:0] DATA,
input CLK,
input [16:0] WR_ADDR,
input [7:0] WR_DATA,
input WRITE
);
reg [7:0] ROM [0:131071];
always @(posedge CLK) begin
if (WRITE) ROM[WR_ADDR] <= WR_DATA;
else DATA <= ROM[ADDR];
end
endmodule
// rtl/rom/coco_rom_16.vhd -- the AMW (automatic memory write) script: three
// {valid, a24..a0, data} records followed by a terminator. Asynchronous.
module COCO_ROM_16
(
input [3:0] ADDR,
output reg [7:0] DATA
);
always @(*) begin
case (ADDR)
// Clear $71 [Warm Start Flag]
4'd0: DATA = 8'h80; 4'd1: DATA = 8'h07; 4'd2: DATA = 8'h00;
4'd3: DATA = 8'h71; 4'd4: DATA = 8'h00;
// Set $C000 <- $55 [Clear D in DK identifier in rom]
4'd5: DATA = 8'h80; 4'd6: DATA = 8'h07; 4'd7: DATA = 8'hC0;
4'd8: DATA = 8'h00; 4'd9: DATA = 8'h55;
// Clear $72 [Warm Start Jump]
4'd10: DATA = 8'h80; 4'd11: DATA = 8'h07; 4'd12: DATA = 8'h00;
4'd13: DATA = 8'h72; 4'd14: DATA = 8'h00;
// terminator
default: DATA = 8'h00;
endcase
end
endmodule
// rtl/rom/coco3_char_rom.vhd -- 4K font RAM, preloaded with the CoCo3 font
// (verilator/rtl/coco3_char_rom.mem, extracted from the VHDL by gen_mem.py).
// Separate write and registered-read clocks, as in the VHDL.
module coco3_Char_ROM
(
input RD_CLK,
input [11:0] ADDR_R,
output reg [7:0] DATA_R,
input WR_CLK,
input WE,
input [11:0] ADDR_W,
input [7:0] DATA_W
);
reg [7:0] RAM [0:4095];
initial $readmemh("rtl/coco3_char_rom.mem", RAM);
always @(posedge WR_CLK) if (WE) RAM[ADDR_W] <= DATA_W;
always @(posedge RD_CLK) DATA_R <= RAM[ADDR_R];
endmodule