aboutsummaryrefslogtreecommitdiffstats
path: root/examples/iceblink/example.v
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2016-01-31 16:22:51 +0100
committerClifford Wolf <clifford@clifford.at>2016-01-31 16:22:51 +0100
commit6470f00ce49eecf12ac9692652b37d244d468034 (patch)
treea052afe5cd645974a21463549677b329c5b8cfcc /examples/iceblink/example.v
parent4fb1bfd2df4188a9563c4b9cbca1355ae4339f56 (diff)
parent438c0b55aea79da73f9be6ace4ddf2b77b749774 (diff)
downloadicestorm-6470f00ce49eecf12ac9692652b37d244d468034.tar.gz
icestorm-6470f00ce49eecf12ac9692652b37d244d468034.tar.bz2
icestorm-6470f00ce49eecf12ac9692652b37d244d468034.zip
Merge pull request #26 from kraiskil/master
Two small improvements.
Diffstat (limited to 'examples/iceblink/example.v')
-rw-r--r--examples/iceblink/example.v24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/iceblink/example.v b/examples/iceblink/example.v
new file mode 100644
index 0000000..6bccc1e
--- /dev/null
+++ b/examples/iceblink/example.v
@@ -0,0 +1,24 @@
+/* Binary counter displayed on LEDs (the 4 green ones on the right).
+ * Changes value about once a second.
+ */
+module top (
+ input clk,
+ output LED2,
+ output LED3,
+ output LED4,
+ output LED5
+);
+
+ localparam BITS = 4;
+ localparam LOG2DELAY = 22;
+
+ reg [BITS+LOG2DELAY-1:0] counter = 0;
+ reg [BITS-1:0] outcnt;
+
+ always@(posedge clk) begin
+ counter <= counter + 1;
+ outcnt <= counter >> LOG2DELAY;
+ end
+
+ assign {LED2, LED3, LED4, LED5} = outcnt;
+endmodule