2014-09-22 06:33:23 -04:00
|
|
|
from mibuild.generic_platform import *
|
|
|
|
from mibuild.crg import SimpleCRG
|
|
|
|
from mibuild.xilinx_common import CRG_DS
|
|
|
|
from mibuild.xilinx_ise import XilinxISEPlatform
|
|
|
|
from mibuild.xilinx_vivado import XilinxVivadoPlatform
|
|
|
|
from mibuild.programmer import *
|
|
|
|
|
2014-12-17 06:07:11 -05:00
|
|
|
def _run_vivado(cmds):
|
|
|
|
with subprocess.Popen("vivado -mode tcl", stdin=subprocess.PIPE, shell=True) as process:
|
2014-09-22 06:33:23 -04:00
|
|
|
process.stdin.write(cmds.encode("ASCII"))
|
|
|
|
process.communicate()
|
|
|
|
|
2014-12-17 06:07:11 -05:00
|
|
|
class VivadoProgrammer(Programmer):
|
2014-09-22 06:33:23 -04:00
|
|
|
needs_bitreverse = False
|
|
|
|
|
|
|
|
def load_bitstream(self, bitstream_file):
|
2014-12-17 06:07:11 -05:00
|
|
|
cmds = """open_hw
|
|
|
|
connect_hw_server
|
|
|
|
open_hw_target [lindex [get_hw_targets -of_objects [get_hw_servers localhost]] 0]
|
|
|
|
|
|
|
|
set_property PROBES.FILE {{}} [lindex [get_hw_devices] 0]
|
|
|
|
set_property PROGRAM.FILE {{{bitstream}}} [lindex [get_hw_devices] 0]
|
|
|
|
|
|
|
|
program_hw_devices [lindex [get_hw_devices] 0]
|
|
|
|
refresh_hw_device [lindex [get_hw_devices] 0]
|
|
|
|
|
2014-09-22 06:33:23 -04:00
|
|
|
quit
|
|
|
|
""".format(bitstream=bitstream_file)
|
2014-12-17 06:07:11 -05:00
|
|
|
_run_vivado(cmds)
|
2014-09-22 06:33:23 -04:00
|
|
|
|
|
|
|
def flash(self, address, data_file):
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
_io = [
|
|
|
|
("user_led", 0, Pins("AB8"), IOStandard("LVCMOS15")),
|
|
|
|
("user_led", 1, Pins("AA8"), IOStandard("LVCMOS15")),
|
|
|
|
("user_led", 2, Pins("AC9"), IOStandard("LVCMOS15")),
|
|
|
|
("user_led", 3, Pins("AB9"), IOStandard("LVCMOS15")),
|
|
|
|
("user_led", 4, Pins("AE26"), IOStandard("LVCMOS25")),
|
|
|
|
("user_led", 5, Pins("G19"), IOStandard("LVCMOS25")),
|
|
|
|
("user_led", 6, Pins("E18"), IOStandard("LVCMOS25")),
|
|
|
|
("user_led", 7, Pins("F16"), IOStandard("LVCMOS25")),
|
2014-09-25 09:37:49 -04:00
|
|
|
|
2014-09-22 06:33:23 -04:00
|
|
|
("cpu_reset", 0, Pins("AB7"), IOStandard("LVCMOS15")),
|
2014-09-25 09:37:49 -04:00
|
|
|
|
2014-09-22 06:33:23 -04:00
|
|
|
("clk200", 0,
|
|
|
|
Subsignal("p", Pins("AD12"), IOStandard("LVDS")),
|
|
|
|
Subsignal("n", Pins("AD11"), IOStandard("LVDS"))
|
|
|
|
),
|
2014-09-25 09:37:49 -04:00
|
|
|
|
2014-09-22 06:33:23 -04:00
|
|
|
("clk156", 0,
|
|
|
|
Subsignal("p", Pins("K28"), IOStandard("LVDS_25")),
|
|
|
|
Subsignal("n", Pins("K29"), IOStandard("LVDS_25"))
|
|
|
|
),
|
2014-09-25 09:37:49 -04:00
|
|
|
|
|
|
|
|
2014-09-22 06:33:23 -04:00
|
|
|
("serial", 0,
|
|
|
|
Subsignal("cts", Pins("L27")),
|
|
|
|
Subsignal("rts", Pins("K23")),
|
|
|
|
Subsignal("tx", Pins("K24")),
|
|
|
|
Subsignal("rx", Pins("M19")),
|
2014-09-24 08:28:52 -04:00
|
|
|
IOStandard("LVCMOS25")
|
|
|
|
),
|
2014-09-25 09:37:49 -04:00
|
|
|
|
2015-01-19 12:40:32 -05:00
|
|
|
("sata", 0,
|
2014-10-24 06:29:29 -04:00
|
|
|
Subsignal("refclk_p", Pins("C8")),
|
|
|
|
Subsignal("refclk_n", Pins("C7")),
|
|
|
|
Subsignal("txp", Pins("D2")),
|
|
|
|
Subsignal("txn", Pins("D1")),
|
|
|
|
Subsignal("rxp", Pins("E4")),
|
|
|
|
Subsignal("rxn", Pins("E3")),
|
2014-09-25 09:37:49 -04:00
|
|
|
),
|
2014-09-22 06:33:23 -04:00
|
|
|
]
|
|
|
|
|
2014-10-24 06:29:29 -04:00
|
|
|
def Platform(*args, toolchain="vivado", programmer="xc3sprog", **kwargs):
|
2014-09-22 06:33:23 -04:00
|
|
|
if toolchain == "ise":
|
|
|
|
xilinx_platform = XilinxISEPlatform
|
|
|
|
elif toolchain == "vivado":
|
|
|
|
xilinx_platform = XilinxVivadoPlatform
|
|
|
|
else:
|
|
|
|
raise ValueError
|
|
|
|
|
|
|
|
class RealPlatform(xilinx_platform):
|
|
|
|
bitgen_opt = "-g LCK_cycle:6 -g Binary:Yes -w -g ConfigRate:12 -g SPI_buswidth:4"
|
|
|
|
|
2015-01-19 12:40:32 -05:00
|
|
|
def __init__(self, crg_factory=lambda p: CRG_DS(p, "clk200", "cpu_reset")):
|
2014-09-22 06:33:23 -04:00
|
|
|
xilinx_platform.__init__(self, "xc7k325t-ffg900-2", _io, crg_factory)
|
|
|
|
|
|
|
|
def create_programmer(self):
|
2014-10-24 06:29:29 -04:00
|
|
|
if programmer == "xc3sprog":
|
|
|
|
return XC3SProg("jtaghs1_fast", "bscan_spi_kc705.bit")
|
2014-12-17 06:07:11 -05:00
|
|
|
elif programmer == "vivado":
|
|
|
|
return VivadoProgrammer()
|
2014-10-24 06:29:29 -04:00
|
|
|
else:
|
|
|
|
raise ValueError
|
2014-09-22 06:33:23 -04:00
|
|
|
|
|
|
|
def do_finalize(self, fragment):
|
|
|
|
try:
|
|
|
|
self.add_period_constraint(self.lookup_request("clk156").p, 6.4)
|
|
|
|
except ConstraintError:
|
|
|
|
pass
|
|
|
|
try:
|
|
|
|
self.add_period_constraint(self.lookup_request("clk200").p, 5.0)
|
|
|
|
except ConstraintError:
|
2014-10-24 13:24:05 -04:00
|
|
|
pass
|
|
|
|
try:
|
|
|
|
self.add_period_constraint(self.lookup_request("sata_host").refclk_p, 6.66)
|
|
|
|
except ConstraintError:
|
|
|
|
pass
|
|
|
|
self.add_platform_command("""
|
2015-01-08 16:58:26 -05:00
|
|
|
create_clock -name sys_clk -period 6 [get_nets sys_clk]
|
2015-01-14 12:18:42 -05:00
|
|
|
create_clock -name sata_rx_clk -period 3.33 [get_nets sata_rx_clk]
|
|
|
|
create_clock -name sata_tx_clk -period 3.33 [get_nets sata_tx_clk]
|
2014-12-17 12:03:11 -05:00
|
|
|
|
|
|
|
set_false_path -from [get_clocks sys_clk] -to [get_clocks sata_rx_clk]
|
|
|
|
set_false_path -from [get_clocks sys_clk] -to [get_clocks sata_tx_clk]
|
|
|
|
set_false_path -from [get_clocks sata_rx_clk] -to [get_clocks sys_clk]
|
|
|
|
set_false_path -from [get_clocks sata_tx_clk] -to [get_clocks sys_clk]
|
|
|
|
|
|
|
|
set_property CFGBVS VCCO [current_design]
|
|
|
|
set_property CONFIG_VOLTAGE 2.5 [current_design]
|
2014-10-24 13:24:05 -04:00
|
|
|
""")
|
|
|
|
|
2014-09-22 06:33:23 -04:00
|
|
|
return RealPlatform(*args, **kwargs)
|