Skip to content

Commit 25e683c

Browse files
committed
Fix support for PolarFireSoC devices
1 parent 5c5c4f9 commit 25e683c

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed

examples/projects/libero.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
parser = argparse.ArgumentParser()
88
parser.add_argument(
9-
'--board', choices=['maker'], default='maker'
9+
'--board', choices=['mpfs-disco-kit', 'maker'], default='mpfs-disco-kit'
1010
)
1111
parser.add_argument(
1212
'--source', choices=['vlog', 'vhdl', 'slog'], default='vlog'
@@ -21,6 +21,13 @@
2121

2222
prj = Libero(odir=f'results/libero/{args.source}/{args.board}')
2323

24+
25+
if args.board == 'mpfs-disco-kit':
26+
prj.set_part('MPFS095T-1-FCSG325E')
27+
prj.add_param('FREQ', '50000000')
28+
prj.add_cons('../sources/cons/mpfs-disco-kit/timing.sdc')
29+
prj.add_cons('../sources/cons/mpfs-disco-kit/clk.pdc')
30+
prj.add_cons('../sources/cons/mpfs-disco-kit/led.pdc')
2431
if args.board == 'maker':
2532
prj.set_part('m2s010-1-tq144')
2633
prj.add_param('FREQ', '125000000')

pyfpga/libero.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ def _make_custom(self):
3131
self.data['device'] = info['device']
3232
self.data['speed'] = info['speed']
3333
self.data['package'] = info['package']
34+
self.data['prange'] = info['prange']
3435

3536
def _prog_custom(self):
36-
raise NotImplementedError('Libero programming not supported')
37+
raise NotImplementedError('Libero programming not supported yet')
3738

3839

3940
# pylint: disable=duplicate-code
@@ -42,7 +43,7 @@ def get_info(part):
4243
"""Get info about the FPGA part.
4344
4445
:param part: the FPGA part as specified by the tool
45-
:returns: a dictionary with the keys family, device, speed and package
46+
:returns: a dict with the keys family, device, speed, package and prange
4647
"""
4748
part = part.lower()
4849
# Looking for the family
@@ -51,6 +52,7 @@ def get_info(part):
5152
r'm2s': 'SmartFusion2',
5253
r'm2gl': 'Igloo2',
5354
r'rt4g': 'RTG4',
55+
r'mpfs': 'PolarFireSoC',
5456
r'mpf': 'PolarFire',
5557
r'a2f': 'SmartFusion',
5658
r'afs': 'Fusion',
@@ -65,10 +67,11 @@ def get_info(part):
6567
if re.match(key, part):
6668
family = value
6769
break
68-
# Looking for the device and package
70+
# Looking for the device, speed and package
6971
device = None
7072
speed = None
7173
package = None
74+
prange = None
7275
aux = part.split('-')
7376
if len(aux) == 2:
7477
device = aux[0]
@@ -86,7 +89,25 @@ def get_info(part):
8689
raise ValueError(
8790
'Part must be DEVICE-SPEED-PACKAGE or DEVICE-PACKAGE'
8891
)
92+
# Looking for a part_range
93+
pranges = {
94+
'c': 'COM',
95+
'e': 'EXT',
96+
'i': 'IND',
97+
'm': 'MIL',
98+
't1': 'TGrade1'
99+
}
100+
prange = 'COM'
101+
for suffix, name in pranges.items():
102+
if package.endswith(suffix):
103+
package = package[:-len(suffix)]
104+
prange = name
105+
break
89106
# Finish
90107
return {
91-
'family': family, 'device': device, 'speed': speed, 'package': package
108+
'family': family,
109+
'device': device,
110+
'speed': speed,
111+
'package': package,
112+
'prange': prange
92113
}

pyfpga/templates/libero.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
{% if 'cfg' in steps %}# Project configuration -------------------------------------------------------
1010

1111
if { [ file exists {{ project }} ] } { file delete -force -- {{ project }} }
12-
new_project -name {{ project }} -location {libero} -hdl {VERILOG} -family {SmartFusion2}
13-
set_device -family {{ family }} -die {{ device }} -package {{ package }} -speed {{ speed }}
12+
new_project -name {{ project }} -location libero -hdl VERILOG -family {{ family }}
13+
set_device -family {{ family }} -die {{ device }} -package {{ package}} -speed {{ speed }} -part_range {{ prange }}
1414

1515
{% if hooks %}{{ hooks.precfg | join('\n') }}{% endif %}
1616

tests/test_part.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def test_libero():
1919
'family': 'SmartFusion2',
2020
'device': 'm2s010',
2121
'speed': '-1',
22-
'package': 'tq144'
22+
'package': 'tq144',
23+
'prange': 'COM'
2324
}
2425
assert get_info_libero('m2s010-1-tq144') == info
2526
assert get_info_libero('m2s010-tq144-1') == info

0 commit comments

Comments
 (0)