diff options
author | devantech <35335852+devantech@users.noreply.github.com> | 2019-03-27 14:30:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-27 14:30:28 +0000 |
commit | 5b58a7fb9d86544f22b0761fe30d21c6cd5a292a (patch) | |
tree | 8169bdfcf1e3183ec62131c82595d3fa6b287035 | |
parent | 4c807dfca679ee19a3017bf1dc1998640c225bd9 (diff) | |
download | iceFUN-5b58a7fb9d86544f22b0761fe30d21c6cd5a292a.tar.gz iceFUN-5b58a7fb9d86544f22b0761fe30d21c6cd5a292a.tar.bz2 iceFUN-5b58a7fb9d86544f22b0761fe30d21c6cd5a292a.zip |
Add files via upload
-rw-r--r-- | leds/Makefile | 22 | ||||
-rw-r--r-- | leds/iceFUN.pcf | 18 | ||||
-rw-r--r-- | leds/leds.v | 79 | ||||
-rw-r--r-- | leds/ledscan.v | 62 | ||||
-rw-r--r-- | leds/readMe | 8 |
5 files changed, 189 insertions, 0 deletions
diff --git a/leds/Makefile b/leds/Makefile new file mode 100644 index 0000000..428f691 --- /dev/null +++ b/leds/Makefile @@ -0,0 +1,22 @@ +# Project setup +PROJ = leds + +# Files +FILES = leds.v + +.PHONY: iceFUN clean burn + +iceFUN: + # synthesize using Yosys + yosys -p "synth_ice40 -top top -json $(PROJ).json" $(FILES) + # Place and route using nextpnr + nextpnr-ice40 -r --hx8k --json $(PROJ).json --package cb132 --asc $(PROJ).asc --opt-timing --pcf iceFUN.pcf + + # Convert to bitstream using IcePack + icepack $(PROJ).asc $(PROJ).bin + +burn: + iceFUNprog $(PROJ).bin + +clean: + rm *.asc *.bin *blif diff --git a/leds/iceFUN.pcf b/leds/iceFUN.pcf new file mode 100644 index 0000000..84583cb --- /dev/null +++ b/leds/iceFUN.pcf @@ -0,0 +1,18 @@ +# For iceFUN board + +set_io --warn-no-port led1 C10 +set_io --warn-no-port led2 A10 +set_io --warn-no-port led3 D7 +set_io --warn-no-port led4 D6 +set_io --warn-no-port led5 A7 +set_io --warn-no-port led6 C7 +set_io --warn-no-port led7 A4 +set_io --warn-no-port led8 C4 +set_io --warn-no-port lcol1 A12 +set_io --warn-no-port lcol2 D10 +set_io --warn-no-port lcol3 A6 +set_io --warn-no-port lcol4 C5 +set_io --warn-no-port spkp M12 +set_io --warn-no-port spkm M6 + +set_io --warn-no-port clk12MHz P7 diff --git a/leds/leds.v b/leds/leds.v new file mode 100644 index 0000000..f486019 --- /dev/null +++ b/leds/leds.v @@ -0,0 +1,79 @@ +/* + * + * Copyright(C) 2018 Gerald Coe, Devantech Ltd <gerry@devantech.co.uk> + * + * Permission to use, copy, modify, and/or distribute this software for any purpose with or + * without fee is hereby granted, provided that the above copyright notice and + * this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +`include "ledscan.v" + +module top ( + input clk12MHz, + output led1, + output led2, + output led3, + output led4, + output led5, + output led6, + output led7, + output led8, + output lcol1, + output lcol2, + output lcol3, + output lcol4 + ); + +// these are the led holding registers, whatever you write to these appears on the led display + reg [7:0] leds1; + reg [7:0] leds2; + reg [7:0] leds3; + reg [7:0] leds4; + +// The output from the ledscan module + wire [7:0] leds; + wire [3:0] lcol; + +// map the output of ledscan to the port pins + assign { led8, led7, led6, led5, led4, led3, led2, led1 } = leds[7:0]; + assign { lcol4, lcol3, lcol2, lcol1 } = lcol[3:0]; + +// Counter register + reg [31:0] counter = 32'b0; + +// instantiate the led scan module + LedScan scan ( + .clk12MHz(clk12MHz), + .leds1(leds1), + .leds2(leds2), + .leds3(leds3), + .leds4(leds4), + .leds(leds), + .lcol(lcol) + ); + + + // This is where you place data in the leds matrix for display. + // Here we put a counter on the 1st column and a simple pattern on the others + always @ (*) begin + leds1[7:0] = ~counter[28:21]; + leds2[7:0] = 8'b11111100; + leds3[7:0] = 8'b11100011; + leds4[7:0] = 8'b00111111; + end + +// increment the counter every clock, only the upper bits are mapped to the leds. + always @ (posedge clk12MHz) begin + counter <= counter + 1; + end + +endmodule diff --git a/leds/ledscan.v b/leds/ledscan.v new file mode 100644 index 0000000..dee7c7d --- /dev/null +++ b/leds/ledscan.v @@ -0,0 +1,62 @@ +/* + * + * Copyright(C) 2018 Gerald Coe, Devantech Ltd <gerry@devantech.co.uk> + * + * Permission to use, copy, modify, and/or distribute this software for any purpose with or + * without fee is hereby granted, provided that the above copyright notice and + * this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +// LedScan takes the four led columns as inputs and outputs them to the led matrix + +module LedScan ( + input clk12MHz, + input [7:0] leds1, + input [7:0] leds2, + input [7:0] leds3, + input [7:0] leds4, + output reg [7:0] leds, + output reg [3:0] lcol + ); + + + /* Counter register */ + reg [11:0] timer = 12'b0; + + + always @ (posedge clk12MHz) begin + case (timer[11:10]) + 2'b00: begin + leds[7:0] <= leds1[7:0]; + lcol[3:0] <= 4'b1110; + end + 2'b01: begin + leds[7:0] <= leds2[7:0]; + lcol[3:0] <= 4'b1101; + end + 2'b10: begin + leds[7:0] <= leds3[7:0]; + lcol[3:0] <= 4'b1011; + end + 2'b11: begin + leds[7:0] <= leds4[7:0]; + lcol[3:0] <= 4'b0111; + end + endcase + end + + +// increment the scan timer + always @ (posedge clk12MHz) begin + timer <= timer + 1; + end + +endmodule diff --git a/leds/readMe b/leds/readMe new file mode 100644 index 0000000..f26e94a --- /dev/null +++ b/leds/readMe @@ -0,0 +1,8 @@ +To build the leds project, install the icestorm toolchain from http://www.clifford.at/icestorm/ +and the iceFUN programmer from https://github.com/devantech/iceFUNprog + +Open a terminal in the leds folder and enter: +make iceFUN +make burn + + |