2015-09-10 13:53:15 -04:00
|
|
|
from migen.build.generic_platform import GenericPlatform
|
|
|
|
from migen.build.altera import common, quartus
|
2015-03-16 15:44:29 -04:00
|
|
|
|
2015-04-13 14:45:35 -04:00
|
|
|
|
2015-03-16 15:44:29 -04:00
|
|
|
class AlteraPlatform(GenericPlatform):
|
2015-04-13 14:07:07 -04:00
|
|
|
bitstream_ext = ".sof"
|
2015-03-16 15:44:29 -04:00
|
|
|
|
2015-04-13 14:07:07 -04:00
|
|
|
def __init__(self, *args, toolchain="quartus", **kwargs):
|
|
|
|
GenericPlatform.__init__(self, *args, **kwargs)
|
|
|
|
if toolchain == "quartus":
|
|
|
|
self.toolchain = quartus.AlteraQuartusToolchain()
|
|
|
|
else:
|
|
|
|
raise ValueError("Unknown toolchain")
|
2015-03-16 15:44:29 -04:00
|
|
|
|
2015-04-13 14:07:07 -04:00
|
|
|
def get_verilog(self, *args, special_overrides=dict(), **kwargs):
|
|
|
|
so = dict(common.altera_special_overrides)
|
|
|
|
so.update(special_overrides)
|
2015-04-20 04:03:08 -04:00
|
|
|
return GenericPlatform.get_verilog(self, *args, special_overrides=so,
|
|
|
|
**kwargs)
|
2015-03-16 15:44:29 -04:00
|
|
|
|
2015-04-13 14:07:07 -04:00
|
|
|
def build(self, *args, **kwargs):
|
|
|
|
return self.toolchain.build(self, *args, **kwargs)
|
2015-03-16 15:44:29 -04:00
|
|
|
|
2015-04-13 14:07:07 -04:00
|
|
|
def add_period_constraint(self, clk, period):
|
|
|
|
if hasattr(clk, "p"):
|
|
|
|
clk = clk.p
|
|
|
|
self.toolchain.add_period_constraint(self, clk, period)
|