X-Git-Url: http://git.joshuawise.com/fpgaboy.git/blobdiff_plain/68ce013e5fe7c5d1c4e07fe8ba1eb0ba2855b280..6306dc0a42b06b5f253bb9ce6c5307761dcd419a:/Sound2.v?ds=inline diff --git a/Sound2.v b/Sound2.v index cf8e83a..ef38263 100644 --- a/Sound2.v +++ b/Sound2.v @@ -24,15 +24,20 @@ module Sound2( reg [3:0] snd_out = 0; assign snd_data = en ? snd_out : 0; + + reg rdlatch; + reg [15:0] addrlatch; - assign data = rd ? - addr == `ADDR_NR21 ? nr21 : - addr == `ADDR_NR22 ? nr22 : - addr == `ADDR_NR23 ? nr23 : - addr == `ADDR_NR24 ? nr24 : 8'bzzzzzzzz + assign data = rdlatch ? + addrlatch == `ADDR_NR21 ? nr21 : + addrlatch == `ADDR_NR22 ? nr22 : + addrlatch == `ADDR_NR23 ? nr23 : + addrlatch == `ADDR_NR24 ? nr24 : 8'bzzzzzzzz : 8'bzzzzzzzz; always @ (posedge core_clk) begin + rdlatch <= rd; + addrlatch <= addr; if(en && wr) begin case(addr) `ADDR_NR21: nr21 <= data;