Skip to content

Commit 1ae1c50

Browse files
committed
Moved TOOLS and STEPS dictionaries inside the Factory and Project classes respectively
1 parent 1fe7d9c commit 1ae1c50

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

pyfpga/factory.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@
1818
from pyfpga.vivado import Vivado
1919

2020

21-
TOOLS = {
22-
'diamond': Diamond,
23-
'ise': Ise,
24-
'libero': Libero,
25-
'openflow': Openflow,
26-
'quartus': Quartus,
27-
'vivado': Vivado
28-
}
29-
30-
3121
class Factory:
3222
"""A factory class to create FPGA projects."""
3323

24+
TOOLS = {
25+
'diamond': Diamond,
26+
'ise': Ise,
27+
'libero': Libero,
28+
'openflow': Openflow,
29+
'quartus': Quartus,
30+
'vivado': Vivado
31+
}
32+
3433
def __init__(self, tool='vivado', project=None, odir='results'):
3534
"""Class constructor."""
36-
if tool not in TOOLS:
35+
if tool not in Factory.TOOLS:
3736
raise NotImplementedError(f'{tool} is unsupported')
38-
self._instance = TOOLS[tool](project, odir)
37+
self._instance = Factory.TOOLS[tool](project, odir)
3938

4039
def __getattr__(self, name):
4140
"""Delegate attribute access to the tool instance."""

pyfpga/project.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
from jinja2 import Environment, FileSystemLoader
1919

2020

21-
STEPS = {
22-
'cfg': 'Project Creation',
23-
'syn': 'Synthesis',
24-
'par': 'Place and Route',
25-
'bit': 'Bitstream generation'
26-
}
27-
28-
2921
class Project:
3022
"""Base class to manage an FPGA project.
3123
@@ -35,6 +27,13 @@ class Project:
3527
:type odir: str, optional
3628
"""
3729

30+
STEPS = {
31+
'cfg': 'Project Creation',
32+
'syn': 'Synthesis',
33+
'par': 'Place and Route',
34+
'bit': 'Bitstream generation'
35+
}
36+
3837
def __init__(self, project=None, odir='results'):
3938
"""Class constructor."""
4039
self.conf = {}
@@ -220,17 +219,17 @@ def make(self, first='cfg', last='bit'):
220219
.. note:: valid steps are ``cfg``, ``syn``, ``par`` and ``bit``.
221220
"""
222221
self.logger.debug('Executing make')
223-
if last not in STEPS:
222+
if last not in Project.STEPS:
224223
raise ValueError('Invalid last step.')
225-
if first not in STEPS:
224+
if first not in Project.STEPS:
226225
raise ValueError('Invalid first step.')
227-
keys = list(STEPS.keys())
226+
keys = list(Project.STEPS.keys())
228227
index = [keys.index(first), keys.index(last)]
229228
if index[0] > index[1]:
230229
raise ValueError('Invalid steps combination.')
231-
message = f'from {STEPS[first]} to {STEPS[last]}'
230+
message = f'from {Project.STEPS[first]} to {Project.STEPS[last]}'
232231
if first == last:
233-
message = STEPS[first]
232+
message = Project.STEPS[first]
234233
self.logger.info('Running %s', message)
235234
self.data['steps'] = keys[index[0]:index[1]+1]
236235
self._make_custom()

0 commit comments

Comments
 (0)