X-Git-Url: http://git.joshuawise.com/fpgaboy.git/blobdiff_plain/68ce013e5fe7c5d1c4e07fe8ba1eb0ba2855b280..refs/heads/master:/Soundcore.v?ds=sidebyside diff --git a/Soundcore.v b/Soundcore.v index 626001d..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 @ (posedge core_clk) begin + rdlatch <= rd; + addrlatch <= addr; if(wr) begin case(addr) `ADDR_NR50: nr50 <= data;