]> Joshua Wise's Git repositories - fpgaboy.git/blobdiff - Sound2.v
Fix bugs in SCF and CCF
[fpgaboy.git] / Sound2.v
index 2bb959861dcd9f5ebf48bc64b4bda1e02b490e63..ef382632d6867b9b3a46eaa00f40a23709792092 100644 (file)
--- 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 @ (negedge core_clk) begin
+       always @ (posedge core_clk) begin
+               rdlatch <= rd;
+               addrlatch <= addr;
                if(en && wr) begin
                        case(addr)
                        `ADDR_NR21: nr21 <= data;
This page took 0.028455 seconds and 4 git commands to generate.