1 `define ADDR_NR10 16'hFF10
2 `define ADDR_NR11 16'hFF11
3 `define ADDR_NR12 16'hFF12
4 `define ADDR_NR13 16'hFF13
5 `define ADDR_NR14 16'hFF14
19 /* can be optimized as register file */
20 reg [7:0] nr10 = 0, nr11 = 0, nr12 = 0, nr13 = 0, nr14 = 0;
21 reg [10:0] counter = 0;
23 reg [3:0] delta = 4'b1111;
25 reg [3:0] snd_out = 0;
27 assign snd_data = en ? snd_out : 0;
30 addr == `ADDR_NR10 ? nr10 :
31 addr == `ADDR_NR11 ? nr11 :
32 addr == `ADDR_NR12 ? nr12 :
33 addr == `ADDR_NR13 ? nr13 :
34 addr == `ADDR_NR14 ? nr14 : 8'bzzzzzzzz
37 always @ (posedge core_clk) begin
40 `ADDR_NR10: nr10 <= data;
41 `ADDR_NR11: nr11 <= data;
42 `ADDR_NR12: nr12 <= data;
43 `ADDR_NR13: nr13 <= data;
44 `ADDR_NR14: nr14 <= data;
56 always @ (posedge cntclk) begin
58 counter <= counter - 1;
60 counter <= ~{nr14[2:0],nr13} + 1; /* possible A */
64 snd_out <= toggle ? delta : 0; /* Leave it to Dennis. */
67 always @ (posedge lenclk) begin
69 lencnt <= lencnt - 1; /* possible A */
71 lencnt <= ~nr11[4:0] + 1;