11 // synthesis attribute ram_style of rom is block
12 reg [7:0] rom [1023:0];
13 initial $readmemh("rom.hex", rom);
15 wire decode = address[15:13] == 0;
17 odata <= rom[address[10:0]];
18 assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
27 reg [7:0] brom [255:0];
28 initial $readmemh("bootstrap.hex", brom);
30 wire decode = address[15:8] == 0;
31 wire [7:0] odata = brom[address[7:0]];
32 assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
41 reg [7:0] ram [127:0];
43 wire decode = (address >= 16'hFF80) && (address <= 16'hFFFE);
45 assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
49 if (decode) // This has to go this way. The only way XST knows how to do
50 begin // block ram is chip select, write enable, and always
51 if (wr) // reading. "else if rd" does not cut it ...
52 ram[address[6:0]] <= data;
53 odata <= ram[address[6:0]];
63 output wire cr_nADV, cr_nCE, cr_nOE, cr_nWE, cr_CRE, cr_nLB, cr_nUB, cr_CLK,
64 output wire [22:0] cr_A,
67 parameter ADDR_PROGADDRH = 16'hFF60;
68 parameter ADDR_PROGADDRM = 16'hFF61;
69 parameter ADDR_PROGADDRL = 16'hFF62;
70 parameter ADDR_PROGDATA = 16'hFF63;
72 reg [7:0] progaddrh, progaddrm, progaddrl;
74 assign cr_nADV = 0; /* Addresses are always valid! :D */
75 assign cr_nCE = 0; /* The chip is enabled */
76 assign cr_nLB = 0; /* Lower byte is enabled */
77 assign cr_nUB = 0; /* Upper byte is enabled */
78 assign cr_CRE = 0; /* Data writes, not config */
79 assign cr_CLK = 0; /* Clock? I think not! */
81 wire decode = (address[15:14] == 2'b00) /* extrom */ || (address[15:13] == 3'b101) /* extram */ || (address == ADDR_PROGDATA);
83 assign cr_nOE = decode ? ~rd : 1;
84 assign cr_nWE = decode ? ~wr : 1;
86 assign cr_DQ = (~cr_nOE) ? 16'bzzzzzzzzzzzzzzzz : {8'b0, data};
87 assign cr_A = (address[15:14] == 2'b00) ? /* extrom */ {9'b0,address[13:0]} :
88 (address[15:13] == 3'b101) ? {1'b1, 9'b0, address[12:0]} :
89 (address == ADDR_PROGDATA) ? {progaddrh[6:0], progaddrm[7:0], progaddrl[7:0]} :
96 ADDR_PROGADDRH: if (wr) progaddrh <= data;
97 ADDR_PROGADDRM: if (wr) progaddrm <= data;
98 ADDR_PROGADDRL: if (wr) progaddrl <= data;
101 assign data = (rd && decode) ?
102 (address == ADDR_PROGADDRH) ? progaddrh :
103 (address == ADDR_PROGADDRM) ? progaddrm :
104 (address == ADDR_PROGADDRL) ? progaddrl :
110 input [15:0] address,
115 // synthesis attribute ram_style of ram is block
116 reg [7:0] ram [8191:0];
118 wire decode = (address >= 16'hC000) && (address <= 16'hFDFF); /* This includes echo RAM. */
120 assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
122 always @(posedge clk)
124 if (decode) // This has to go this way. The only way XST knows how to do
125 begin // block ram is chip select, write enable, and always
126 if (wr) // reading. "else if rd" does not cut it ...
127 ram[address[12:0]] <= data;
128 odata <= ram[address[12:0]];
134 input [15:0] address,
138 input [7:0] switches,
139 output reg [7:0] ledout = 0);
141 wire decode = address == 16'hFF51;
143 assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
145 always @(posedge clk)
149 else if (decode && wr)
155 module Dumpable(input [2:0] r, g, input [1:0] b, input hs, vs, vgaclk);
161 output reg vgaclk = 0,
165 input [7:0] switches,
167 output wire [7:0] leds,
169 output wire [3:0] digits,
170 output wire [7:0] seven,
171 output wire cr_nADV, cr_nCE, cr_nOE, cr_nWE, cr_CRE, cr_nLB, cr_nUB, cr_CLK,
172 output wire [22:0] cr_A,
176 output wire [2:0] r, g,
178 output wire soundl, soundr);
181 always #62 clk <= ~clk;
182 always #100 vgaclk <= ~vgaclk;
184 Dumpable dump(r,g,b,hs,vs,vgaclk);
190 wire [7:0] switches = 8'b0;
191 wire [3:0] buttons = 4'b0;
193 wire xtalb, clk, vgaclk;
194 IBUFG iclkbuf(.O(xtalb), .I(xtal));
195 CPUDCM dcm (.CLKIN_IN(xtalb), .CLKFX_OUT(clk));
196 pixDCM pixdcm (.CLKIN_IN(xtalb), .CLKFX_OUT(vgaclk));
199 wire [15:0] addr [1:0];
200 wire [7:0] data [1:0];
201 wire wr [1:0], rd [1:0];
203 wire irq, tmrirq, lcdcirq, vblankirq;
209 .bus0address(addr[0]),
213 .bus1address(addr[1]),
254 wire lcdhs, lcdvs, lcdclk;
255 wire [2:0] lcdr, lcdg;
265 .vblankirq(vblankirq),
294 (state == 2'b00) ? 4'b0010 :
295 (state == 2'b01) ? 4'b0001 :
296 (state == 2'b10) ? 4'b1000 :
309 UART nouart ( /* no u */
364 .snd_data_r(soundr));