move ucf constraints into .ship files
[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
71   sasc_brg sasc_brg(clk, !rst_in, 215, 1, sio_ce, sio_ce_x4);
72   sasc_top sasc_top(clk, !rst_in,
73                     uart_in,
74                     uart_out,
75                     uart_cts,
76                     uart_rts, 
77                     sio_ce,
78                     sio_ce_x4,
79                     data_to_host,
80                     data_to_fleet,
81                     data_to_fleet_read_enable,
82                     data_to_host_write_enable,
83                     data_to_host_full,
84                     data_to_fleet_empty,
85                     break,
86                     break_i);
87
88    // break and break are _active high_
89    always @(posedge clk) break_last <= break;
90    assign break_i    =  break && !break_last;
91    assign break_done = !break &&  break_last;
92
93    // fpga -> host
94    always @(posedge clk) begin
95      if (rst) begin
96        count_in  <= 0;
97        count_out <= 0;
98        `reset
99      end else begin
100
101        `cleanup
102
103        // fpga -> host
104        data_to_host_write_enable <= 0;
105        if (break_i) begin
106        end else if (break_done) begin
107          data_to_host_write_enable <= 1;
108          data_to_host <= 111;
109          send_k <= 1;
110        end else if (send_k) begin
111          data_to_host_write_enable <= 1;
112          data_to_host <= 107;
113          send_k <= 0;
114        end else if (count_out==0 && `in_full) begin
115          `drain_in
116          data_to_host_full_word <= in_d;
117          count_out <= 8;
118        end else if (count_out!=0 && !data_to_host_full && !data_to_host_write_enable) begin
119          data_to_host <= { 2'b0, data_to_host_full_word[5:0] };
120          data_to_host_full_word <= (data_to_host_full_word >> 6);
121          data_to_host_write_enable <= 1;
122          count_out <= count_out-1;
123        end
124
125        // host -> fpga
126        data_to_fleet_read_enable <= 0;
127        if (!data_to_fleet_empty && `out_empty && !data_to_fleet_read_enable) begin
128          out_d <= { out_d[43:0], data_to_fleet[5:0] };
129          data_to_fleet_read_enable <= 1;
130          if (count_in==9) begin
131            count_in <= 0;
132            `fill_out
133          end else begin
134            count_in <= count_in+1;
135          end
136        end
137
138     end
139   end
140
141 == UCF =================================================================
142
143 Net clk_pin LOC=AH15;
144 Net clk_pin  PERIOD = 10 ns HIGH 50%;  # 100Mhz
145
146 # 33mhz clock
147 #Net clk_pin LOC=AH17;
148 #Net clk_pin TNM_NET = clk_pin;
149 #TIMESPEC TS_clk_pin = PERIOD clk_pin 30 ns HIGH 50%;  # 33Mhz
150
151 Net rst_pin LOC=E9;
152 Net rst_pin PULLUP;
153 Net rst_pin TIG;
154
155 #Net uart_cts LOC=G6;
156 #Net uart_cts IOSTANDARD = LVCMOS33;
157 #Net uart_cts TIG;
158
159 #Net uart_rts LOC=F6;
160 #Net uart_rts IOSTANDARD = LVCMOS33;
161 #Net uart_rts TIG;
162
163 Net uart_in LOC=AG15;
164 #Net uart_in IOSTANDARD = LVCMOS33;
165 Net uart_in TIG;
166 Net uart_in PULLUP;
167
168 Net uart_out LOC=AG20;
169 #Net uart_out IOSTANDARD = LVCMOS33;
170 Net uart_out TIG;
171 Net uart_out PULLUP;
172
173 NET  gpio_sw_c            LOC="AJ6";   # Bank 18, Vcco=3.3V, No DCI
174
175 NET  gpio_led_c           LOC="E8";    # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
176 NET  gpio_led_e           LOC="AG23";  # Bank 2, Vcco=3.3V
177 NET  gpio_led_n           LOC="AF13";  # Bank 2, Vcco=3.3V
178 NET  gpio_led_s           LOC="AG12";  # Bank 2, Vcco=3.3V
179 NET  gpio_led_w           LOC="AF23";  # Bank 2, Vcco=3.3V
180
181 NET  gpio_led_0           LOC="H18";   # Bank 3, Vcco=2.5V, No DCI
182 NET  gpio_led_1           LOC="L18";   # Bank 3, Vcco=2.5V, No DCI
183 NET  gpio_led_2           LOC="G15";   # Bank 3, Vcco=2.5V, No DCI
184 NET  gpio_led_3           LOC="AD26" | IOSTANDARD="LVCMOS18";  # Bank 21, Vcco=1.8V, DCI using 49.9 ohm resistors
185 NET  gpio_led_4           LOC="G16";   # Bank 3, Vcco=2.5V, No DCI
186 NET  gpio_led_5           LOC="AD25" | IOSTANDARD="LVCMOS18";  # Bank 21, Vcco=1.8V, DCI using 49.9 ohm resistors
187 NET  gpio_led_6           LOC="AD24" | IOSTANDARD="LVCMOS18";  # Bank 21, Vcco=1.8V, DCI using 49.9 ohm resistors
188 NET  gpio_led_7           LOC="AE24" | IOSTANDARD="LVCMOS18";  # Bank 21, Vcco=1.8V, DCI using 49.9 ohm resistors
189
190
191
192
193
194 == Test ================================================================
195 #expect 25
196
197 #ship debug : Debug
198
199 debug.in:
200   set word= 25;
201   deliver;
202
203 == Contributors =========================================================
204 Adam Megacz <megacz@cs.berkeley.edu>