Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 6 files changed
  • 0 comments
  • 1 contributor
3  build.py
@@ -5,8 +5,9 @@
5 5
 from mibuild.platforms import m1
6 6
 from mibuild.tools import write_to_file
7 7
 
  8
+from milkymist import cif
  9
+
8 10
 import top
9  
-import cif
10 11
 
11 12
 def main():
12 13
 	platform = m1.Platform()
0  cif.py → milkymist/cif.py
File renamed without changes
17  milkymist/dvisampler/clocking.py
@@ -16,19 +16,6 @@ def __init__(self, pads):
16 16
 
17 17
 		###
18 18
 
19  
-		clk_dejitter = Signal()
20  
-		dcm_locked = Signal()
21  
-		self.specials += Instance("DCM_CLKGEN",
22  
-			Instance.Parameter("CLKIN_PERIOD", 26.7),
23  
-			Instance.Parameter("CLKFX_DIVIDE", 2),
24  
-			Instance.Parameter("CLKFX_MULTIPLY", 2),
25  
-			Instance.Parameter("CLKFX_MD_MAX", 1.0),
26  
-			Instance.Input("CLKIN", pads.clk),
27  
-			Instance.Input("RST", self._r_pll_reset.storage),
28  
-			Instance.Output("CLKFX", clk_dejitter),
29  
-			Instance.Output("LOCKED", dcm_locked)
30  
-		)
31  
-
32 19
 		clkfbout = Signal()
33 20
 		pll_locked = Signal()
34 21
 		pll_clk0 = Signal()
@@ -52,8 +39,8 @@ def __init__(self, pads):
52 39
 			Instance.Output("CLKOUT3", pll_clk3),
53 40
 			Instance.Output("LOCKED", pll_locked),
54 41
 			Instance.Input("CLKFBIN", clkfbout),
55  
-			Instance.Input("CLKIN", clk_dejitter),
56  
-			Instance.Input("RST", ~dcm_locked)
  42
+			Instance.Input("CLKIN", pads.clk),
  43
+			Instance.Input("RST", self._r_pll_reset.storage)
57 44
 		)
58 45
 
59 46
 		locked_async = Signal()
47  software/videomixer/dvisamplerX.c
@@ -106,11 +106,13 @@ void dvisamplerX_adjust_phase(void)
106 106
 	switch(dvisamplerX_data0_cap_phase_read()) {
107 107
 		case DVISAMPLER_TOO_LATE:
108 108
 			dvisamplerX_data0_cap_dly_ctl_write(DVISAMPLER_DELAY_DEC);
  109
+			while(dvisamplerX_data0_cap_dly_busy_read());
109 110
 			dvisamplerX_d0--;
110 111
 			dvisamplerX_data0_cap_phase_reset_write(1);
111 112
 			break;
112 113
 		case DVISAMPLER_TOO_EARLY:
113 114
 			dvisamplerX_data0_cap_dly_ctl_write(DVISAMPLER_DELAY_INC);
  115
+			while(dvisamplerX_data0_cap_dly_busy_read());
114 116
 			dvisamplerX_d0++;
115 117
 			dvisamplerX_data0_cap_phase_reset_write(1);
116 118
 			break;
@@ -118,11 +120,13 @@ void dvisamplerX_adjust_phase(void)
118 120
 	switch(dvisamplerX_data1_cap_phase_read()) {
119 121
 		case DVISAMPLER_TOO_LATE:
120 122
 			dvisamplerX_data1_cap_dly_ctl_write(DVISAMPLER_DELAY_DEC);
  123
+			while(dvisamplerX_data1_cap_dly_busy_read());
121 124
 			dvisamplerX_d1--;
122 125
 			dvisamplerX_data1_cap_phase_reset_write(1);
123 126
 			break;
124 127
 		case DVISAMPLER_TOO_EARLY:
125 128
 			dvisamplerX_data1_cap_dly_ctl_write(DVISAMPLER_DELAY_INC);
  129
+			while(dvisamplerX_data1_cap_dly_busy_read());
126 130
 			dvisamplerX_d1++;
127 131
 			dvisamplerX_data1_cap_phase_reset_write(1);
128 132
 			break;
@@ -130,11 +134,13 @@ void dvisamplerX_adjust_phase(void)
130 134
 	switch(dvisamplerX_data2_cap_phase_read()) {
131 135
 		case DVISAMPLER_TOO_LATE:
132 136
 			dvisamplerX_data2_cap_dly_ctl_write(DVISAMPLER_DELAY_DEC);
  137
+			while(dvisamplerX_data2_cap_dly_busy_read());
133 138
 			dvisamplerX_d2--;
134 139
 			dvisamplerX_data2_cap_phase_reset_write(1);
135 140
 			break;
136 141
 		case DVISAMPLER_TOO_EARLY:
137 142
 			dvisamplerX_data2_cap_dly_ctl_write(DVISAMPLER_DELAY_INC);
  143
+			while(dvisamplerX_data2_cap_dly_busy_read());
138 144
 			dvisamplerX_d2++;
139 145
 			dvisamplerX_data2_cap_phase_reset_write(1);
140 146
 			break;
@@ -158,13 +164,36 @@ int dvisamplerX_init_phase(void)
158 164
 	return 0;
159 165
 }
160 166
 
  167
+int dvisamplerX_phase_startup(void)
  168
+{
  169
+	int ret;
  170
+	int attempts;
  171
+
  172
+	attempts = 0;
  173
+	while(1) {
  174
+		attempts++;
  175
+		dvisamplerX_calibrate_delays();
  176
+		printf("dvisamplerX: delays calibrated\n");
  177
+		ret = dvisamplerX_init_phase();
  178
+		if(ret) {
  179
+			printf("dvisamplerX: phase init OK\n");
  180
+			return 1;
  181
+		} else {
  182
+			printf("dvisamplerX: phase did not settle\n");
  183
+			if(attempts > 3) {
  184
+				printf("dvisamplerX: giving up\n");
  185
+				dvisamplerX_calibrate_delays();
  186
+				return 0;
  187
+			}
  188
+		}
  189
+	}
  190
+}
  191
+
161 192
 static int dvisamplerX_locked;
162 193
 static int dvisamplerX_last_event;
163 194
 
164 195
 void dvisamplerX_service(void)
165 196
 {
166  
-	int ret;
167  
-
168 197
 	if(dvisamplerX_locked) {
169 198
 		if(dvisamplerX_clocking_locked_read()) {
170 199
 			if(elapsed(&dvisamplerX_last_event, identifier_frequency_read()/2)) {
@@ -178,21 +207,9 @@ void dvisamplerX_service(void)
178 207
 	} else {
179 208
 		if(dvisamplerX_clocking_locked_read()) {
180 209
 			printf("dvisamplerX: PLL locked\n");
181  
-			dvisamplerX_calibrate_delays();
182  
-			printf("dvisamplerX: delays calibrated\n");
183  
-			ret = dvisamplerX_init_phase();
184  
-			if(ret)
185  
-				printf("dvisamplerX: phase init OK\n");
186  
-			else
187  
-				printf("dvisamplerX: phase did not settle\n");
  210
+			dvisamplerX_phase_startup();
188 211
 			dvisamplerX_print_status();
189 212
 			dvisamplerX_locked = 1;
190  
-		} else {
191  
-			if(elapsed(&dvisamplerX_last_event, identifier_frequency_read()/4)) {
192  
-				dvisamplerX_clocking_pll_reset_write(1);
193  
-				while(!elapsed(&dvisamplerX_last_event, identifier_frequency_read()/16));
194  
-				dvisamplerX_clocking_pll_reset_write(0);
195  
-			}
196 213
 		}
197 214
 	}
198 215
 }
1  software/videomixer/dvisamplerX.h
@@ -7,6 +7,7 @@ void dvisamplerX_print_status(void);
7 7
 void dvisamplerX_calibrate_delays(void);
8 8
 void dvisamplerX_adjust_phase(void);
9 9
 int dvisamplerX_init_phase(void);
  10
+int dvisamplerX_phase_startup(void);
10 11
 void dvisamplerX_service(void);
11 12
 
12 13
 #endif
2  top.py
@@ -9,7 +9,7 @@
9 9
 from milkymist import m1crg, lm32, norflash, uart, s6ddrphy, dfii, asmicon, \
10 10
 	identifier, timer, minimac3, framebuffer, asmiprobe, dvisampler, \
11 11
 	counteradc, gpio
12  
-from cif import get_macros
  12
+from milkymist.cif import get_macros
13 13
 
14 14
 version = get_macros("common/version.h")["VERSION"][1:-1]
15 15
 

No commit comments for this range

Something went wrong with that request. Please try again.