X-Git-Url: http://git.joshuawise.com/fpgaboy.git/blobdiff_plain/09c1936c32d74947896338a1c57270b2918656f8..01878f5fdca9d08e4cf7ceed7f5a39f4df602de4:/Soundcore.v diff --git a/Soundcore.v b/Soundcore.v index 16d6067..b2c4d35 100644 --- a/Soundcore.v +++ b/Soundcore.v @@ -17,9 +17,16 @@ module Soundcore( reg [4:0] cntclk; reg [13:0] lenclk; wire [3:0] sndout1,sndout2,sndout3,sndout4; - wire [3:0] right_snd = nr51[0] ? sndout1 : 4'b0; - wire [3:0] left_snd = nr51[4] ? sndout1 : 4'b0; - + wire [3:0] right_snd = + (nr51[0] ? sndout1 : 4'b0) + + (nr51[1] ? sndout2 : 4'b0) + + (nr51[2] ? sndout3 : 4'b0) + + (nr51[3] ? sndout4 : 4'b0); + wire [3:0] left_snd = + (nr51[4] ? sndout1 : 4'b0) + + (nr51[5] ? sndout2 : 4'b0) + + (nr51[6] ? sndout3 : 4'b0) + + (nr51[7] ? sndout4 : 4'b0); assign sndout3 = 0; assign sndout4 = 0; @@ -34,14 +41,14 @@ module Soundcore( case(addr) `ADDR_NR50: nr50 <= data; `ADDR_NR51: nr51 <= data; - `ADDR_NR52: nr52 <= {data[7],3'b1,data[3:0]}; + `ADDR_NR52: nr52 <= {data[7],7'b1111111}; endcase end cntclk <= cntclk + 1; lenclk <= lenclk + 1; pwmcnt <= pwmcnt + 1; - snd_data_l <= (pwmcnt <= left_snd) ? 1 : 0; - snd_data_r <= (pwmcnt <= right_snd) ? 1 : 0; + snd_data_l <= (pwmcnt <= left_snd) ? nr50[7] : 0; + snd_data_r <= (pwmcnt <= right_snd) ? nr50[3] : 0; end Sound1 s1( @@ -52,7 +59,7 @@ module Soundcore( .data(data), .cntclk(cntclk[4]), .lenclk(lenclk[13]), - .en(nr52[7] & nr52[0]), + .en(nr52[7]), .snd_data(sndout1) ); @@ -64,7 +71,7 @@ module Soundcore( .data(data), .cntclk(cntclk[4]), .lenclk(lenclk[13]), - .en(nr52[7] & nr52[0]), + .en(nr52[7]), .snd_data(sndout2) );