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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| module controller (clock, select, PWM_o, count, i);
input clock, select;
output reg PWM_o;
output reg [2:0] i = 0;
output reg [16:0] count = 0;
always @(posedge PWM_o)
if (PWM_o == 1) //Seperate counter that counts the amount of output pulses
begin //2 Pulses of each initial needed
i=i+1;
end
always @(posedge clock)
begin
count <= count+1; //Counter matches the input clock frequency, used to control the output pulses
end
always @(posedge count)
begin
if (select == 1) //Select chooses the PWM, 1 for Uppercase letters, 0 for Lowercase
begin
if (i<2) //Sets up loop conditions for first initial, so we get 2 pulses
begin
if (count < 65617) //Conditions for output wave, resulting in 2 pulses of 1.31ms
PWM_o <= 0;
else
PWM_o <= 1;
end
else
begin
if (count < 67024) //Conditions for output wave (pulse 2),second inital
PWM_o <= 0;
else
PWM_o <= 1;
end
if (i==4) //If 4 pulses have been completed, resets and starts pulsing again
begin
i = 0;
end
end
else //If select = 0, lowercase initials are used
begin
if (i<2) //Sets up loop conditions for first initial, so we get 2 pulses
begin
if (count < 72046) //Conditions for output wave, resulting in 2 pulses of 1.44ms
PWM_o <= 0;
else
PWM_o <= 1;
end
else
begin
if (count < 72993) //Conditions for output wave (pulse 2), second initial
PWM_o <= 0;
else
PWM_o <= 1;
end
if (i==4) //If 4 pulses have been completed, resets and starts pulsing again
begin
i = 0;
end
end
end
endmodule |