1 `define ADDR_IF 16'hFF0F
2 `define ADDR_IE 16'hFFFF
19 wire [7:0] iflag = {3'b0,buttons,serial,tovf,lcdc,vblank};
20 reg [7:0] imask = 16'hFFFF;
21 reg [7:0] ihold = 8'b0;
22 wire [7:0] imasked = ihold & imask;
25 reg [15:0] addrlatch = 0;
27 assign data = rdlatch ?
28 (addrlatch == `ADDR_IF) ? ihold :
29 (addrlatch == `ADDR_IE) ? imask :
33 assign master = (imasked) != 0;
35 assign jaddr = imasked[0] ? 8'h40 :
39 imasked[4] ? 8'h60 : 8'h00;
43 if (wr && (addr == `ADDR_IF || addr == `ADDR_IE)) begin
45 `ADDR_IF : ihold <= iflag | data;
46 `ADDR_IE : begin imask <= data; ihold <= ihold | iflag; end
51 (imasked[0] ? 8'b11111110 :
52 imasked[1] ? 8'b11111101 :
53 imasked[2] ? 8'b11111011 :
54 imasked[3] ? 8'b11110111 :
55 imasked[4] ? 8'b11101111 :
58 ihold <= ihold | iflag;