Skip to content

Commit 3248478

Browse files
committed
openflow: add set_oci and set_tools
1 parent 5a44906 commit 3248478

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

openflow/openflow.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,51 @@ def __init__(self, name='openflow', part='hx8k-ct256'):
2828
"""Class constructor."""
2929
self.name = name
3030
self.part = get_part(part)
31+
self.set_oci()
32+
self.set_tools()
33+
34+
def set_oci(self):
35+
"""Set the OCI engine."""
36+
self.oci = {
37+
'engine': 'docker',
38+
'volumes': ['$HOME:$HOME'],
39+
'work': '$PWD',
40+
'containers': {
41+
'ghdl': 'hdlc/ghdl:yosys',
42+
'yosys': 'hdlc/ghdl:yosys',
43+
'nextpnr-ice40': 'hdlc/nextpnr:ice40',
44+
'icetime': 'hdlc/icestorm',
45+
'icepack': 'hdlc/icestorm',
46+
'iceprog': 'hdlc/icestorm',
47+
'nextpnr-ecp5': 'hdlc/nextpnr:ecp5',
48+
'ecppack': 'hdlc/prjtrellis',
49+
'openocd': 'hdlc/prog'
50+
},
51+
'tools': {
52+
'ghdl': 'ghdl',
53+
'yosys': 'yosys',
54+
'nextpnr-ice40': 'nextpnr-ice40',
55+
'icetime': 'icetime',
56+
'icepack': 'icepack',
57+
'iceprog': 'iceprog',
58+
'nextpnr-ecp5': 'nextpnr-ecp5',
59+
'ecppack': 'ecppack',
60+
'openocd': 'openocd'
61+
}
62+
}
63+
64+
def set_tools(self):
65+
"""Set the underlying tools."""
66+
# Check if oci['engine'] is available
67+
engine = self.oci['engine']
68+
volumes = '-v ' + ('-v ').join(self.oci['volumes'])
69+
work = '-w ' + self.oci['work']
70+
command = '{} run --rm {} {}'.format(engine, volumes, work)
71+
self.tools = {}
72+
for tool in self.oci['tools']:
73+
self.tools[tool] = '{} {} {}'.format(
74+
command, self.oci['containers'][tool], self.oci['tools'][tool]
75+
)
3176

3277
# pylint: disable=too-many-arguments
3378
def synthesis(

0 commit comments

Comments
 (0)