import os import subprocess from migen.build.generic_programmer import GenericProgrammer from migen.build import tools # XXX Lattice programmer need an .xcf file, will need clean up and support for more parameters _xcf_template = """ JTAG 1 Lattice LatticeECP3 LFE3-35EA {bitstream_file} Fast Program SEQUENTIAL ENTIRED CHAIN No Override TLR TLR USB2 FTUSB-0 Dual RS232-HS A Location 0000 Serial A TRST ABSENT; ISPEN ABSENT; """ class LatticeProgrammer(GenericProgrammer): needs_bitreverse = False def load_bitstream(self, bitstream_file): xcf_file = bitstream_file.replace(".bit", ".xcf") xcf_content = _xcf_template.format(bitstream_file=bitstream_file) tools.write_to_file(xcf_file, xcf_content) subprocess.call(["pgrcmd", "-infile", xcf_file])