summaryrefslogtreecommitdiffstats
path: root/music/fpga4fun/simple_beep
diff options
context:
space:
mode:
authordevantech <35335852+devantech@users.noreply.github.com>2020-02-12 10:45:55 +0000
committerGitHub <noreply@github.com>2020-02-12 10:45:55 +0000
commit074e43d92ac7de3fc8fb5ba6c4596c5cc58c4a0d (patch)
treec19bd7534e29d89b120c910d598910399bdc7b95 /music/fpga4fun/simple_beep
parentf7210f49f67444b135ddc6e92da67fc533abba44 (diff)
parentbb6be8d6bf84071ad04247163932fecff500367e (diff)
downloadiceFUN-074e43d92ac7de3fc8fb5ba6c4596c5cc58c4a0d.tar.gz
iceFUN-074e43d92ac7de3fc8fb5ba6c4596c5cc58c4a0d.tar.bz2
iceFUN-074e43d92ac7de3fc8fb5ba6c4596c5cc58c4a0d.zip
Merge pull request #2 from splinedrive/fpga4fun_music_box
ported fpga fun music examples to iceFun. iceFun has built-in speakers.
Diffstat (limited to 'music/fpga4fun/simple_beep')
-rw-r--r--music/fpga4fun/simple_beep/Makefile21
-rw-r--r--music/fpga4fun/simple_beep/iceFUN.pcf25
-rw-r--r--music/fpga4fun/simple_beep/top.v35
3 files changed, 81 insertions, 0 deletions
diff --git a/music/fpga4fun/simple_beep/Makefile b/music/fpga4fun/simple_beep/Makefile
new file mode 100644
index 0000000..52d9869
--- /dev/null
+++ b/music/fpga4fun/simple_beep/Makefile
@@ -0,0 +1,21 @@
+# Project setup
+PROJ = top
+
+# Files
+FILES = top.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 -f *.asc *.bin *.blif *.json
diff --git a/music/fpga4fun/simple_beep/iceFUN.pcf b/music/fpga4fun/simple_beep/iceFUN.pcf
new file mode 100644
index 0000000..5fb58d0
--- /dev/null
+++ b/music/fpga4fun/simple_beep/iceFUN.pcf
@@ -0,0 +1,25 @@
+# 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 key1 C11
+set_io --warn-no-port key2 C6
+set_io --warn-no-port key3 A11
+set_io --warn-no-port key4 A5
+set_io --warn-no-port red P14
+set_io --warn-no-port green N14
+set_io --warn-no-port blue L14
+
+set_io --warn-no-port clk12MHz P7
diff --git a/music/fpga4fun/simple_beep/top.v b/music/fpga4fun/simple_beep/top.v
new file mode 100644
index 0000000..069e4d1
--- /dev/null
+++ b/music/fpga4fun/simple_beep/top.v
@@ -0,0 +1,35 @@
+/*
+* (c) https://www.fpga4fun.com
+*
+ * ported to iceFun FPGA by Hirosh Dabui <hirosh@dabui.de>
+ */
+module top (
+ input clk12MHz,
+ output spkp,
+ output spkm
+);
+
+wire clk;
+assign spkp = speaker;
+assign spkm = ~speaker;
+// 25 MHz PLL
+SB_PLL40_CORE #(
+ .FEEDBACK_PATH("SIMPLE"),
+ .DIVR(4'b0000), // DIVR = 0
+ .DIVF(7'b1000010), // DIVF = 66
+ .DIVQ(3'b101), // DIVQ = 5
+ .FILTER_RANGE(3'b001) // FILTER_RANGE = 1
+) uut (
+ .LOCK(locked),
+ .RESETB(1'b1),
+ .BYPASS(1'b0),
+ .REFERENCECLK(clk12MHz),
+ .PLLOUTCORE(clk)
+);
+
+reg [15:0] counter;
+always @(posedge clk) counter <= counter+1;
+
+// and use the most significant bit (MSB) of the counter to drive the speaker
+ assign speaker = counter[15];
+endmodule