-
Notifications
You must be signed in to change notification settings - Fork 15
/
TestUart.v
142 lines (122 loc) · 3.51 KB
/
TestUart.v
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// blinking _led.v
//////////////////////// LED Blinker Using On-Chip Osc /////////////////////////////
//***********************************************************************
// FileName: blinking _led.v
// FPGA: MachXO2 7000HE
// IDE: Diamond 2.0.1
//
// HDL IS PROVIDED "AS IS." DIGI-KEY EXPRESSLY DISCLAIMS ANY
// WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL DIGI-KEY
// BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL
// DAMAGES, LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
// PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
// BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
// ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS.
// DIGI-KEY ALSO DISCLAIMS ANY LIABILITY FOR PATENT OR COPYRIGHT
// INFRINGEMENT.
//
// Version History
// Version 1.0 04/5/2013 Tony Storey
// Initial Public Release
// Small Footprint Button Debouncer
//// The default frequency is 2.08MHz. Supported frequencies (in MHz) include:
//// 2.08 4.16 8.31 15.65
//// 2.15 4.29 8.58 16.63
//// 2.22 4.43 8.87 17.73
//// 2.29 4.59 9.17 19.00
//// 2.38 4.75 9.50 20.46
//// 2.46 4.93 9.85 22.17
//// 2.56 5.12 10.23 24.18
//// 2.66 5.32 10.64 26.60
//// 2.77 5.54 11.08 29.56
//// 2.89 5.78 11.57 33.25
//// 3.02 6.05 12.09 38.00
//// 3.17 6.33 12.67 44.33
//// 3.33 6.65 13.30 53.20
//// 3.50 7.00 14.00 66.50
//// 3.69 7.39 14.78 88.67
//// 3.91 7.82 15.65 133.00
module blinking_led
(
output reg [7:0] MYLED,
input wire In0,
input wire osc_clk
);
//// ---------------- internal constants --------------
parameter N= 28; // sets counter size
////---------------- internal variables ---------------
reg [N-1 : 0] count;
reg Bit0;
//// ------------------------------------------------------
/*//// Internal Oscillator
defparam OSCH_inst.NOM_FREQ = "133.00";
OSCH OSCH_inst
(
.STDBY(1'b0), // 0=Enabled, 1=Disabled also Disabled with Bandgap=OFF
.OSC(osc_clk),
.SEDSTDBY() // this signal is not required if not using SED
);
*/
//// counter with no flag control
always @ (posedge osc_clk)
begin
if(count < {8'h 79, {N-7{1'h 0}}})
begin
count <= count + 1'b1;
end
else
begin
count <= {N {1'h0} };
end
end
////4-8 data encoder ROM
always @ ( count[N-1:N-2] )
begin
case( count[N-1:N-2])
2'b 01 :
begin
MYLED[3:0] <= ~4'b 1000;
Bit0 <=1'b1;
end
2'b 10 :
begin
MYLED[3:0] <= ~4'b 1010;
Bit0 <=1'b0;
end
2'b 11 :
begin
MYLED[3:0] <= ~4'b 1110;
Bit0 <=1'b0;
end
2'b 00 :
begin
MYLED[3:0] <= ~4'b 1111;
Bit0 <=1'b0;
end
default :
begin
MYLED[3:0] <= ~4'b 0000;
Bit0 <=1'b0;
end
endcase
MYLED[4] <= 1'b 0;
MYLED[5] <= 1'b 0;
end
always @ (posedge osc_clk)
begin
if(Bit0 ==1'b1)
begin
MYLED[7] <= 1'b1;
end
else
begin
MYLED[7] <= 1'b0;
end
end
always @ (posedge osc_clk)
begin
MYLED[6] <= In0;
end
endmodule