diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-02-06 14:57:28 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-02-06 15:02:16 +0100 |
commit | d3a753f7d747b007f464a831d6b2b21e87991e46 (patch) | |
tree | 3f20fd5c95294e4dd76ed628e602e5ba0316fbdf /examples/icebreaker/example.v | |
parent | 722790ad3cdb497e1b13cd1b4368d8380371eb37 (diff) | |
download | icestorm-d3a753f7d747b007f464a831d6b2b21e87991e46.tar.gz icestorm-d3a753f7d747b007f464a831d6b2b21e87991e46.tar.bz2 icestorm-d3a753f7d747b007f464a831d6b2b21e87991e46.zip |
Add icebreaker example project
Diffstat (limited to 'examples/icebreaker/example.v')
-rw-r--r-- | examples/icebreaker/example.v | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/icebreaker/example.v b/examples/icebreaker/example.v new file mode 100644 index 0000000..8985f9e --- /dev/null +++ b/examples/icebreaker/example.v @@ -0,0 +1,39 @@ +module top ( + input CLK, + + output LED1, + output LED2, + output LED3, + output LED4, + output LED5, + + input BTN_N, + input BTN1, + input BTN2, + input BTN3, + + output LEDR_N, + output LEDG_N, + + output P1A1, P1A2, P1A3, P1A4, P1A7, P1A8, P1A9, P1A10, + output P1B1, P1B2, P1B3, P1B4, P1B7, P1B8, P1B9, P1B10 +); + + localparam BITS = 5; + 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 {LED1, LED2, LED3, LED4, LED5} = outcnt ^ (outcnt >> 1); + + assign {LEDR_N, LEDG_N} = ~(!BTN_N + BTN1 + BTN2 + BTN3); + + assign {P1A1, P1A2, P1A3, P1A4, P1A7, P1A8, P1A9, P1A10, + P1B1, P1B2, P1B3, P1B4, P1B7, P1B8, P1B9, P1B10} = 1 << (outcnt & 15); +endmodule |