litex/build: move xcf_template to platform (xcf is specific to platform)
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 2 Dec 2016 16:23:40 +0000 (17:23 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 2 Dec 2016 16:23:40 +0000 (17:23 +0100)
litex/boards/platforms/versa.py
litex/build/lattice/programmer.py

index e1a0cf5faf4f19a151838d995938bcb620d362a8..ca9b6bd03c7a525d72db49000b170e13ba1e30c4 100644 (file)
@@ -92,5 +92,43 @@ class Platform(LatticePlatform):
             self.add_period_constraint(self.lookup_request("eth_clocks", 1).rx, 8.0)
         except ConstraintError:
             pass
+
     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)
index 94726d22aedef3d4d389c45ab9cfbc08c837a333..a34af86b38f4f86bd947312ad1052c12ce8fac10 100644 (file)
@@ -5,50 +5,14 @@ from litex.build.generic_programmer import GenericProgrammer
 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):
     needs_bitreverse = False
 
+    def __init__(self, xcf_template):
+        self.xcf_template = xcf_template
+
     def load_bitstream(self, bitstream_file):
         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)
         subprocess.call(["pgrcmd", "-infile", xcf_file])