== Fleeterpreter ====================================================
public void service() {
if (box_in.dataReadyForShip())
- ((Interpreter)getFleet()).debug(box_in.removeDataForShip());
+ ((Interpreter)getFleet()).debug(new BitVector(37).set(box_in.removeDataForShip()));
}
== FleetSim ==============================================================
== FPGA ==============================================================
wire break_i;
- reg break_last;
reg send_k;
initial send_k = 0;
wire [7:0] data_to_fleet;
reg data_to_host_write_enable;
reg data_to_fleet_read_enable;
+ reg [7:0] force_reset;
wire sio_ce;
wire sio_ce_x4;
wire break;
wire uart_cts;
assign uart_cts = 0;
- assign rst_out = rst_in || break;
+ assign rst_out = rst_in || (force_reset!=0) /* || break */;
// fst=3 means clock divider is 3+2=5 for a 50Mhz clock => 10Mhz
// using a 33Mhz clock,
- // 33.333Mhz / 38400hz * 4 = 217.013 => 215+2,1
+ // 33.333Mhz / 38400hz * 4 = 217.013 => 215+2,1 => 215,1
+ // using a 100Mhz clock,
+ // 100Mhz / 38400hz * 4 = 651.039 => 215+2,3 => 215,3
+ // using a 100Mhz clock, 115200baud
+ // 100Mhz / 115200hz * 4 = 217.013 => 215+2,1 => 215,1
+// sasc_brg sasc_brg(clk, !rst_in, 215, 3, sio_ce, sio_ce_x4);
sasc_brg sasc_brg(clk, !rst_in, 215, 1, sio_ce, sio_ce_x4);
sasc_top sasc_top(clk, !rst_in,
uart_in,
break,
break_i);
- // break and break are _active high_
- always @(posedge clk) break_last <= break;
- assign break_i = break && !break_last;
- assign break_done = !break && break_last;
+ reg [16:0] credits;
// fpga -> host
always @(posedge clk) begin
- if (rst) begin
- count_in <= 0;
- count_out <= 0;
+ if (rst_in /* || break */) begin
+ count_in <= 0;
+ count_out <= 0;
+ force_reset <= 0;
+ credits = 0;
`reset
end else begin
// fpga -> host
data_to_host_write_enable <= 0;
- if (break_i) begin
- end else if (break_done) begin
+ if (force_reset == 1) begin
+ force_reset <= 0;
data_to_host_write_enable <= 1;
- data_to_host <= 111;
- send_k <= 1;
- end else if (send_k) begin
- data_to_host_write_enable <= 1;
- data_to_host <= 107;
- send_k <= 0;
+ credits = 0;
+ count_in <= 0;
+ count_out <= 0;
+ `reset
+ end else if (force_reset != 0) begin
+ force_reset <= force_reset-1;
end else if (count_out==0 && `in_full) begin
`drain_in
data_to_host_full_word <= in_d;
count_out <= 8;
- end else if (count_out!=0 && !data_to_host_full && !data_to_host_write_enable) begin
+ end else if (count_out!=0 && !data_to_host_full && !data_to_host_write_enable && credits!=0) begin
data_to_host <= { 2'b0, data_to_host_full_word[5:0] };
data_to_host_full_word <= (data_to_host_full_word >> 6);
data_to_host_write_enable <= 1;
count_out <= count_out-1;
+ credits = credits - 1;
end
// host -> fpga
data_to_fleet_read_enable <= 0;
- if (!data_to_fleet_empty && `out_empty && !data_to_fleet_read_enable) begin
- out_d <= { out_d[43:0], data_to_fleet[5:0] };
- data_to_fleet_read_enable <= 1;
- if (count_in==9) begin
- count_in <= 0;
- `fill_out
- end else begin
- count_in <= count_in+1;
- end
+ if (!data_to_fleet_empty && !data_to_fleet_read_enable) begin
+
+ // Note: if the switch fabric refuses to accept a new item,
+ // we can get deadlocked in a state where sending a reset
+ // code (2'b11) won't have any effect. Probably need to go
+ // back to using the break signal.
+
+ // command 0: data
+ if (data_to_fleet[7:6] == 2'b00 && `out_empty) begin
+ data_to_fleet_read_enable <= 1;
+ out_d <= { out_d[43:0], data_to_fleet[5:0] };
+ if (count_in==9) begin
+ count_in <= 0;
+ `fill_out
+ end else begin
+ count_in <= count_in+1;
+ end
+
+ // command 1: flow control credit
+ end else if (data_to_fleet[7:6] == 2'b01) begin
+ data_to_fleet_read_enable <= 1;
+ credits = credits + data_to_fleet[5:0];
+
+/*
+ // uncommenting this requires changing data_to_host_write_enable
+ // to a blocking assignment, and seems to cause data loss whenever
+ // more than four items are in flight.
+ // command 2: echo
+ end else if (data_to_fleet[7:6] == 2'b10 && !data_to_host_full && !data_to_host_write_enable) begin
+ data_to_fleet_read_enable <= 1;
+ data_to_host <= data_to_fleet;
+ data_to_host_write_enable = 1;
+*/
+
+ // command 3: reset (and echo back reset code)
+ end else if (data_to_fleet[7:6] == 2'b11) begin
+ data_to_fleet_read_enable <= 1;
+ data_to_host <= data_to_fleet;
+ force_reset <= 255;
+
+ end
+
end
end
Net uart_out TIG;
Net uart_out PULLUP;
-NET gpio_sw_c LOC="AJ6"; # Bank 18, Vcco=3.3V, No DCI
-
-NET gpio_led_c LOC="E8"; # Bank 20, Vcco=3.3V, DCI using 49.9 ohm resistors
-NET gpio_led_e LOC="AG23"; # Bank 2, Vcco=3.3V
-NET gpio_led_n LOC="AF13"; # Bank 2, Vcco=3.3V
-NET gpio_led_s LOC="AG12"; # Bank 2, Vcco=3.3V
-NET gpio_led_w LOC="AF23"; # Bank 2, Vcco=3.3V
-
-NET gpio_led_0 LOC="H18"; # Bank 3, Vcco=2.5V, No DCI
-NET gpio_led_1 LOC="L18"; # Bank 3, Vcco=2.5V, No DCI
-NET gpio_led_2 LOC="G15"; # Bank 3, Vcco=2.5V, No DCI
-NET gpio_led_3 LOC="AD26" | IOSTANDARD="LVCMOS18"; # Bank 21, Vcco=1.8V, DCI using 49.9 ohm resistors
-NET gpio_led_4 LOC="G16"; # Bank 3, Vcco=2.5V, No DCI
-NET gpio_led_5 LOC="AD25" | IOSTANDARD="LVCMOS18"; # Bank 21, Vcco=1.8V, DCI using 49.9 ohm resistors
-NET gpio_led_6 LOC="AD24" | IOSTANDARD="LVCMOS18"; # Bank 21, Vcco=1.8V, DCI using 49.9 ohm resistors
-NET gpio_led_7 LOC="AE24" | IOSTANDARD="LVCMOS18"; # Bank 21, Vcco=1.8V, DCI using 49.9 ohm resistors
-