diff --git a/.gitignore b/.gitignore index c143053..16e88d4 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ src/os.map src/os.noi src/os.sym .vscode/settings.json +verilator/imgui.ini diff --git a/InputTest.sv b/InputTest.sv index 4ca70c5..701b213 100644 --- a/InputTest.sv +++ b/InputTest.sv @@ -1,7 +1,23 @@ -//============================================================================ -// InputTest_MiSTer -// Copyright (c) 2021 jimmystones -//============================================================================ +/*============================================================================ + MiSTer test harness - emu module + + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ module emu ( @@ -194,7 +210,7 @@ localparam CONF_STR = { "-;", "F0,BIN,Load BIOS", "-;", - "J1,A,B,C,X,Y,Z,L,R,Select,Start;", + "J1,A,B,X,Y,L,R,Select,Start,C,Z;", "V,v",`BUILD_DATE }; @@ -204,13 +220,10 @@ wire forced_scandoubler; wire direct_video; wire ioctl_download; -wire ioctl_upload; wire ioctl_wr; wire [24:0] ioctl_addr; wire [7:0] ioctl_dout; -wire [7:0] ioctl_din; wire [7:0] ioctl_index; -wire ioctl_wait; wire [31:0] joystick_0; wire [31:0] joystick_1; @@ -255,13 +268,10 @@ hps_io #(.CONF_STR(CONF_STR)) hps_io .direct_video(direct_video), .ioctl_download(ioctl_download), - .ioctl_upload(ioctl_upload), .ioctl_wr(ioctl_wr), .ioctl_addr(ioctl_addr), .ioctl_dout(ioctl_dout), - .ioctl_din(ioctl_din), .ioctl_index(ioctl_index), - .ioctl_wait(ioctl_wait), .joystick_0(joystick_0), .joystick_1(joystick_1), diff --git a/README.MD b/README.MD index 0dd2354..f9bd754 100644 --- a/README.MD +++ b/README.MD @@ -1,4 +1,4 @@ -# InputTest_MiSTer +# MiSTer test harness ## Overview @@ -6,36 +6,38 @@ A custom mini-system running an input test utility. Shows all standard HPS sour ## Hardware -A simple bespoke (i.e. I made it up with no real plan) 8-bit system with a 40x30 character display, each character can be set to one of 256 colours. No sound capabilities. +A simple bespoke (i.e. I made it up with no real plan) 8-bit system with a 40x30 character display, each character can be set to one of 256 colours. No sound capabilities. All relevant MiSTer inputs are mapped into memory regions. ### Components - Z80 CPU (tv80 by Guy Hutchison, based on VHDL T80 core by Daniel Wallner) - - jtframe_vtimer for VGA timing (from JTFRAME by Jotego) + - jtframe_vtimer for VGA timing (from JTFRAME (https://github.com/jotego/jtframe) by Jotego) + - jtframe_cen24 for clock enables (from JTFRAME (https://github.com/jotego/jtframe) by Jotego) - 16Kb program ROM (port 1 cpu, port 2 download) - 16Kb work RAM (port 1 cpu) - 2Kb character ROM (port 1 cpu, port 2 download) - 2Kb character RAM (port 1 cpu, port 2 graphics) - 2Kb colour RAM (port 1 cpu, port 2 graphics) - - 5 Memory-mapped IO regions (all read-only). _Yes I know about MREQ but SFRs turned out to be annoying in sdcc so :)_ + - 7 Memory-mapped IO regions (all read-only). _Yes I know about MREQ but SFRs turned out to be annoying in sdcc so :)_ - Hardware state (H/V Sync, H/V Blank etc) (8 bytes) - joystick_5->0 from HPS (192 bytes) - joystick_analog_5->0 from HPS (96 bytes) - paddle_5->0 from HPS (48 bytes) - spinner_5->0 from HPS (96 bytes) + - ps2_key from HPS (11 bytes) + - ps2_mouse from HPS (48 bytes, combination of ps2_mouse and ps2_mouseext with some padding to align bytes) ### Memory Map Start|End|Length|Name ---|---|---|--- 0x0000|0x3FFF|0x4000|Program ROM 0x4000|0x47FF|0x0800|Char ROM -0x6000|0x6000|0x0001|System inputs (video timings etc) +0x6000|0x6000|0x0001|System inputs (video signals) 0x7000|0x70BF|0x00C0|Joystick inputs 0x7100|0x715F|0x0060|Analog inputs 0x7200|0x722F|0x0030|Paddle inputs 0x7300|0x735F|0x0060|Spinner inputs -0x7400|0x740B|0x000C|PS2 key -0x7500|0x7530|0x0031|PS2 mouse - +0x7400|0x740B|0x000C|PS2 keyboard input +0x7500|0x752F|0x0030|PS2 mouse input 0x8000|0x87FF|0x0800|Char RAM 0x8800|0x8FFF|0x0800|Colour RAM 0xC000|0xFFFF|0x4000|Work RAM @@ -44,15 +46,16 @@ Start|End|Length|Name /src contains a C program compiled to Z80 assembly using sdcc. It reads and displays all available input values once every vblank, and also does some other things ;) -### C source files -File|Description ----|--- -/src/sys.c|Memory maps and global declarations -/src/ui.c|Character map drawing functions -/src/os.c|Main program +All required ROMs (compiled program and default MiSTer font) are built into this core. It also supports hot loading of binary OS ROM files for easier development. -### ROMS -All required ROMs (compiled program and default MiSTer font) are built into this core. +### Building the OS + +#### Required packages +- `sdcc` +- `srecord` +#### Build steps +- Run `make` in `/src/Makefile` to create binary ROM +- Run `od -An -t x1 -v src/os.bin > rtl/rom.hex` to create hex version of ROM for Quartus build ## License This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. \ No newline at end of file diff --git a/release/InputTest_20210629.rbf b/release/InputTest_20210629.rbf new file mode 100644 index 0000000..0e097fa Binary files /dev/null and b/release/InputTest_20210629.rbf differ diff --git a/rtl/dpram.v b/rtl/dpram.v index e69d350..4a3b6c9 100644 --- a/rtl/dpram.v +++ b/rtl/dpram.v @@ -1,3 +1,24 @@ +/*============================================================================ + Generic dual-port RAM module + + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ + module dpram #( parameter address_width = 10, parameter data_width = 8, @@ -19,7 +40,7 @@ module dpram #( initial begin if (init_file>0) begin - $display("Loading rom:"); + $display("Loading dpram from file:"); $display(init_file); $readmemh(init_file, mem); end @@ -28,17 +49,6 @@ end localparam ramLength = (2**address_width); reg [data_width-1:0] mem [ramLength-1:0]; -// `ifdef SIMULATION -// integer j; -// initial -// begin -// for (j = 0; j < ramLength; j = j + 1) -// begin -// mem[j] = 0; -// end -// end -// `endif - always @(posedge clock_a) begin q_a <= mem[address_a]; if(wren_a) begin diff --git a/rtl/spram.v b/rtl/spram.v index f7cf437..9c87f20 100644 --- a/rtl/spram.v +++ b/rtl/spram.v @@ -1,3 +1,24 @@ +/*============================================================================ + Generic single-port RAM module + + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ + module spram #( parameter address_width = 10, parameter data_width = 8 @@ -12,17 +33,6 @@ module spram #( localparam ramLength = (2**address_width); reg [data_width-1:0] mem [ramLength-1:0]; -// `ifdef SIMULATION -// integer j; -// initial -// begin -// for (j = 0; j < ramLength; j = j + 1) -// begin -// mem[j] = 0; -// end -// end -// `endif - always @(posedge clock) begin q <= mem[address]; if(wren) begin diff --git a/rtl/system.v b/rtl/system.v index c8f7caf..5800e7d 100644 --- a/rtl/system.v +++ b/rtl/system.v @@ -1,4 +1,25 @@ `timescale 1ns / 1ps +/*============================================================================ + MiSTer test harness - System module + + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ + module system ( input clk_sys, input ce_pix, diff --git a/src/os.c b/src/os.c index f94c5dd..89aa625 100644 --- a/src/os.c +++ b/src/os.c @@ -1,3 +1,24 @@ +/*============================================================================ + MiSTer test harness OS - Main application + + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ + #include #include #include @@ -5,16 +26,19 @@ #include "ui.c" #include "ps2.c" -unsigned char hsync; -unsigned char hsync_last; -unsigned char vsync; -unsigned char vsync_last; +bool hsync; +bool hsync_last; +bool vsync; +bool vsync_last; +// Draw static elements for input test page void page_inputs() { clear_chars(0); page_border(0b00000111); - write_string("RLDUABCXYZLRsS", 0xFF, 7, 3); + + write_string("- MiSTer Input Tester -", 0b11100011, 8, 1); + write_string("RLDUABXYLRsSCZ", 0xFF, 7, 3); write_string("AX", 0xFF, 26, 3); write_string("AY", 0xFF, 31, 3); @@ -33,14 +57,11 @@ void page_inputs() // write_string("EXT PRS SHF SCN ASC CHR", 0xFF, 6, 18); write_string("CON", 0xFF, 2, 18); - } -char color = 0xAB; - +// Application state char state = 0; char nextstate = 0; - // state = 0 - inputtester // state = 1 - fadeout // state = 2 - fadein @@ -50,35 +71,62 @@ char nextstate = 0; // state = 7 - startattract // state = 8 - attract -char movefreqinit = 14; - -char movefreqdecfreq = 200; -char movefreqdectimer = 0; - -char movefreq = 0; -char movetimer = 0; - +// SNEK variables +unsigned char movefreqinit = 14; +unsigned char movefreqdecfreq = 200; +unsigned char movefreqdectimer = 0; +unsigned char movefreq = 0; +unsigned char movetimer = 0; signed int x = 20; signed int y = 15; - signed char xd = 0; signed char yd = 1; - signed char nxd = 0; signed char nyd = 1; unsigned int length = 0; +unsigned char playerchar = 83; -char playerchar = 83; -char fade = 0; -char fadetimer = 0; -char fadefreq = 4; +// Fade in/out variables +unsigned char fade = 0; +unsigned char fadetimer = 0; +unsigned char fadefreq = 4; +// Attract mode variables +unsigned char attractstate = 0; + +// Input tester variables +unsigned char inputindex = 0; +unsigned char con_x; // Console cursor X position +unsigned char con_y; // Console cursor X position +unsigned char con_l = 2; // Console left edge X +unsigned char con_t = 20; // Console top edge Y +unsigned char con_r = 37; // Console right edge X +unsigned char con_b = 37; // Console bottom edge Y +bool con_cursor; +unsigned char con_cursortimer = 1; +unsigned char con_cursorfreq = 30; + +// DPAD tracker +bool bdown_left = 0; +bool bdown_left_last = 0; +bool bdown_right = 0; +bool bdown_right_last = 0; +bool bdown_up = 0; +bool bdown_up_last = 0; +bool bdown_down = 0; +bool bdown_down_last = 0; +char history[4]; + +// Initialise inputtester state and draw static elements void start_inputtester() { page_inputs(); state = 1; + con_x = con_l; + con_y = con_t; } +// Initialise fadeout state void start_fadeout() { state = 2; @@ -86,6 +134,7 @@ void start_fadeout() fade = 0; } +// Initialise fadein state void start_fadein() { state = 3; @@ -93,8 +142,7 @@ void start_fadein() fade = 15; } -char attractstate = 0; - +// Initialise attract state and draw static elements void start_attract() { state = 7; @@ -106,6 +154,7 @@ void start_attract() movetimer = 1; } +// Initialise attract state and draw static elements void start_gameplay() { state = 5; @@ -126,6 +175,7 @@ void start_gameplay() movetimer = movefreq; } +// Fade out state void fadeout() { if (vsync && !vsync_last) @@ -144,6 +194,7 @@ void fadeout() } } +// Fade in state void fadein() { if (vsync && !vsync_last) @@ -162,17 +213,7 @@ void fadein() } } -char bdown_left = 0; -char bdown_left_last = 0; -char bdown_right = 0; -char bdown_right_last = 0; -char bdown_up = 0; -char bdown_up_last = 0; -char bdown_down = 0; -char bdown_down_last = 0; - -char history[4]; - +// Rotate DPAD direction history and push new entry void pushhistory(char new) { for (char h = 1; h < 4; h++) @@ -182,36 +223,24 @@ void pushhistory(char new) history[3] = new; } -char lastbufferlen = 0; -char inputindex = 0; -char fps; -char con_x; // Console cursor X position -char con_y; // Console cursor X position -char con_l = 2; // Console left edge X -char con_t = 21; // Console top edge Y -char con_r = 37; // Console right edge X -char con_b = 37; // Console bottom edge Y - +// Input tester state void inputtester() { - hsync = input0 & 0x80; - vsync = input0 & 0x40; + // Handle PS/2 inputs whenever possible to improve latency handle_ps2(); if (hsync && !hsync_last) { - + // Track input history of P1 DPAD for secret codes! bdown_up_last = bdown_up; bdown_down_last = bdown_down; bdown_left_last = bdown_left; bdown_right_last = bdown_right; - - bdown_up = joystick[0] & 0b00001000; - bdown_down = joystick[0] & 0b00000100; - bdown_left = joystick[0] & 0b00000010; - bdown_right = joystick[0] & 0b00000001; - + bdown_up = CHECK_BIT(joystick[0], 3); + bdown_down = CHECK_BIT(joystick[0], 2); + bdown_left = CHECK_BIT(joystick[0], 1); + bdown_right = CHECK_BIT(joystick[0], 0); if (!bdown_up && bdown_up_last) { pushhistory(1); @@ -232,18 +261,14 @@ void inputtester() if (vsync && !vsync_last) { + // Rotate index of inputs to show this loop inputindex++; if (inputindex == 6) { inputindex = 0; } - color++; - fps++; - write_string("- MiSTer Input Tester -", color, 8, 1); - write_stringf("%d", 0xbb, 0, 1, fps); - // char hstr[10]; - // sprintf(hstr, "%d %d %d %d", history[0], history[1], history[2], history[3]); + // Check for SNEK code if (history[0] == 4 && history[1] == 2 && history[2] == 3 && history[3] == 1) { nextstate = 6; @@ -251,9 +276,9 @@ void inputtester() start_fadeout(); return; } - // write_string(hstr, 0xFF, 6, 2); - char x = 7; + // Draw joystick inputs + char x = 6; char y = 4 + inputindex; char inputoffset = (inputindex * 32); for (char b = 0; b < 2; b++) @@ -261,92 +286,107 @@ void inputtester() char m = 0b00000001; for (char i = 0; i < 8; i++) { - //(b * 8); x++; - // for (inputindex = 0; inputindex < 6; inputindex++) - // { write_char((joystick[(b * 8) + inputoffset] & m) ? asc_1 : asc_0, 0xFF, x, y); - // } m <<= 1; } } y = 4; - // ANALOG + // Draw analog inputs char m = 0b00000001; char stra[10]; - // for (inputindex = 0; inputindex < 6; inputindex++) - // { signed char jx = analog[(inputindex * 16)]; signed char jy = analog[(inputindex * 16) + 8]; - sprintf(stra, "%4d %4d", jx, jy); write_string(stra, 0xFF, 24, y + inputindex); m <<= 1; - // } - // PADDLE + // Draw paddle inputs y = 11; m = 0b00000001; char strp[3]; - // for (inputindex = 0; inputindex < 6; inputindex++) - // { char px = paddle[(inputindex * 8)]; sprintf(strp, "%4d", px); write_string(strp, 0xFF, 6, y + inputindex); m <<= 1; - // } - // SPINNER + // Draw spinner inputs y = 11; m = 0b00000001; - // for (j = 0; j < 6; j++) - // { signed char sx = spinner[(inputindex * 16)]; write_stringf("%4d", 0xFF, 17, y + inputindex, sx); m <<= 1; - // } - - // KEYBOARD - // write_stringf("%3d", 0xFF, 6, 19, kbd_extend); - // write_stringf("%3d", 0xFF, 10, 19, kbd_pressed); - // write_stringf("%3d", 0xFF, 14, 19, kbd_shift); - // write_stringf("%3d", 0xFF, 18, 19, kbd_lastscan); - // write_stringf("%3d", 0xFF, 22, 19, kbd_lastascii); - // write_char(kbd_lastascii, 0xFF, 26, 19); + // Keyboard test console if (kbd_buffer_len > 0) { + // Clear existing cursor if visible + if (con_cursor) + { + write_char(' ', 0xFF, con_x, con_y); + } + // Write characters in buffer for (char k = 0; k < kbd_buffer_len; k++) { - write_char(kbd_buffer[k], 0xFF, con_x, con_y); - con_x++; - if (con_x > con_r) + if (kbd_buffer[k] == '\n') { + // New line con_x = con_l; con_y++; if (con_y > con_b) { + // Wrap to top con_y = con_t; } } + else if (kbd_buffer[k] == '\b') + { + // Backspace - only if not at beginning of line + if (con_x > con_l) + { + con_x--; + // Clear existing character + write_char(' ', 0xFF, con_x, con_y); + } + } + else + { + // Write character + write_char(kbd_buffer[k], 0xFF, con_x, con_y); + // Move cursor right + con_x++; + if (con_x > con_r) + { + // New line + con_x = con_l; + con_y++; + if (con_y > con_b) + { + // Wrap to top + con_y = con_t; + } + } + } } + // Clear buffer and enable cursor kbd_buffer_len = 0; + con_cursor = 0; + con_cursortimer = 1; } - // MOUSE - // write_stringf("%3d", 0xFF, 6, 23, mse_a1); - // write_stringf("%3d", 0xFF, 10, 23, mse_a2); - // write_stringf("%3d", 0xFF, 14, 23, mse_a3); - - // write_bits(ps2_mouse, 8, 0, 3, 0xFF, 6, 25); - // write_bits(ps2_mouse, 8, 3, 3, 0xFF, 6, 27); + // Cursor blink timer + con_cursortimer--; + if (con_cursortimer <= 0) + { + con_cursor = !con_cursor; + con_cursortimer = con_cursorfreq; + write_char(con_cursor ? '|' : ' ', 0xFF, con_x, con_y); + } } - - hsync_last = hsync; - vsync_last = vsync; } +// SNEK - gameplay state void gameplay() { @@ -420,6 +460,7 @@ void gameplay() } } +// SNEK - attract state void attract() { @@ -443,11 +484,10 @@ void attract() } } +// Main entry and state machine void main() { chram_size = chram_cols * chram_rows; - con_x = con_l; - con_y = con_t; while (1) { diff --git a/src/ps2.c b/src/ps2.c index 52a1ed2..1ac51eb 100644 --- a/src/ps2.c +++ b/src/ps2.c @@ -1,3 +1,24 @@ +/*============================================================================ + MiSTer test harness OS - PS/2 interface functions + + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ + #include "sys.c" // COMMAND KEYS @@ -148,12 +169,19 @@ char kbd_UK[256] = 0, 0, // 0x57 '+', '=', // 0x58 0, 0, // 0x59 (RSHIFT) - 0, 0, // 0x5a (ENTER) + '\n', '\n',// 0x5a (ENTER) '}', ']', // 0x5b 0, 0, // 0x5c '|', '\\', // 0x5d 0, 0, // 0x5e 0, 0, // 0x5f + 0, 0, // 0x60 + 0, 0, // 0x61 + 0, 0, // 0x62 + 0, 0, // 0x63 + 0, 0, // 0x64 + 0, 0, // 0x65 + '\b', '\b',// 0x66 0, 0}; char kbd_in[2]; diff --git a/src/sys.c b/src/sys.c index 8929e01..8b69dc8 100644 --- a/src/sys.c +++ b/src/sys.c @@ -1,3 +1,24 @@ +/*============================================================================ + MiSTer test harness OS - System interface functions + + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ + #pragma once #include diff --git a/src/ui.c b/src/ui.c index cccb4d4..b65189e 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1,3 +1,24 @@ +/*============================================================================ + MiSTer test harness OS - User interface functions + + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ + #pragma once #include "sys.c" diff --git a/verilator/Makefile b/verilator/Makefile index 352d8c1..c9f60e3 100644 --- a/verilator/Makefile +++ b/verilator/Makefile @@ -7,7 +7,7 @@ V = verilator #V = /usr/local/src/verilator-3.876/bin/verilator COSIM = n -TOP = --top-module top +TOP = --top-module emu RTL = ../rtl V_INC = +incdir+$(RTL) diff --git a/verilator/imgui.ini b/verilator/imgui.ini index 3bae294..ae8024e 100644 --- a/verilator/imgui.ini +++ b/verilator/imgui.ini @@ -44,8 +44,8 @@ Size=553,169 Collapsed=0 [Window][WKRAM Editor] -Pos=5,626 -Size=540,370 +Pos=5,624 +Size=549,372 Collapsed=0 [Window][CHRAM Editor] diff --git a/verilator/sim.v b/verilator/sim.v index c455d51..e3bfd11 100644 --- a/verilator/sim.v +++ b/verilator/sim.v @@ -1,9 +1,29 @@ `timescale 1ns / 1ps +/*============================================================================ + MiSTer test harness - Verilator emu module -module top( + Author: Jim Gregory - https://github.com/JimmyStones/ + Version: 0.1 + Date: 2021-06-29 - input clk_sys/*verilator public_flat*/, - input reset/*verilator public_flat*/, + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program. If not, see . +===========================================================================*/ + +module emu ( + + input clk_sys, + input reset, input [31:0] joystick_0, input [31:0] joystick_1, @@ -41,9 +61,9 @@ module top( input [24:0] ps2_mouse, input [15:0] ps2_mouse_ext, // 15:8 - reserved(additional buttons), 7:0 - wheel movements - output [7:0] VGA_R/*verilator public_flat*/, - output [7:0] VGA_G/*verilator public_flat*/, - output [7:0] VGA_B/*verilator public_flat*/, + output [7:0] VGA_R, + output [7:0] VGA_G, + output [7:0] VGA_B, output VGA_HS, output VGA_VS, diff --git a/verilator/verilate.sh b/verilator/verilate.sh index 13bd2e3..71b9fe7 100644 --- a/verilator/verilate.sh +++ b/verilator/verilate.sh @@ -1,5 +1,4 @@ -#verilator -cc -exe --public --compiler msvc --converge-limit 2000 -Wno-WIDTH -Wno-IMPLICIT -Wno-MODDUP -Wno-UNSIGNED -Wno-CASEINCOMPLETE -Wno-CASEX -Wno-SYMRSVDWORD -Wno-COMBDLY -Wno-INITIALDLY -Wno-BLKANDNBLK -Wno-UNOPTFLAT -Wno-SELRANGE -Wno-CMPCONST -Wno-CASEOVERLAP -Wno-PINMISSING --top-module top sim.v \ -verilator -cc -exe --public --compiler msvc +define+SIMULATION=1 --converge-limit 2000 --top-module top sim.v \ +verilator -cc -exe --public --compiler msvc +define+SIMULATION=1 --converge-limit 2000 --top-module emu sim.v \ ../rtl/dpram.v \ ../rtl/spram.v \ ../rtl/JTFRAME/jtframe_vtimer.v \