Skip to content

Commit

Permalink
disable namco 106 mapper for now; update hdmi stack; fix tcl build sc…
Browse files Browse the repository at this point in the history
…ript
  • Loading branch information
nand2mario committed Mar 26, 2024
1 parent 9647ad3 commit 0761327
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 833 deletions.
2 changes: 2 additions & 0 deletions build.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ add_file -type verilog "src/sdram.v"
add_file -type verilog "src/uart_tx_V2.v"
add_file -type verilog "src/usb_hid_host.v"
add_file -type verilog "src/usb_hid_host_rom.v"
add_file -type verilog "src/NESGamepad.v"
add_file -type verilog "src/mapLoopy.v"

if {$dev eq "nano20k"} {
set_device GW2AR-LV18QN88C8/I7 -device_version C
Expand Down
4 changes: 2 additions & 2 deletions nestang_nano20k.gprj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<Version>5</Version>
<Device name="GW2AR-18C" pn="GW2AR-LV18QN88C8/I7">gw2ar18c-000</Device>
<FileList>
<File path="src/tang_nano_20k/config.sv" type="file.verilog" enable="1"/>
<File path="src/NESgamepad/NESGamepad.v" type="file.verilog" enable="1"/>
<File path="src/MicroCode.v" type="file.verilog" enable="1"/>
<File path="src/NESGamepad.v" type="file.verilog" enable="1"/>
<File path="src/apu.v" type="file.verilog" enable="1"/>
<File path="src/autofire.v" type="file.verilog" enable="1"/>
<File path="src/compat.v" type="file.verilog" enable="1"/>
Expand Down Expand Up @@ -39,6 +38,7 @@
<File path="src/sd_reader.sv" type="file.verilog" enable="1"/>
<File path="src/sdcmd_ctrl.sv" type="file.verilog" enable="1"/>
<File path="src/sdram.v" type="file.verilog" enable="1"/>
<File path="src/tang_nano_20k/config.sv" type="file.verilog" enable="1"/>
<File path="src/tang_nano_20k/gowin_pll_hdmi.v" type="file.verilog" enable="1"/>
<File path="src/tang_nano_20k/gowin_pll_usb.v" type="file.verilog" enable="1"/>
<File path="src/uart_tx_V2.v" type="file.verilog" enable="1"/>
Expand Down
4 changes: 2 additions & 2 deletions nestang_primer25k.gprj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<Version>5</Version>
<Device name="GW5A-25A" pn="GW5A-LV25MG121NC1/I0">gw5a25a-002</Device>
<FileList>
<File path="src/tang_primer_25k/config.sv" type="file.verilog" enable="1"/>
<File path="src/NESgamepad/NESGamepad.v" type="file.verilog" enable="1"/>
<File path="src/MicroCode.v" type="file.verilog" enable="1"/>
<File path="src/NESGamepad.v" type="file.verilog" enable="1"/>
<File path="src/apu.v" type="file.verilog" enable="1"/>
<File path="src/autofire.v" type="file.verilog" enable="1"/>
<File path="src/compat.v" type="file.verilog" enable="1"/>
Expand Down Expand Up @@ -39,6 +38,7 @@
<File path="src/sd_reader.sv" type="file.verilog" enable="1"/>
<File path="src/sdcmd_ctrl.sv" type="file.verilog" enable="1"/>
<File path="src/sdram.v" type="file.verilog" enable="1"/>
<File path="src/tang_primer_25k/config.sv" type="file.verilog" enable="1"/>
<File path="src/tang_primer_25k/gowin_pll_27.v" type="file.verilog" enable="1"/>
<File path="src/tang_primer_25k/gowin_pll_hdmi.v" type="file.verilog" enable="1"/>
<File path="src/tang_primer_25k/gowin_pll_usb.v" type="file.verilog" enable="1"/>
Expand Down
File renamed without changes.
36 changes: 0 additions & 36 deletions src/NESgamepad/CHANGELOG.md

This file was deleted.

19 changes: 0 additions & 19 deletions src/NESgamepad/NESGamepad.sby

This file was deleted.

3 changes: 0 additions & 3 deletions src/NESgamepad/build_verilator.sh

This file was deleted.

136 changes: 0 additions & 136 deletions src/NESgamepad/obj_dir/NESGamepad.cpp

This file was deleted.

Binary file removed src/NESgamepad/signals/000_8BitDo_isPressed_none.JPG
Binary file not shown.
Binary file removed src/NESgamepad/signals/001_8BitDo_isPressed_A.JPG
Binary file not shown.
Binary file removed src/NESgamepad/signals/002_8BitDo_isPressed_B.JPG
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed src/NESgamepad/signals/005_8BitDo_isPressed_Up.JPG
Binary file not shown.
Binary file removed src/NESgamepad/signals/006_8BitDo_isPressed_Down.JPG
Binary file not shown.
Binary file removed src/NESgamepad/signals/007_8BitDo_isPressed_Left.JPG
Binary file not shown.
Binary file not shown.
22 changes: 14 additions & 8 deletions src/hdmi2/audio_clock_regeneration_packet.sv
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,27 @@ module audio_clock_regeneration_packet
);

// See Section 7.2.3, values derived from "Other" row in Tables 7-1, 7-2, 7-3.
localparam bit [19:0] N = AUDIO_RATE % 125 == 0 ? 20'(16 * AUDIO_RATE / 125) : AUDIO_RATE % 225 == 0 ? 20'(196 * AUDIO_RATE / 225) : 20'(AUDIO_RATE * 16 / 125);
localparam bit [19:0] N = AUDIO_RATE % 125 == 0 ? 20'(16 * AUDIO_RATE / 125) : AUDIO_RATE % 225 == 0 ? 20'(32 * AUDIO_RATE / 225) : 20'(AUDIO_RATE * 16 / 125);

localparam int CLK_AUDIO_COUNTER_WIDTH = $clog2(N / 128);
localparam bit [CLK_AUDIO_COUNTER_WIDTH-1:0] CLK_AUDIO_COUNTER_END = CLK_AUDIO_COUNTER_WIDTH'(N / 128 - 1);
logic [CLK_AUDIO_COUNTER_WIDTH-1:0] clk_audio_counter = CLK_AUDIO_COUNTER_WIDTH'(0);
logic internal_clk_audio_counter_wrap = 1'd0;
always_ff @(posedge clk_audio)

logic clk_audio_old;
// always_ff @(posedge clk_audio)
always_ff @(posedge clk_pixel)
begin
if (clk_audio_counter == CLK_AUDIO_COUNTER_END)
begin
clk_audio_counter <= CLK_AUDIO_COUNTER_WIDTH'(0);
internal_clk_audio_counter_wrap <= !internal_clk_audio_counter_wrap;
clk_audio_old <= clk_audio;
if (clk_audio & ~clk_audio_old) begin
if (clk_audio_counter == CLK_AUDIO_COUNTER_END)
begin
clk_audio_counter <= CLK_AUDIO_COUNTER_WIDTH'(0);
internal_clk_audio_counter_wrap <= !internal_clk_audio_counter_wrap;
end
else
clk_audio_counter <= clk_audio_counter + 1'd1;
end
else
clk_audio_counter <= clk_audio_counter + 1'd1;
end

logic [1:0] clk_audio_counter_wrap_synchronizer_chain = 2'd0;
Expand Down
21 changes: 12 additions & 9 deletions src/hdmi2/hdmi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ always_comb begin
hsync <= invert ^ (cx >= screen_width + hsync_pulse_start && cx < screen_width + hsync_pulse_start + hsync_pulse_size);
// vsync pulses should begin and end at the start of hsync, so special
// handling is required for the lines on which vsync starts and ends
if (cy == screen_height + vsync_pulse_start)
if (cy == screen_height + vsync_pulse_start - 1)
vsync <= invert ^ (cx >= screen_width + hsync_pulse_start);
else if (cy == screen_height + vsync_pulse_start + vsync_pulse_size)
else if (cy == screen_height + vsync_pulse_start + vsync_pulse_size - 1)
vsync <= invert ^ (cx < screen_width + hsync_pulse_start);
else
vsync <= invert ^ (cy >= screen_height + vsync_pulse_start && cy < screen_height + vsync_pulse_start + vsync_pulse_size);
Expand Down Expand Up @@ -254,8 +254,8 @@ generate
end
else
begin
video_guard <= cx >= frame_width - 2 && cx < frame_width && (cy == frame_height - 1 || cy < screen_height);
video_preamble <= cx >= frame_width - 10 && cx < frame_width - 2 && (cy == frame_height - 1 || cy < screen_height);
video_guard <= cx >= frame_width - 2 && cx < frame_width && (cy == frame_height - 1 || cy < screen_height - 1 /* no VG at end of last line */);
video_preamble <= cx >= frame_width - 10 && cx < frame_width - 2 && (cy == frame_height - 1 || cy < screen_height - 1 /* no VP at end of last line */);
end
end

Expand All @@ -264,17 +264,17 @@ generate
logic [4:0] num_packets_alongside;
always_comb
begin
max_num_packets_alongside = ((frame_width - screen_width) /* VD period */ - 2 /* V guard */ - 8 /* V preamble */ - 12 /* 12px control period */ - 2 /* DI guard */ - 2 /* DI start guard */ - 8 /* DI premable */) / 32;
max_num_packets_alongside = (frame_width - screen_width /* VD period */ - 2 /* V guard */ - 8 /* V preamble */ - 4 /* Min V control period */ - 2 /* DI trailing guard */ - 2 /* DI leading guard */ - 8 /* DI premable */ - 4 /* Min DI control period */) / 32;
if (max_num_packets_alongside > 18)
num_packets_alongside = 5'd18;
else
num_packets_alongside = 5'(max_num_packets_alongside);
end

logic data_island_period_instantaneous;
assign data_island_period_instantaneous = num_packets_alongside > 0 && cx >= screen_width + 10 && cx < screen_width + 10 + num_packets_alongside * 32;
assign data_island_period_instantaneous = num_packets_alongside > 0 && cx >= screen_width + 14 && cx < screen_width + 14 + num_packets_alongside * 32;
logic packet_enable;
assign packet_enable = data_island_period_instantaneous && 5'(cx + screen_width + 22) == 5'd0;
assign packet_enable = data_island_period_instantaneous && 5'(cx + screen_width + 18) == 5'd0;

logic data_island_guard = 0;
logic data_island_preamble = 0;
Expand All @@ -289,8 +289,11 @@ generate
end
else
begin
data_island_guard <= num_packets_alongside > 0 && ((cx >= screen_width + 8 && cx < screen_width + 10) || (cx >= screen_width + 10 + num_packets_alongside * 32 && cx < screen_width + 10 + num_packets_alongside * 32 + 2));
data_island_preamble <= num_packets_alongside > 0 && cx >= screen_width && cx < screen_width + 8;
data_island_guard <= num_packets_alongside > 0 && (
(cx >= screen_width + 12 && cx < screen_width + 14) /* leading guard */ ||
(cx >= screen_width + 14 + num_packets_alongside * 32 && cx < screen_width + 14 + num_packets_alongside * 32 + 2) /* trailing guard */
);
data_island_preamble <= num_packets_alongside > 0 && cx >= screen_width + 4 && cx < screen_width + 12;
data_island_period <= data_island_period_instantaneous;
end
end
Expand Down
10 changes: 7 additions & 3 deletions src/hdmi2/packet_picker.sv
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ localparam bit WORD_LENGTH_LIMIT = AUDIO_BIT_WIDTH <= 20 ? 1'b0 : 1'b1;

logic [AUDIO_BIT_WIDTH-1:0] audio_sample_word_transfer [1:0];
logic audio_sample_word_transfer_control = 1'd0;
always_ff @(posedge clk_audio)
logic clk_audio_old;
always_ff @(posedge clk_pixel)
begin
audio_sample_word_transfer <= audio_sample_word;
audio_sample_word_transfer_control <= !audio_sample_word_transfer_control;
clk_audio_old <= clk_audio;
if (clk_audio & ~clk_audio_old) begin
audio_sample_word_transfer <= audio_sample_word;
audio_sample_word_transfer_control <= !audio_sample_word_transfer_control;
end
end

logic [1:0] audio_sample_word_transfer_control_synchronizer_chain = 2'd0;
Expand Down
2 changes: 2 additions & 0 deletions src/hdmi2/serializer.sv
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
`define GW_IDE

module serializer
#(
parameter int NUM_CHANNELS = 3,
Expand Down
Loading

0 comments on commit 0761327

Please sign in to comment.