forked from timvideos/litex-buildenv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.py
executable file
·39 lines (32 loc) · 874 Bytes
/
load.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import sys
import os
cmd, prog = sys.argv[:2]
if len(sys.argv) == 3:
fname = sys.argv[2]
else:
p = os.environ['PLATFORM']
t = os.environ['TARGET']
c = os.environ['CPU']
try:
v = os.environ['CPU_VARIANT']
v = "." + v
except:
v =""
pass
fname = "build/{p}_{t}_{c}{v}/gateware/{p}.bit".format(
p=p, t=t, c=c,v=v)
print("fname: ",fname)
if prog == 'ise':
from litex.build.xilinx import iMPACT
prog = iMPACT()
elif prog == 'vivado':
from litex.build.xilinx import VivadoProgrammer
prog = VivadoProgrammer()
else:
raise SystemError('Unknown programmer {}'.format(prog))
if not os.path.exists(fname):
raise SystemError('File {} not found'.format(fname))
if not fname.endswith('.bit'):
raise SystemError('Use the .bit file')
prog.load_bitstream(fname)