]> Joshua Wise's Git repositories - fpgaboy.git/blobdiff - Soundcore.v
IP
[fpgaboy.git] / Soundcore.v
index 7752317f9e461e74f430c23cd7c37697a1146efd..70c4db1f5dab5794196e02bf7bb3f97690d93ad7 100644 (file)
@@ -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;
This page took 0.025577 seconds and 4 git commands to generate.