Skip to content

Commit ebbdac9

Browse files
authored
vendor.intel: add support for Cyclone V internal oscillator
When using the default clock "cyclonev_oscillator" on Cyclone V devices, the internal oscillator will be used.
1 parent bde37fe commit ebbdac9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

nmigen/vendor/intel.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,31 @@ def add_clock_constraint(self, clock, frequency):
146146
super().add_clock_constraint(clock, frequency)
147147
clock.attrs["keep"] = "true"
148148

149+
@property
150+
def default_clk_constraint(self):
151+
# Internal high-speed oscillator on Cyclone V devices.
152+
# It is specified to not be faster than 100MHz, but the actual
153+
# frequency seems to vary a lot between devices. Measurements
154+
# of 78 to 84 MHz have been observed.
155+
if self.default_clk == "cyclonev_oscillator":
156+
assert self.device.startswith("5C")
157+
return Clock(100e6)
158+
# Otherwise, use the defined Clock resource.
159+
return super().default_clk_constraint
160+
161+
def create_missing_domain(self, name):
162+
if name == "sync" and self.default_clk == "cyclonev_oscillator":
163+
# Use the internal high-speed oscillator for Cyclone V devices
164+
assert self.device.startswith("5C")
165+
m = Module()
166+
m.domains += ClockDomain("sync")
167+
m.submodules += Instance("cyclonev_oscillator",
168+
i_oscena=Const(1),
169+
o_clkout=ClockSignal("sync"))
170+
return m
171+
else:
172+
return super().create_missing_domain(name)
173+
149174
# The altiobuf_* and altddio_* primitives are explained in the following Intel documents:
150175
# * https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/ug/ug_altiobuf.pdf
151176
# * https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/ug/ug_altddio.pdf

0 commit comments

Comments
 (0)