litex/build: move xcf_template to platform (xcf is specific to platform)

This commit is contained in:
Florent Kermarrec 2016-12-02 17:23:40 +01:00
parent daa9473809
commit 873e50430e
2 changed files with 43 additions and 41 deletions

View File

@ -92,5 +92,43 @@ class Platform(LatticePlatform):
self.add_period_constraint(self.lookup_request("eth_clocks", 1).rx, 8.0) self.add_period_constraint(self.lookup_request("eth_clocks", 1).rx, 8.0)
except ConstraintError: except ConstraintError:
pass pass
def create_programmer(self): def create_programmer(self):
return LatticeProgrammer() _xcf_template = """
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE ispXCF SYSTEM "IspXCF.dtd" >
<ispXCF version="3.4.1">
<Comment></Comment>
<Chain>
<Comm>JTAG</Comm>
<Device>
<SelectedProg value="TRUE"/>
<Pos>1</Pos>
<Vendor>Lattice</Vendor>
<Family>LatticeECP3</Family>
<Name>LFE3-35EA</Name>
<File>{bitstream_file}</File>
<Operation>Fast Program</Operation>
</Device>
</Chain>
<ProjectOptions>
<Program>SEQUENTIAL</Program>
<Process>ENTIRED CHAIN</Process>
<OperationOverride>No Override</OperationOverride>
<StartTAP>TLR</StartTAP>
<EndTAP>TLR</EndTAP>
<VerifyUsercode value="FALSE"/>
</ProjectOptions>
<CableOptions>
<CableName>USB2</CableName>
<PortAdd>FTUSB-0</PortAdd>
<USBID>Dual RS232-HS A Location 0000 Serial A</USBID>
<JTAGPinSetting>
TRST ABSENT;
ISPEN ABSENT;
</JTAGPinSetting>
</CableOptions>
</ispXCF>
"""
return LatticeProgrammer(_xcf_template)

View File

@ -5,50 +5,14 @@ from litex.build.generic_programmer import GenericProgrammer
from litex.build import tools from litex.build import tools
# XXX Lattice programmer need an .xcf file, will need clean up and support for more parameters
_xcf_template = """
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE ispXCF SYSTEM "IspXCF.dtd" >
<ispXCF version="3.4.1">
<Comment></Comment>
<Chain>
<Comm>JTAG</Comm>
<Device>
<SelectedProg value="TRUE"/>
<Pos>1</Pos>
<Vendor>Lattice</Vendor>
<Family>LatticeECP3</Family>
<Name>LFE3-35EA</Name>
<File>{bitstream_file}</File>
<Operation>Fast Program</Operation>
</Device>
</Chain>
<ProjectOptions>
<Program>SEQUENTIAL</Program>
<Process>ENTIRED CHAIN</Process>
<OperationOverride>No Override</OperationOverride>
<StartTAP>TLR</StartTAP>
<EndTAP>TLR</EndTAP>
<VerifyUsercode value="FALSE"/>
</ProjectOptions>
<CableOptions>
<CableName>USB2</CableName>
<PortAdd>FTUSB-0</PortAdd>
<USBID>Dual RS232-HS A Location 0000 Serial A</USBID>
<JTAGPinSetting>
TRST ABSENT;
ISPEN ABSENT;
</JTAGPinSetting>
</CableOptions>
</ispXCF>
"""
class LatticeProgrammer(GenericProgrammer): class LatticeProgrammer(GenericProgrammer):
needs_bitreverse = False needs_bitreverse = False
def __init__(self, xcf_template):
self.xcf_template = xcf_template
def load_bitstream(self, bitstream_file): def load_bitstream(self, bitstream_file):
xcf_file = bitstream_file.replace(".bit", ".xcf") xcf_file = bitstream_file.replace(".bit", ".xcf")
xcf_content = _xcf_template.format(bitstream_file=bitstream_file) xcf_content = self.xcf_template.format(bitstream_file=bitstream_file)
tools.write_to_file(xcf_file, xcf_content) tools.write_to_file(xcf_file, xcf_content)
subprocess.call(["pgrcmd", "-infile", xcf_file]) subprocess.call(["pgrcmd", "-infile", xcf_file])