first draft of ZBT controller
[fleet.git] / ships / ZBT.ship
1 ship: ZBT
2
3 == Ports ===========================================================
4 data  in:    inAddrRead
5 data  in:    inAddrWrite
6 data  in:    inDataWrite
7
8 data  out:   out
9
10 percolate up:      sram_adv_ld_b 1
11 percolate up:      sram_bw0 1
12 percolate up:      sram_bw1 1
13 percolate up:      sram_bw2 1
14 percolate up:      sram_bw3 1
15 percolate up:      sram_clk 1
16 percolate up:      sram_cs_b 1
17 percolate up:      sram_flash_a0 1
18 percolate up:      sram_flash_a1 1
19 percolate up:      sram_flash_a2 1
20 percolate up:      sram_flash_a3 1
21 percolate up:      sram_flash_a4 1
22 percolate up:      sram_flash_a5 1
23 percolate up:      sram_flash_a6 1
24 percolate up:      sram_flash_a7 1
25 percolate up:      sram_flash_a8 1
26 percolate up:      sram_flash_a9 1
27 percolate up:      sram_flash_a10 1
28 percolate up:      sram_flash_a11 1
29 percolate up:      sram_flash_a12 1
30 percolate up:      sram_flash_a13 1
31 percolate up:      sram_flash_a14 1
32 percolate up:      sram_flash_a15 1
33 percolate up:      sram_flash_a16 1
34 percolate up:      sram_flash_a17 1
35 percolate up:      sram_flash_a18 1
36 percolate up:      sram_flash_a19 1
37 percolate up:      sram_flash_a20 1
38 percolate up:      sram_flash_a21 1
39 percolate up:      sram_flash_we_b 1
40 percolate up:      sram_mode 1
41 percolate up:      sram_oe_b 1
42
43 percolate inout:    sram_d16 1
44 percolate inout:    sram_d17 1
45 percolate inout:    sram_d18 1
46 percolate inout:    sram_d19 1
47 percolate inout:    sram_d20 1
48 percolate inout:    sram_d21 1
49 percolate inout:    sram_d22 1
50 percolate inout:    sram_d23 1
51 percolate inout:    sram_d24 1
52 percolate inout:    sram_d25 1
53 percolate inout:    sram_d26 1
54 percolate inout:    sram_d27 1
55 percolate inout:    sram_d28 1
56 percolate inout:    sram_d29 1
57 percolate inout:    sram_d30 1
58 percolate inout:    sram_d31 1
59
60 percolate inout:    sram_dqp0 1
61 percolate inout:    sram_dqp1 1
62 percolate inout:    sram_dqp2 1
63 percolate inout:    sram_dqp3 1
64
65 percolate inout:    sram_flash_d0 1
66 percolate inout:    sram_flash_d1 1
67 percolate inout:    sram_flash_d2 1
68 percolate inout:    sram_flash_d3 1
69 percolate inout:    sram_flash_d4 1
70 percolate inout:    sram_flash_d5 1
71 percolate inout:    sram_flash_d6 1
72 percolate inout:    sram_flash_d7 1
73 percolate inout:    sram_flash_d8 1
74 percolate inout:    sram_flash_d9 1
75 percolate inout:    sram_flash_d10 1
76 percolate inout:    sram_flash_d11 1
77 percolate inout:    sram_flash_d12 1
78 percolate inout:    sram_flash_d13 1
79 percolate inout:    sram_flash_d14 1
80 percolate inout:    sram_flash_d15 1
81
82 == TeX ==============================================================
83
84 == Fleeterpreter ====================================================
85     public void service() { }
86 == FleetSim ==============================================================
87
88 == FPGA ==============================================================
89
90 zbt_top my_zbt_top(
91   .clk(clk),
92   .reset(rst),
93   .sram_clk(clk),
94   .sram_mode(sram_mode),
95   .sram_cs_b(sram_cs_b),
96   .sram_oe_b(sram_oe_b),
97   .sram_flash_we_b(sram_flash_we_b),            
98   .sram_adv_ld_b(sram_adv_ld_b),            
99   .SRAM_BW0(sram_bw0),
100   .SRAM_BW1(sram_bw1),
101   .SRAM_BW2(sram_bw2),
102   .SRAM_BW3(sram_bw3),
103             
104   // SRAM_FLASH_A0 : out STD_LOGIC; --not connected to SRAM!
105   .SRAM_FLASH_A1(sram_flash_a1),
106   .SRAM_FLASH_A2(sram_flash_a2),
107   .SRAM_FLASH_A3(sram_flash_a3),
108   .SRAM_FLASH_A4(sram_flash_a4),
109   .SRAM_FLASH_A5(sram_flash_a5),
110   .SRAM_FLASH_A6(sram_flash_a6),
111   .SRAM_FLASH_A7(sram_flash_a7),
112   .SRAM_FLASH_A8(sram_flash_a8),
113   .SRAM_FLASH_A9(sram_flash_a9),
114   .SRAM_FLASH_A10(sram_flash_a10),
115   .SRAM_FLASH_A11(sram_flash_a11),
116   .SRAM_FLASH_A12(sram_flash_a12),
117   .SRAM_FLASH_A13(sram_flash_a13),
118   .SRAM_FLASH_A14(sram_flash_a14),
119   .SRAM_FLASH_A15(sram_flash_a15),
120   .SRAM_FLASH_A16(sram_flash_a16),
121   .SRAM_FLASH_A17(sram_flash_a17),
122   .SRAM_FLASH_A18(sram_flash_a18),
123             
124   .SRAM_FLASH_D0(sram_flash_d0),
125   .SRAM_FLASH_D1(sram_flash_d1),
126   .SRAM_FLASH_D2(sram_flash_d2),
127   .SRAM_FLASH_D3(sram_flash_d3),
128   .SRAM_FLASH_D4(sram_flash_d4),
129   .SRAM_FLASH_D5(sram_flash_d5),
130   .SRAM_FLASH_D6(sram_flash_d6),
131   .SRAM_FLASH_D7(sram_flash_d7),
132   .SRAM_FLASH_D8(sram_flash_d8),
133   .SRAM_FLASH_D9(sram_flash_d9),
134   .SRAM_FLASH_D10(sram_flash_d10),
135   .SRAM_FLASH_D11(sram_flash_d11),
136   .SRAM_FLASH_D12(sram_flash_d12),
137   .SRAM_FLASH_D13(sram_flash_d13),
138   .SRAM_FLASH_D14(sram_flash_d14),
139   .SRAM_FLASH_D15(sram_flash_d15),
140   .SRAM_D16(sram_d16),
141   .SRAM_D17(sram_d17),
142   .SRAM_D18(sram_d18),
143   .SRAM_D19(sram_d19),
144   .SRAM_D20(sram_d20),
145   .SRAM_D21(sram_d21),
146   .SRAM_D22(sram_d22),
147   .SRAM_D23(sram_d23),
148   .SRAM_D24(sram_d24),
149   .SRAM_D25(sram_d25),
150   .SRAM_D26(sram_d26),
151   .SRAM_D27(sram_d27),
152   .SRAM_D28(sram_d28),
153   .SRAM_D29(sram_d29),
154   .SRAM_D30(sram_d30),
155   .SRAM_D31(sram_d31),
156
157   .SRAM_DQP0(sram_dqp0),
158   .SRAM_DQP1(sram_dqp1),
159   .SRAM_DQP2(sram_dqp2),
160   .SRAM_DQP3(sram_dqp3),
161
162   .wb_adr_i(), // : in std_logic_vector(17 downto 0);
163   .wb_we_i(), // : in std_logic;
164   .wb_dat_i(), // : in std_logic_vector(35 downto 0);
165   .wb_sel_i(), // : in std_logic_vector(3 downto 0);
166   .wb_dat_o(), // : out std_logic_vector(35 downto 0);
167   .wb_cyc_i(), // : in std_logic;
168   .wb_stb_i(), // : in std_logic;
169   .wb_cti_i(), // : in std_logic_vector(2 downto 0);
170   .wb_bte_i(), // : in std_logic_vector(1 downto 0);
171   .wb_ack_o(), // : out std_logic;
172   .wb_err_o(), // : out std_logic;
173   .wb_tga_i() // in std_logic := '0' --'0' to mean last (or single) 4 words burst
174  );
175 /*
176 // custom code //////////////////////////////////////////////////////////////////////////////
177
178 reg  [37:0] out_d;
179 assign out_d_ = out_d;
180
181 // grossly inefficient -- always uses only the first word of a burst!
182 always @(posedge clk) begin
183   if (rst) begin
184     `reset
185     app_wdf_wren <= 0;
186     app_af_wren  <= 0;
187     read_waiting <= 0;
188     burst_count  <= 0;
189
190   end else begin
191     `cleanup
192
193     mask <= 8'b11111111;
194     if (burst_count == 0 || burst_count == 1) begin
195       app_wdf_wren <= 0;
196       app_af_wren  <= 0;
197     end else if ((burst_count > 1) && (app_af_cmd == 3'b000)) begin
198       app_af_wren  <= ~burst_count[0];
199     end
200
201     if (burst_count > 0) begin
202       burst_count <= burst_count - 1;
203     end else if ((~read_waiting) && rd_data_valid) begin
204       // wait
205     end else if (read_waiting) begin
206       if (rd_data_valid) begin
207         read_waiting <= 0;
208         out_d <= { 1'b0, rd_data_fifo_out[36:0] };
209         `fill_out
210       end
211     end else if (app_wdf_afull || app_af_afull) begin
212       // wait
213     end else if (`inAddrWrite_full && `inDataWrite_full) begin
214       `drain_inDataWrite
215       `drain_inAddrWrite
216       app_wdf_data   <= inDataWrite_d;
217       app_af_addr    <= { inAddrWrite_d, 2'b00 };
218       app_af_cmd     <= 3'b000;
219       app_af_wren    <= 1;
220       app_wdf_wren   <= 1;
221       burst_count    <= 7;
222       out_d          <= { phy_init_done //1'b1
223                           , 37'b0 };
224       mask           <= 8'b00000000;
225       `fill_out
226     end else if (`inAddrRead_full) begin
227       `drain_inAddrRead
228       app_af_addr    <= { inAddrRead_d, 2'b00 };
229       app_af_cmd     <= 3'b001;
230       app_af_wren    <= 1;
231       burst_count    <= 3;
232       read_waiting   <= 1;
233     end
234   end
235 end
236 */
237
238
239 == UCF ==============================================================
240
241 NET  sram_adv_ld_b        LOC="H8";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
242 NET  sram_bw0             LOC="D10";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
243 NET  sram_bw1             LOC="D11";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
244 NET  sram_bw2             LOC="J11";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
245 NET  sram_bw3             LOC="K11";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
246 NET  sram_clk             LOC="AG21";  # Bank 4, Vcco=3.3V, No DCI      
247 NET  sram_clk             LOC="G8";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
248 NET  sram_cs_b            LOC="J10";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
249 NET  sram_d16             LOC="N10";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
250 NET  sram_d17             LOC="E13";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
251 NET  sram_d18             LOC="E12";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
252 NET  sram_d19             LOC="L9";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
253 NET  sram_d20             LOC="M10";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors      
254 NET  sram_d21             LOC="E11";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
255 NET  sram_d22             LOC="F11";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
256 NET  sram_d23             LOC="L8";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
257 NET  sram_d24             LOC="M8";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
258 NET  sram_d25             LOC="G12";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
259 NET  sram_d26             LOC="G11";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
260 NET  sram_d27             LOC="C13";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
261 NET  sram_d28             LOC="B13";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
262 NET  sram_d29             LOC="K9";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
263 NET  sram_d30             LOC="K8";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
264 NET  sram_d31             LOC="J9";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
265 NET  sram_dqp0            LOC="D12";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
266 NET  sram_dqp1            LOC="C12";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
267 NET  sram_dqp2            LOC="H10";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
268 NET  sram_dqp3            LOC="H9";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
269 NET  sram_flash_a0        LOC="K12";   # Bank 1, Vcco=3.3V
270 NET  sram_flash_a1        LOC="K13";   # Bank 1, Vcco=3.3V
271 NET  sram_flash_a2        LOC="H23";   # Bank 1, Vcco=3.3V
272 NET  sram_flash_a3        LOC="G23";   # Bank 1, Vcco=3.3V
273 NET  sram_flash_a4        LOC="H12";   # Bank 1, Vcco=3.3V
274 NET  sram_flash_a5        LOC="J12";   # Bank 1, Vcco=3.3V
275 NET  sram_flash_a6        LOC="K22";   # Bank 1, Vcco=3.3V
276 NET  sram_flash_a7        LOC="K23";   # Bank 1, Vcco=3.3V
277 NET  sram_flash_a8        LOC="K14";   # Bank 1, Vcco=3.3V
278 NET  sram_flash_a9        LOC="L14";   # Bank 1, Vcco=3.3V
279 NET  sram_flash_a10       LOC="H22";   # Bank 1, Vcco=3.3V
280 NET  sram_flash_a11       LOC="G22";   # Bank 1, Vcco=3.3V
281 NET  sram_flash_a12       LOC="J15";   # Bank 1, Vcco=3.3V
282 NET  sram_flash_a13       LOC="K16";   # Bank 1, Vcco=3.3V
283 NET  sram_flash_a14       LOC="K21";   # Bank 1, Vcco=3.3V
284 NET  sram_flash_a15       LOC="J22";   # Bank 1, Vcco=3.3V
285 NET  sram_flash_a16       LOC="L16";   # Bank 1, Vcco=3.3V
286 NET  sram_flash_a17       LOC="L15";   # Bank 1, Vcco=3.3V
287 NET  sram_flash_a18       LOC="L20";   # Bank 1, Vcco=3.3V
288 NET  sram_flash_a19       LOC="L21";   # Bank 1, Vcco=3.3V
289 NET  sram_flash_a20       LOC="AE23";  # Bank 2, Vcco=3.3V
290 NET  sram_flash_a21       LOC="AE22";  # Bank 2, Vcco=3.3V
291 NET  sram_flash_d0        LOC="AD19";  # Bank 2, Vcco=3.3V
292 NET  sram_flash_d1        LOC="AE19";  # Bank 2, Vcco=3.3V
293 NET  sram_flash_d2        LOC="AE17";  # Bank 2, Vcco=3.3V
294 NET  sram_flash_d3        LOC="AF16";  # Bank 2, Vcco=3.3V
295 NET  sram_flash_d4        LOC="AD20";  # Bank 2, Vcco=3.3V
296 NET  sram_flash_d5        LOC="AE21";  # Bank 2, Vcco=3.3V
297 NET  sram_flash_d6        LOC="AE16";  # Bank 2, Vcco=3.3V
298 NET  sram_flash_d7        LOC="AF15";  # Bank 2, Vcco=3.3V
299 NET  sram_flash_d8        LOC="AH13";  # Bank 4, Vcco=3.3V, No DCI
300 NET  sram_flash_d9        LOC="AH14";  # Bank 4, Vcco=3.3V, No DCI
301 NET  sram_flash_d10       LOC="AH19";  # Bank 4, Vcco=3.3V, No DCI
302 NET  sram_flash_d11       LOC="AH20";  # Bank 4, Vcco=3.3V, No DCI
303 NET  sram_flash_d12       LOC="AG13";  # Bank 4, Vcco=3.3V, No DCI
304 NET  sram_flash_d13       LOC="AH12";  # Bank 4, Vcco=3.3V, No DCI
305 NET  sram_flash_d14       LOC="AH22";  # Bank 4, Vcco=3.3V, No DCI
306 NET  sram_flash_d15       LOC="AG22";  # Bank 4, Vcco=3.3V, No DCI
307 NET  sram_flash_we_b      LOC="AF20";  # Bank 2, Vcco=3.3V
308 NET  sram_mode            LOC="A13";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
309 NET  sram_oe_b            LOC="B12";   # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
310
311
312 == Test ==============================================================
313 #expect 20
314 #expect 16
315 #expect 12
316
317 #ship debug : Debug
318 #ship ddr   : DDR2
319
320 debug.in:
321   set ilc=*; recv, deliver;
322
323 ddr.out:
324   set ilc=3; collect;
325   send token to ddr.inAddrRead;
326   set ilc=3; collect, send to debug.in;
327
328 ddr.inAddrWrite:
329   set word=  0x1; deliver;
330   set word= 0x10; deliver;
331   set word=0x100; deliver;
332
333 ddr.inDataWrite:
334   set word=20; deliver;
335   set word=16; deliver;
336   set word=12; deliver;
337
338 ddr.inAddrRead:
339   recv token;
340   set word=  0x1; deliver;
341   set word= 0x10; deliver;
342   set word=0x100; deliver;
343
344
345 == Constants ========================================================
346
347 == Contributors =========================================================
348 Adam Megacz <megacz@cs.berkeley.edu>