3 `define CLK_DIV `IN_CLK / `OUT_CLK
4 `define MMAP_ADDR 16'hFF50
12 output reg serial = 1);
15 wire decode = (addr == `MMAP_ADDR);
18 assign data = rdlatch ? odata : 8'bzzzzzzzz;
20 reg [7:0] data_stor = 0;
21 reg [15:0] clkdiv = 0;
23 reg [3:0] diqing = 4'b0000;
25 wire newdata = (wr) && (!have_data) && decode;
27 assign odata = have_data ? 8'b1 : 8'b0;
29 always @ (posedge clk)
31 rdlatch <= rd && decode;
32 /* deal with diqing */
37 end else if (clkdiv == 0) begin
42 4'b0001: serial <= data_stor[0];
43 4'b0010: serial <= data_stor[1];
44 4'b0011: serial <= data_stor[2];
45 4'b0100: serial <= data_stor[3];
46 4'b0101: serial <= data_stor[4];
47 4'b0110: serial <= data_stor[5];
48 4'b0111: serial <= data_stor[6];
49 4'b1000: serial <= data_stor[7];
51 4'b1010: have_data <= 0;
56 /* deal with clkdiv */
57 if((newdata && !have_data) || clkdiv == `CLK_DIV)