X-Git-Url: http://git.joshuawise.com/fpgaboy.git/blobdiff_plain/75ab1e9975f64989ee18450eb09b66b33ec5def8..refs/heads/master:/Soundcore.v diff --git a/Soundcore.v b/Soundcore.v index 7752317..70c4db1 100644 --- a/Soundcore.v +++ b/Soundcore.v @@ -29,14 +29,19 @@ module Soundcore( (nr51[7] ? sndout4 : 4'b0); assign sndout3 = 0; assign sndout4 = 0; - - assign data = rd ? - addr == `ADDR_NR50 ? nr50 : - addr == `ADDR_NR51 ? nr51 : - addr == `ADDR_NR52 ? nr52 : 8'bzzzzzzzz + + reg rdlatch; + reg [15:0] addrlatch; + + assign data = rdlatch ? + addrlatch == `ADDR_NR50 ? nr50 : + addrlatch == `ADDR_NR51 ? nr51 : + addrlatch == `ADDR_NR52 ? nr52 : 8'bzzzzzzzz : 8'bzzzzzzzz; - always @ (negedge core_clk) begin + always @ (posedge core_clk) begin + rdlatch <= rd; + addrlatch <= addr; if(wr) begin case(addr) `ADDR_NR50: nr50 <= data;