aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2017-09-14 19:09:52 +0200
committerClifford Wolf <clifford@clifford.at>2017-09-14 19:09:52 +0200
commit5c4d4db08d39673b98ce953f1ab1d1368eeb2f44 (patch)
tree4f449b7cf9b88b48156ee503f14d486845b8bbdb /examples
parentd0f5b2ee8efd4c6babab101f68087f8339138317 (diff)
downloadicestorm-5c4d4db08d39673b98ce953f1ab1d1368eeb2f44.tar.gz
icestorm-5c4d4db08d39673b98ce953f1ab1d1368eeb2f44.tar.bz2
icestorm-5c4d4db08d39673b98ce953f1ab1d1368eeb2f44.zip
Add icemulti example
Diffstat (limited to 'examples')
-rw-r--r--examples/icemulti/.gitignore4
-rw-r--r--examples/icemulti/Makefile20
-rw-r--r--examples/icemulti/README6
-rw-r--r--examples/icemulti/app0.v28
-rw-r--r--examples/icemulti/app1.v28
-rw-r--r--examples/icemulti/app2.v28
-rw-r--r--examples/icemulti/app3.v28
-rw-r--r--examples/icemulti/icestick.pcf11
8 files changed, 153 insertions, 0 deletions
diff --git a/examples/icemulti/.gitignore b/examples/icemulti/.gitignore
new file mode 100644
index 0000000..5ae574e
--- /dev/null
+++ b/examples/icemulti/.gitignore
@@ -0,0 +1,4 @@
+/app?.asc
+/app?.bin
+/app?.blif
+/config.bin
diff --git a/examples/icemulti/Makefile b/examples/icemulti/Makefile
new file mode 100644
index 0000000..d8a8320
--- /dev/null
+++ b/examples/icemulti/Makefile
@@ -0,0 +1,20 @@
+prog: config.bin
+ sudo iceprog config.bin
+
+sudo-prog: config.bin
+ @echo 'Executing prog as root!!!'
+ sudo iceprog config.bin
+
+config.bin: app0.bin app1.bin app2.bin app3.bin
+ icemulti -v -A16 -p0 -o config.bin app0.bin app1.bin app2.bin app3.bin
+
+app%.bin: app%.v icestick.pcf
+ yosys -p "synth_ice40 -top top -blif $(basename $<).blif" $<
+ arachne-pnr -o $(basename $<).asc -d 1k -P tq144 -p icestick.pcf $(basename $<).blif
+ icetime -d hx1k -c 25 $(basename $<).asc
+ icepack $(basename $<).asc $(basename $<).bin
+
+clean:
+ rm -f app?.asc app?.bin app?.blif config.bin
+
+.PHONY: prog sudo-prog clean
diff --git a/examples/icemulti/README b/examples/icemulti/README
new file mode 100644
index 0000000..8056e90
--- /dev/null
+++ b/examples/icemulti/README
@@ -0,0 +1,6 @@
+
+A simple example for icemulti using the iCEstick dev board.
+
+Each of the four images blinks another LED. After 7 blinks
+the next image is loaded automatically.
+
diff --git a/examples/icemulti/app0.v b/examples/icemulti/app0.v
new file mode 100644
index 0000000..46833cc
--- /dev/null
+++ b/examples/icemulti/app0.v
@@ -0,0 +1,28 @@
+module top (
+ input clk,
+ output LED1, LED2, LED3, LED4, LED5
+);
+ localparam LOG2DELAY = 22;
+
+ reg [LOG2DELAY-1:0] counter = 0;
+ reg [3:0] counter2 = 0;
+ reg state = 0;
+
+ always @(posedge clk) begin
+ counter <= counter + 1;
+ counter2 <= counter2 + !counter;
+ state <= state ^ !counter;
+ end
+
+ assign LED1 = state;
+ assign LED2 = 0;
+ assign LED3 = 0;
+ assign LED4 = 0;
+ assign LED5 = 1;
+
+ SB_WARMBOOT WB (
+ .BOOT(&counter2),
+ .S1(1'b 0),
+ .S0(1'b 1)
+ );
+endmodule
diff --git a/examples/icemulti/app1.v b/examples/icemulti/app1.v
new file mode 100644
index 0000000..ac863ce
--- /dev/null
+++ b/examples/icemulti/app1.v
@@ -0,0 +1,28 @@
+module top (
+ input clk,
+ output LED1, LED2, LED3, LED4, LED5
+);
+ localparam LOG2DELAY = 22;
+
+ reg [LOG2DELAY-1:0] counter = 0;
+ reg [3:0] counter2 = 0;
+ reg state = 0;
+
+ always @(posedge clk) begin
+ counter <= counter + 1;
+ counter2 <= counter2 + !counter;
+ state <= state ^ !counter;
+ end
+
+ assign LED1 = 0;
+ assign LED2 = state;
+ assign LED3 = 0;
+ assign LED4 = 0;
+ assign LED5 = 1;
+
+ SB_WARMBOOT WB (
+ .BOOT(&counter2),
+ .S1(1'b 1),
+ .S0(1'b 0)
+ );
+endmodule
diff --git a/examples/icemulti/app2.v b/examples/icemulti/app2.v
new file mode 100644
index 0000000..d4866f7
--- /dev/null
+++ b/examples/icemulti/app2.v
@@ -0,0 +1,28 @@
+module top (
+ input clk,
+ output LED1, LED2, LED3, LED4, LED5
+);
+ localparam LOG2DELAY = 22;
+
+ reg [LOG2DELAY-1:0] counter = 0;
+ reg [3:0] counter2 = 0;
+ reg state = 0;
+
+ always @(posedge clk) begin
+ counter <= counter + 1;
+ counter2 <= counter2 + !counter;
+ state <= state ^ !counter;
+ end
+
+ assign LED1 = 0;
+ assign LED2 = 0;
+ assign LED3 = state;
+ assign LED4 = 0;
+ assign LED5 = 1;
+
+ SB_WARMBOOT WB (
+ .BOOT(&counter2),
+ .S1(1'b 1),
+ .S0(1'b 1)
+ );
+endmodule
diff --git a/examples/icemulti/app3.v b/examples/icemulti/app3.v
new file mode 100644
index 0000000..0103b06
--- /dev/null
+++ b/examples/icemulti/app3.v
@@ -0,0 +1,28 @@
+module top (
+ input clk,
+ output LED1, LED2, LED3, LED4, LED5
+);
+ localparam LOG2DELAY = 22;
+
+ reg [LOG2DELAY-1:0] counter = 0;
+ reg [3:0] counter2 = 0;
+ reg state = 0;
+
+ always @(posedge clk) begin
+ counter <= counter + 1;
+ counter2 <= counter2 + !counter;
+ state <= state ^ !counter;
+ end
+
+ assign LED1 = 0;
+ assign LED2 = 0;
+ assign LED3 = 0;
+ assign LED4 = state;
+ assign LED5 = 1;
+
+ SB_WARMBOOT WB (
+ .BOOT(&counter2),
+ .S1(1'b 0),
+ .S0(1'b 0)
+ );
+endmodule
diff --git a/examples/icemulti/icestick.pcf b/examples/icemulti/icestick.pcf
new file mode 100644
index 0000000..8bf462e
--- /dev/null
+++ b/examples/icemulti/icestick.pcf
@@ -0,0 +1,11 @@
+# full iCEstick pinout:
+# http://www.pighixxx.com/test/portfolio-items/icestick/
+
+set_io --warn-no-port RX 9
+set_io --warn-no-port TX 8
+set_io LED1 99
+set_io LED2 98
+set_io LED3 97
+set_io LED4 96
+set_io LED5 95
+set_io clk 21