summaryrefslogtreecommitdiffstats
path: root/music/fpga4fun/simple_beep/top.v
diff options
context:
space:
mode:
authorHirosh Dabui <hirosh@dabui.de>2020-02-11 20:15:16 +0100
committerHirosh Dabui <hirosh@dabui.de>2020-02-12 00:10:35 +0100
commitbb6be8d6bf84071ad04247163932fecff500367e (patch)
treec19bd7534e29d89b120c910d598910399bdc7b95 /music/fpga4fun/simple_beep/top.v
parentf7210f49f67444b135ddc6e92da67fc533abba44 (diff)
downloadiceFUN-bb6be8d6bf84071ad04247163932fecff500367e.tar.gz
iceFUN-bb6be8d6bf84071ad04247163932fecff500367e.tar.bz2
iceFUN-bb6be8d6bf84071ad04247163932fecff500367e.zip
ported fpga fun music examples to iceFun. iceFun has built-in speakers.
Diffstat (limited to 'music/fpga4fun/simple_beep/top.v')
-rw-r--r--music/fpga4fun/simple_beep/top.v35
1 files changed, 35 insertions, 0 deletions
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