Merge pull request #1274 from fjullien/fix_efinix_pll

Fix efinix pll
This commit is contained in:
enjoy-digital 2022-04-15 08:19:18 +02:00 committed by GitHub
commit 08cd4803f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 13 deletions

View File

@ -160,8 +160,8 @@ class EfinixPlatform(GenericPlatform):
def get_pll_resource(self, name): def get_pll_resource(self, name):
self.pll_used.append(name) self.pll_used.append(name)
self.pll_available.remove(name) self.pll_available.remove(name)
print('Pll used : ' + str(self.pll_used))
print('Pll pll_available: ' + str(self.pll_available))
def get_free_pll_resource(self): def get_free_pll_resource(self):
return self.pll_available[0] pll = self.pll_available[0]
self.get_pll_resource(pll)
return pll

View File

@ -15,11 +15,20 @@ class Open(Signal): pass
# Efinix / TRIONPLL ---------------------------------------------------------------------------------- # Efinix / TRIONPLL ----------------------------------------------------------------------------------
class TRIONPLL(Module): class EFINIXPLL(Module):
nclkouts_max = 3 nclkouts_max = 3
def __init__(self, platform, n=0, version="V1_V2"): def __init__(self, platform, n=0, version="V1_V2"):
self.logger = logging.getLogger("TRIONPLL") self.logger = logging.getLogger("EFINIXPLL")
self.logger.info("Creating TRIONPLL.".format())
if version == "V1_V2":
self.type = "TRIONPLL"
elif version == "V3":
self.type = "TITANIUMPLL"
else:
self.logger.error("PLL version {} not supported".format(version))
quit()
self.logger.info("Creating {}".format(colorer(self.type, color="green")))
self.platform = platform self.platform = platform
self.nclkouts = 0 self.nclkouts = 0
self.reset = Signal() self.reset = Signal()
@ -76,11 +85,14 @@ class TRIONPLL(Module):
block["input_signal"] = name block["input_signal"] = name
self.logger.info("Clock source: {}".format(block["input_clock"])) self.logger.info("Clock source: {}".format(block["input_clock"]))
self.logger.info("PLL used : " + colorer(str(self.platform.pll_used), "cyan"))
self.logger.info("PLL available: " + colorer(str(self.platform.pll_available), "cyan"))
block["input_freq"] = freq block["input_freq"] = freq
self.logger.info("Using {}".format(block["resource"])) self.logger.info("Use {}".format(colorer(block["resource"], "green")))
def create_clkout(self, cd, freq, phase=0, margin=1e-2, name="", with_reset=True): def create_clkout(self, cd, freq, phase=0, margin=0, name="", with_reset=True):
assert self.nclkouts < self.nclkouts_max assert self.nclkouts < self.nclkouts_max
clk_out_name = f"{self.name}_clkout{self.nclkouts}" if name == "" else name clk_out_name = f"{self.name}_clkout{self.nclkouts}" if name == "" else name
@ -92,7 +104,8 @@ class TRIONPLL(Module):
if with_reset: if with_reset:
self.specials += AsyncResetSynchronizer(cd, ~self.locked) self.specials += AsyncResetSynchronizer(cd, ~self.locked)
self.platform.toolchain.excluded_ios.append(clk_out_name) self.platform.toolchain.excluded_ios.append(clk_out_name)
create_clkout_log(self.logger, cd.name, freq, margin, self.nclkouts)
create_clkout_log(self.logger, clk_out_name, freq, margin, self.nclkouts)
self.nclkouts += 1 self.nclkouts += 1
@ -112,10 +125,16 @@ class TRIONPLL(Module):
def do_finalize(self): def do_finalize(self):
pass pass
# Efinix / TITANIUMPLL -----------------------------------------------------------------------------
# Efinix / TITANIUMPLL ---------------------------------------------------------------------------------- class TITANIUMPLL(EFINIXPLL):
class TITANIUMPLL(TRIONPLL):
nclkouts_max = 5 nclkouts_max = 5
def __init__(self, platform, n=0): def __init__(self, platform, n=0):
TRIONPLL.__init__(self, platform, n, version="V3") EFINIXPLL.__init__(self, platform, n, version="V3")
# Efinix / TRION ----------------------------------------------------------------------------------
class TRIONPLL(EFINIXPLL):
nclkouts_max = 3
def __init__(self, platform, n=0):
EFINIXPLL.__init__(self, platform, n, version="V1_V2")