add software implementation of Button ship
[fleet.git] / ships / Button.ship
1 ship: Null
2
3 == Ports ===========================================================
4 data  out:  out
5
6 percolate down:  gpio_sw_c    1
7
8
9 == Constants ========================================================
10
11 == UCF ==============================================================================
12 NET  gpio_sw_c            LOC="AJ6" | IOSTANDARD="LVCMOS33";   # Bank 18, Vcco=3.3V, No DCI
13
14 == TeX ==============================================================
15 == Fleeterpreter ====================================================
16 public void service() {
17     if (!box_out.readyForDataFromShip()) return;
18     box_out.addDataFromShip(0);
19 }
20
21 == FleetSim ==============================================================
22
23 == FPGA ==============================================================
24
25   assign out_d_ = 0;
26   reg [20:0] count;
27   reg last_state;
28
29   always @(posedge clk) begin
30     if (rst) begin
31       `reset
32       last_state <= gpio_sw_c;
33     end else begin
34       `cleanup
35       if (count==0) begin
36         if (`out_empty && gpio_sw_c && !last_state) begin
37           `fill_out
38         end
39         count <= 51200;
40         last_state <= gpio_sw_c;
41       end else begin
42         count <= count-1;
43       end
44     end
45   end
46
47 == Test =================================================================
48
49 #skip
50 #expect 0
51
52 #ship button : Button
53 #ship debug : Debug
54
55 debug.in:
56   set ilc=*;
57   recv, deliver;
58
59 button.out:
60   collect, send to debug.in;
61
62 == Contributors =========================================================
63 Adam Megacz <megacz@cs.berkeley.edu>