X-Git-Url: http://git.joshuawise.com/fpgaboy.git/blobdiff_plain/68ce013e5fe7c5d1c4e07fe8ba1eb0ba2855b280..a8f4468d0cd6910eba8031e21038d76857a2c107:/Interrupt.v diff --git a/Interrupt.v b/Interrupt.v index fcc396b..2686146 100644 --- a/Interrupt.v +++ b/Interrupt.v @@ -19,10 +19,13 @@ module Interrupt( reg [7:0] imask = 16'hFFFF; reg [7:0] ihold = 8'b0; wire [7:0] imasked = ihold & imask; + + reg rdlatch = 0; + reg [15:0] addrlatch = 0; - assign data = rd ? - (addr == `ADDR_IF) ? ihold : - (addr == `ADDR_IE) ? imask : + assign data = rdlatch ? + (addrlatch == `ADDR_IF) ? ihold : + (addrlatch == `ADDR_IE) ? imask : 8'bzzzzzzzz : 8'bzzzzzzzz; @@ -45,6 +48,8 @@ module Interrupt( end else ihold <= ihold | iflag; + rdlatch <= rd; + addrlatch <= addr; end endmodule