move gpio_led constraints from Debug into Dvi
[fleet.git] / ships / Debug.ship
1 ship: Debug
2
3 == Ports ===========================================================
4 data  in:     in
5 dockless out: out
6
7 percolate down: uart_in     1
8 percolate up:   uart_out    1
9 percolate up:   rst_out     1
10 percolate down: rst_in      1
11
12 == Constants ========================================================
13
14 == TeX ==============================================================
15
16 percolate up:   uart_rts    1
17 percolate down: uart_cts    1
18
19 This ship is used for debugging.  It has only one port, {\tt in}.
20 Programmers should send debug report values to this port.  How such
21 values are reported back to the programmer doing the debugging is left
22 unspecified.
23
24 \subsection*{To Do}
25
26 Provide an {\tt inOp} port and use opcode ports \cite{am25} to
27 effectively allow multiple independent ``debug streams''
28
29 Provide a way to programmatically read back the output of the debug
30 ship.
31
32 == Fleeterpreter ====================================================
33 public void service() {
34   if (box_in.dataReadyForShip())
35     ((Interpreter)getFleet()).debug(box_in.removeDataForShip());
36 }
37
38 == FleetSim ==============================================================
39
40 == FPGA ==============================================================
41
42   wire break_i;
43   reg break_last;
44   reg send_k;
45   initial send_k = 0;
46
47   reg [`WORDWIDTH-1:0] data_to_host_full_word;
48   reg [7:0] count_in;
49   reg [7:0] count_out;
50   reg [49:0] out_d;
51   assign out_d_ = out_d;
52
53   wire       data_to_host_full;
54   reg  [7:0] data_to_host;
55   wire       data_to_fleet_empty;
56   wire [7:0] data_to_fleet;
57   reg        data_to_host_write_enable;
58   reg        data_to_fleet_read_enable;
59
60   wire sio_ce;
61   wire sio_ce_x4;
62
63   wire break;
64   wire uart_cts;
65   assign uart_cts = 0;
66   assign rst_out = rst_in || break;
67
68   // fst=3 means clock divider is 3+2=5 for a 50Mhz clock => 10Mhz
69   // using a 33Mhz clock,
70   //   33.333Mhz / 38400hz * 4 = 217.013 => 215+2,1 => 215,1
71   // using a 100Mhz clock,
72   //   100Mhz / 38400hz * 4 = 651.039 => 215+2,3 => 215,3
73   sasc_brg sasc_brg(clk, !rst_in, 215, 3, sio_ce, sio_ce_x4);
74   sasc_top sasc_top(clk, !rst_in,
75                     uart_in,
76                     uart_out,
77                     uart_cts,
78                     uart_rts, 
79                     sio_ce,
80                     sio_ce_x4,
81                     data_to_host,
82                     data_to_fleet,
83                     data_to_fleet_read_enable,
84                     data_to_host_write_enable,
85                     data_to_host_full,
86                     data_to_fleet_empty,
87                     break,
88                     break_i);
89
90    // break and break are _active high_
91    always @(posedge clk) break_last <= break;
92    assign break_i    =  break && !break_last;
93    assign break_done = !break &&  break_last;
94
95    // fpga -> host
96    always @(posedge clk) begin
97      if (rst) begin
98        count_in  <= 0;
99        count_out <= 0;
100        `reset
101      end else begin
102
103        `cleanup
104
105        // fpga -> host
106        data_to_host_write_enable <= 0;
107        if (break_i) begin
108        end else if (break_done) begin
109          data_to_host_write_enable <= 1;
110          data_to_host <= 111;
111          send_k <= 1;
112        end else if (send_k) begin
113          data_to_host_write_enable <= 1;
114          data_to_host <= 107;
115          send_k <= 0;
116        end else if (count_out==0 && `in_full) begin
117          `drain_in
118          data_to_host_full_word <= in_d;
119          count_out <= 8;
120        end else if (count_out!=0 && !data_to_host_full && !data_to_host_write_enable) begin
121          data_to_host <= { 2'b0, data_to_host_full_word[5:0] };
122          data_to_host_full_word <= (data_to_host_full_word >> 6);
123          data_to_host_write_enable <= 1;
124          count_out <= count_out-1;
125        end
126
127        // host -> fpga
128        data_to_fleet_read_enable <= 0;
129        if (!data_to_fleet_empty && `out_empty && !data_to_fleet_read_enable) begin
130          out_d <= { out_d[43:0], data_to_fleet[5:0] };
131          data_to_fleet_read_enable <= 1;
132          if (count_in==9) begin
133            count_in <= 0;
134            `fill_out
135          end else begin
136            count_in <= count_in+1;
137          end
138        end
139
140     end
141   end
142
143 == UCF =================================================================
144
145 Net clk_pin LOC=AH15;
146 Net clk_pin  PERIOD = 10 ns HIGH 50%;  # 100Mhz
147
148 # 33mhz clock
149 #Net clk_pin LOC=AH17;
150 #Net clk_pin TNM_NET = clk_pin;
151 #TIMESPEC TS_clk_pin = PERIOD clk_pin 30 ns HIGH 50%;  # 33Mhz
152
153 Net rst_pin LOC=E9;
154 Net rst_pin PULLUP;
155 Net rst_pin TIG;
156
157 #Net uart_cts LOC=G6;
158 #Net uart_cts IOSTANDARD = LVCMOS33;
159 #Net uart_cts TIG;
160
161 #Net uart_rts LOC=F6;
162 #Net uart_rts IOSTANDARD = LVCMOS33;
163 #Net uart_rts TIG;
164
165 Net uart_in LOC=AG15;
166 #Net uart_in IOSTANDARD = LVCMOS33;
167 Net uart_in TIG;
168 Net uart_in PULLUP;
169
170 Net uart_out LOC=AG20;
171 #Net uart_out IOSTANDARD = LVCMOS33;
172 Net uart_out TIG;
173 Net uart_out PULLUP;
174
175
176
177
178
179 == Test ================================================================
180 #expect 25
181
182 #ship debug : Debug
183
184 debug.in:
185   set word= 25;
186   deliver;
187
188 == Contributors =========================================================
189 Adam Megacz <megacz@cs.berkeley.edu>