From a199682f6782c8508a9244161126e84b28f23bea Mon Sep 17 00:00:00 2001 From: Eugene Lozovoy Date: Wed, 19 Feb 2025 16:01:34 +0300 Subject: [PATCH] midi out is now handled on both ay chips --- rtl/sound/turbosound.sv | 41 ++++++++++++++++++++++++++++------------- rtl/tsconf.v | 20 ++++++++++++++++---- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/rtl/sound/turbosound.sv b/rtl/sound/turbosound.sv index bb191c0..e5ab3c8 100644 --- a/rtl/sound/turbosound.sv +++ b/rtl/sound/turbosound.sv @@ -34,12 +34,20 @@ module turbosound output [11:0] CHANNEL_L, // Output channel L output [11:0] CHANNEL_R, // Output channel R - input [7:0] IOA_in, - input [7:0] IOB_in, - output [7:0] IOA_out, - output [7:0] IOB_out, - output IOA_oe, - output IOB_oe + input [7:0] IOA_0_in, + input [7:0] IOB_0_in, + output [7:0] IOA_0_out, + output [7:0] IOB_0_out, + output IOA_0_oe, + output IOB_0_oe, + + input [7:0] IOA_1_in, + input [7:0] IOB_1_in, + output [7:0] IOA_1_out, + output [7:0] IOB_1_out, + output IOA_1_oe, + output IOB_1_oe + ); @@ -128,7 +136,14 @@ jt03 ym2203_0 .psg_B(psg_ch_b_0), .psg_C(psg_ch_c_0), - .fm_snd(opn_0) + .fm_snd(opn_0), + + .IOA_in(IOA_0_in), + .IOB_in(IOB_0_in), + .IOA_out(IOA_0_out), + .IOB_out(IOB_0_out), + .IOA_oe(IOA_0_oe), + .IOB_oe(IOB_0_oe) ); wire [7:0] psg_ch_a_1; @@ -154,12 +169,12 @@ jt03 ym2203_1 .fm_snd(opn_1), - .IOA_in(IOA_in), - .IOB_in(IOB_in), - .IOA_out(IOA_out), - .IOB_out(IOB_out), - .IOA_oe(IOA_oe), - .IOB_oe(IOB_oe) + .IOA_in(IOA_1_in), + .IOB_in(IOB_1_in), + .IOA_out(IOA_1_out), + .IOB_out(IOB_1_out), + .IOA_oe(IOA_1_oe), + .IOB_oe(IOB_1_oe) ); assign DO = ay_select ? DO_1 : DO_0; diff --git a/rtl/tsconf.v b/rtl/tsconf.v index 5bd0786..acc56a7 100644 --- a/rtl/tsconf.v +++ b/rtl/tsconf.v @@ -46,7 +46,7 @@ module tsconf input [64:0] RTC, input TAPE_IN, output TAPE_OUT, - output MIDI_OUT, + output reg MIDI_OUT = 1'b0, input UART_RX, output UART_TX, @@ -1049,8 +1049,19 @@ module tsconf wire [11:0] ts_l, ts_r; wire [7:0] ts_do; - wire [7:0] ioa_out; - assign MIDI_OUT = ioa_out[2]; + wire [7:0] ioa_0_out; + wire [7:0] ioa_1_out; + reg ioa_0_out_2_r = 1'b0, ioa_1_out_2_r = 1'b0; + always @(posedge fclk) begin + if (ioa_0_out_2_r != ioa_0_out[2]) begin + ioa_0_out_2_r <= ioa_0_out[2]; + MIDI_OUT <= ioa_0_out[2]; + end + if (ioa_1_out_2_r != ioa_1_out[2]) begin + ioa_1_out_2_r <= ioa_1_out[2]; + MIDI_OUT <= ioa_1_out[2]; + end + end turbosound turbosound ( @@ -1063,7 +1074,8 @@ module tsconf .DO(ts_do), .CHANNEL_L(ts_l), .CHANNEL_R(ts_r), - .IOA_out(ioa_out) + .IOA_0_out(ioa_0_out), + .IOA_1_out(ioa_1_out) );