Skip to content

Commit adef3b2

Browse files
Jan Kowalewskiwhitequark
authored andcommitted
vendor.quicklogic: enable SoC clock configuration
Signed-off-by: Jan Kowalewski <jkowalewski@antmicro.com>
1 parent 36bc1d2 commit adef3b2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

nmigen/vendor/quicklogic.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,19 @@ class QuicklogicPlatform(TemplatedPlatform):
129129
python3 -m quicklogic_fasm.bitstream_to_openocd
130130
{{name}}.bit
131131
{{name}}.openocd
132+
--osc-freq {{platform.osc_freq}}
133+
--fpga-clk-divider {{platform.osc_div}}
132134
""",
133135
]
134136

135137
# Common logic
136138

139+
@property
140+
def default_clk_constraint(self):
141+
if self.default_clk == "sys_clk0":
142+
return Clock(self.osc_freq / self.osc_div)
143+
return super().default_clk_constraint
144+
137145
def add_clock_constraint(self, clock, frequency):
138146
super().add_clock_constraint(clock, frequency)
139147
clock.attrs["keep"] = "TRUE"
@@ -142,6 +150,20 @@ def create_missing_domain(self, name):
142150
if name == "sync" and self.default_clk is not None:
143151
m = Module()
144152
if self.default_clk == "sys_clk0":
153+
if not hasattr(self, "osc_div"):
154+
raise ValueError("OSC divider (osc_div) must be an integer between 2 "
155+
"and 512")
156+
if not isinstance(self.osc_div, int) or self.osc_div < 2 or self.osc_div > 512:
157+
raise ValueError("OSC divider (osc_div) must be an integer between 2 "
158+
"and 512, not {!r}"
159+
.format(self.osc_div))
160+
if not hasattr(self, "osc_freq"):
161+
raise ValueError("OSC frequency (osc_freq) must be an integer between 2100000 "
162+
"and 80000000")
163+
if not isinstance(self.osc_freq, int) or self.osc_freq < 2100000 or self.osc_freq > 80000000:
164+
raise ValueError("OSC frequency (osc_freq) must be an integer between 2100000 "
165+
"and 80000000, not {!r}"
166+
.format(self.osc_freq))
145167
clk_i = Signal()
146168
sys_clk0 = Signal()
147169
m.submodules += Instance("qlal4s3b_cell_macro",

0 commit comments

Comments
 (0)