openfpgaloader: add cable and freq options

This commit is contained in:
Gwenhael Goavec-Merou 2021-07-14 16:48:29 +02:00
parent 756503ab92
commit c984a4dbc8
1 changed files with 14 additions and 8 deletions

View File

@ -12,16 +12,22 @@ from litex.build.generic_programmer import GenericProgrammer
class OpenFPGALoader(GenericProgrammer): class OpenFPGALoader(GenericProgrammer):
needs_bitreverse = False needs_bitreverse = False
def __init__(self, board): def __init__(self, board="", cable="", freq=0):
self.board = board self.cmd = ["openFPGALoader"]
if board:
self.cmd += ["--board", board]
if cable:
self.cmd += ["--cable", cable]
if freq:
self.cmd += ["--freq", int(freq)]
def load_bitstream(self, bitstream_file): def load_bitstream(self, bitstream_file):
cmd = ["openFPGALoader", "--board", self.board, "--bitstream", bitstream_file] self.cmd += ["--bitstream", bitstream_file]
self.call(cmd) self.call(self.cmd)
def flash(self, address, data_file): def flash(self, address, data_file):
cmd = ["openFPGALoader", "--board", self.board, "--write-flash", "--bitstream", data_file] self.cmd += ["--write-flash", "--bitstream", data_file]
if address: if address:
cmd.append("--offset") self.cmd.append("--offset")
cmd.append(address) self.cmd.append(address)
self.call(cmd) self.call(self.cmd)