12 // synthesis attribute ram_style of rom is block
13 reg [7:0] rom [1023:0];
14 initial $readmemh("rom.hex", rom);
16 wire decode = address[15:13] == 0;
17 always @(posedge clk) begin
18 rdlatch <= rd && decode;
19 odata <= rom[address[10:0]];
21 assign data = rdlatch ? odata : 8'bzzzzzzzz;
31 reg [7:0] brom [255:0];
32 initial $readmemh("bootstrap.hex", brom);
34 wire decode = address[15:8] == 0;
35 wire [7:0] odata = brom[address[7:0]];
37 rdlatch <= rd && decode;
38 assign data = rdlatch ? odata : 8'bzzzzzzzz;
47 reg [7:0] ram [127:0];
49 wire decode = (address >= 16'hFF80) && (address <= 16'hFFFE);
52 assign data = rdlatch ? odata : 8'bzzzzzzzz;
56 rdlatch <= rd && decode;
57 if (decode) // This has to go this way. The only way XST knows how to do
58 begin // block ram is chip select, write enable, and always
59 if (wr) // reading. "else if rd" does not cut it ...
60 ram[address[6:0]] <= data;
61 odata <= ram[address[6:0]];
71 output wire cr_nADV, cr_nCE, cr_nOE, cr_nWE, cr_CRE, cr_nLB, cr_nUB, cr_CLK,
72 output wire [22:0] cr_A,
75 parameter ADDR_PROGADDRH = 16'hFF60;
76 parameter ADDR_PROGADDRM = 16'hFF61;
77 parameter ADDR_PROGADDRL = 16'hFF62;
78 parameter ADDR_PROGDATA = 16'hFF63;
80 reg rdlatch = 0, wrlatch = 0;
81 reg [15:0] addrlatch = 0;
82 reg [7:0] datalatch = 0;
84 reg [7:0] progaddrh, progaddrm, progaddrl;
86 assign cr_nADV = 0; /* Addresses are always valid! :D */
87 assign cr_nCE = 0; /* The chip is enabled */
88 assign cr_nLB = 0; /* Lower byte is enabled */
89 assign cr_nUB = 0; /* Upper byte is enabled */
90 assign cr_CRE = 0; /* Data writes, not config */
91 assign cr_CLK = 0; /* Clock? I think not! */
93 wire decode = (addrlatch[15:14] == 2'b00) /* extrom */ || (addrlatch[15:13] == 3'b101) /* extram */ || (addrlatch == ADDR_PROGDATA);
95 assign cr_nOE = decode ? ~rdlatch : 1;
96 assign cr_nWE = decode ? ~wrlatch : 1;
98 assign cr_DQ = (~cr_nOE) ? 16'bzzzzzzzzzzzzzzzz : {8'b0, datalatch};
99 assign cr_A = (addrlatch[15:14] == 2'b00) ? /* extrom */ {9'b0,addrlatch[13:0]} :
100 (addrlatch[15:13] == 3'b101) ? {1'b1, 9'b0, addrlatch[12:0]} :
101 (addrlatch == ADDR_PROGDATA) ? {progaddrh[6:0], progaddrm[7:0], progaddrl[7:0]} :
106 always @(posedge clk) begin
108 ADDR_PROGADDRH: if (wr) progaddrh <= data;
109 ADDR_PROGADDRM: if (wr) progaddrm <= data;
110 ADDR_PROGADDRL: if (wr) progaddrl <= data;
114 addrlatch <= address;
118 assign data = (rdlatch && decode) ?
119 (addrlatch == ADDR_PROGADDRH) ? progaddrh :
120 (addrlatch == ADDR_PROGADDRM) ? progaddrm :
121 (addrlatch == ADDR_PROGADDRL) ? progaddrl :
127 input [15:0] address,
132 // synthesis attribute ram_style of ram is block
133 reg [7:0] ram [8191:0];
135 wire decode = (address >= 16'hC000) && (address <= 16'hFDFF); /* This includes echo RAM. */
138 assign data = rdlatch ? odata : 8'bzzzzzzzz;
140 always @(posedge clk)
142 rdlatch <= rd && decode;
143 if (decode) // This has to go this way. The only way XST knows how to do
144 begin // block ram is chip select, write enable, and always
145 if (wr) // reading. "else if rd" does not cut it ...
146 ram[address[12:0]] <= data;
147 odata <= ram[address[12:0]];
153 input [15:0] address,
157 input [7:0] switches,
158 output reg [7:0] ledout = 0);
160 wire decode = address == 16'hFF51;
163 assign data = rdlatch ? odata : 8'bzzzzzzzz;
165 always @(posedge clk)
167 rdlatch <= rd && decode;
170 else if (decode && wr)
176 module Dumpable(input [2:0] r, g, input [1:0] b, input hs, vs, vgaclk);
182 output reg vgaclk = 0,
186 input [7:0] switches,
188 output wire [7:0] leds,
190 output wire [3:0] digits,
191 output wire [7:0] seven,
192 output wire cr_nADV, cr_nCE, cr_nOE, cr_nWE, cr_CRE, cr_nLB, cr_nUB, cr_CLK,
193 output wire [22:0] cr_A,
197 output wire [2:0] r, g,
199 output wire soundl, soundr);
202 always #62 clk <= ~clk;
203 always #100 vgaclk <= ~vgaclk;
205 Dumpable dump(r,g,b,hs,vs,vgaclk);
211 wire [7:0] switches = 8'b0;
212 wire [3:0] buttons = 4'b0;
214 wire xtalb, clk, vgaclk;
215 IBUFG iclkbuf(.O(xtalb), .I(xtal));
216 CPUDCM dcm (.CLKIN_IN(xtalb), .CLKFX_OUT(clk));
217 pixDCM pixdcm (.CLKIN_IN(xtalb), .CLKFX_OUT(vgaclk));
220 wire [15:0] addr [1:0];
221 wire [7:0] data [1:0];
222 wire wr [1:0], rd [1:0];
224 wire irq, tmrirq, lcdcirq, vblankirq;
230 .bus0address(addr[0]),
234 .bus1address(addr[1]),
275 wire lcdhs, lcdvs, lcdclk;
276 wire [2:0] lcdr, lcdg;
286 .vblankirq(vblankirq),
315 (state == 2'b00) ? 4'b0010 :
316 (state == 2'b01) ? 4'b0001 :
317 (state == 2'b10) ? 4'b1000 :
330 UART nouart ( /* no u */
385 .snd_data_r(soundr));