1 `define ADDR_DIV 16'hFF04
2 `define ADDR_TIMA 16'hFF05
3 `define ADDR_TMA 16'hFF06
4 `define ADDR_TAC 16'hFF07
14 reg [7:0] tima = 0, tma = 0, tac = 0, div = 0;
18 wire is_tima = addr == `ADDR_TIMA;
19 wire is_tma = addr == `ADDR_TMA;
20 wire is_tac = addr == `ADDR_TAC;
30 (tac[1:0] == 2'b00) ? (clkdv == 10'b0) :
31 (tac[1:0] == 2'b01) ? (clkdv[3:0] == 4'b0) :
32 (tac[1:0] == 2'b10) ? (clkdv[5:0] == 6'b0) :
33 (clkdv[7:0] == 8'b0) :
36 always @ (negedge clk)
40 `ADDR_DIV: div <= 8'b0;
41 `ADDR_TIMA: tima <= data;
42 `ADDR_TMA: tma <= data;
43 `ADDR_TAC: tac <= data;
54 {ovf,tima} <= {1'b0,tima} + 1;
59 if(clkdv[7:0] == 8'b0)