File: morse.v

package info (click to toggle)
prjtrellis 1.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,036 kB
  • sloc: cpp: 20,813; python: 16,246; sh: 375; makefile: 262; asm: 80; ansic: 58
file content (28 lines) | stat: -rw-r--r-- 568 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module top(input clk, output led);

	// HELLO
	// .... . .-.. .-.. ---
    // 10101 000 1 000 101110101 000 101110101 000 11101110111 00000000
	localparam pattern_len = 55;
	localparam pattern = 55'b00000000_11101110111_000_101011101_000_101011101_000_1_000_10101;

	reg [21:0] div = 0;

	always @ ( posedge clk ) begin
		div <= div + 1'b1;
	end

	reg [5:0] ctr = 0;
	always @(posedge clk) begin
		if (div == 0) begin
			if (ctr == pattern_len - 1) begin
				ctr <= 0;
			end else begin
				ctr <= ctr + 1'b1;
			end
		end
	end

	assign led = pattern[ctr];

endmodule