1 from mibuild
.generic_platform
import *
2 from mibuild
.crg
import SimpleCRG
3 from mibuild
.xilinx_common
import CRG_DS
4 from mibuild
.xilinx_ise
import XilinxISEPlatform
5 from mibuild
.xilinx_vivado
import XilinxVivadoPlatform
6 from mibuild
.programmer
import *
9 with subprocess
.Popen("vivado -mode tcl", stdin
=subprocess
.PIPE
, shell
=True) as process
:
10 process
.stdin
.write(cmds
.encode("ASCII"))
13 class VivadoProgrammer(Programmer
):
14 needs_bitreverse
= False
16 def load_bitstream(self
, bitstream_file
):
19 open_hw_target [lindex [get_hw_targets -of_objects [get_hw_servers localhost]] 0]
21 set_property PROBES.FILE {{}} [lindex [get_hw_devices] 0]
22 set_property PROGRAM.FILE {{{bitstream}}} [lindex [get_hw_devices] 0]
24 program_hw_devices [lindex [get_hw_devices] 0]
25 refresh_hw_device [lindex [get_hw_devices] 0]
28 """.format(bitstream
=bitstream_file
)
31 def flash(self
, address
, data_file
):
32 raise NotImplementedError
35 ("user_led", 0, Pins("AB8"), IOStandard("LVCMOS15")),
36 ("user_led", 1, Pins("AA8"), IOStandard("LVCMOS15")),
37 ("user_led", 2, Pins("AC9"), IOStandard("LVCMOS15")),
38 ("user_led", 3, Pins("AB9"), IOStandard("LVCMOS15")),
39 ("user_led", 4, Pins("AE26"), IOStandard("LVCMOS25")),
40 ("user_led", 5, Pins("G19"), IOStandard("LVCMOS25")),
41 ("user_led", 6, Pins("E18"), IOStandard("LVCMOS25")),
42 ("user_led", 7, Pins("F16"), IOStandard("LVCMOS25")),
44 ("cpu_reset", 0, Pins("AB7"), IOStandard("LVCMOS15")),
47 Subsignal("p", Pins("AD12"), IOStandard("LVDS")),
48 Subsignal("n", Pins("AD11"), IOStandard("LVDS"))
52 Subsignal("p", Pins("K28"), IOStandard("LVDS_25")),
53 Subsignal("n", Pins("K29"), IOStandard("LVDS_25"))
58 Subsignal("cts", Pins("L27")),
59 Subsignal("rts", Pins("K23")),
60 Subsignal("tx", Pins("K24")),
61 Subsignal("rx", Pins("M19")),
62 IOStandard("LVCMOS25")
66 Subsignal("refclk_p", Pins("C8")),
67 Subsignal("refclk_n", Pins("C7")),
68 Subsignal("txp", Pins("D2")),
69 Subsignal("txn", Pins("D1")),
70 Subsignal("rxp", Pins("E4")),
71 Subsignal("rxn", Pins("E3")),
75 def Platform(*args
, toolchain
="vivado", programmer
="xc3sprog", **kwargs
):
76 if toolchain
== "ise":
77 xilinx_platform
= XilinxISEPlatform
78 elif toolchain
== "vivado":
79 xilinx_platform
= XilinxVivadoPlatform
83 class RealPlatform(xilinx_platform
):
84 bitgen_opt
= "-g LCK_cycle:6 -g Binary:Yes -w -g ConfigRate:12 -g SPI_buswidth:4"
86 def __init__(self
, crg_factory
=lambda p
: CRG_DS(p
, "clk200", "cpu_reset")):
87 xilinx_platform
.__init
__(self
, "xc7k325t-ffg900-2", _io
, crg_factory
)
89 def create_programmer(self
):
90 if programmer
== "xc3sprog":
91 return XC3SProg("jtaghs1_fast", "bscan_spi_kc705.bit")
92 elif programmer
== "vivado":
93 return VivadoProgrammer()
97 def do_finalize(self
, fragment
):
99 self
.add_period_constraint(self
.lookup_request("clk156").p
, 6.4)
100 except ConstraintError
:
103 self
.add_period_constraint(self
.lookup_request("clk200").p
, 5.0)
104 except ConstraintError
:
107 self
.add_period_constraint(self
.lookup_request("sata_host").refclk_p
, 6.66)
108 except ConstraintError
:
110 self
.add_platform_command("""
111 create_clock -name sys_clk -period 6 [get_nets sys_clk]
112 create_clock -name sata_rx_clk -period 3.33 [get_nets sata_rx_clk]
113 create_clock -name sata_tx_clk -period 3.33 [get_nets sata_tx_clk]
115 set_false_path -from [get_clocks sys_clk] -to [get_clocks sata_rx_clk]
116 set_false_path -from [get_clocks sys_clk] -to [get_clocks sata_tx_clk]
117 set_false_path -from [get_clocks sata_rx_clk] -to [get_clocks sys_clk]
118 set_false_path -from [get_clocks sata_tx_clk] -to [get_clocks sys_clk]
120 set_property CFGBVS VCCO [current_design]
121 set_property CONFIG_VOLTAGE 2.5 [current_design]
124 return RealPlatform(*args
, **kwargs
)