-
Notifications
You must be signed in to change notification settings - Fork 0
/
ebrick.py
executable file
·203 lines (160 loc) · 5.79 KB
/
ebrick.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/env python3
# Copyright (c) 2024 Zero ASIC Corporation
# This code is licensed under Apache License 2.0 (see LICENSE for details)
import os
import umi
import lambdalib
from siliconcompiler import Chip
from siliconcompiler.targets import asap7_demo
from siliconcompiler.flows import lintflow
def __add_ebrick_sources(chip):
# Add the ebrick itself as a package source
chip.register_source(
'ebrick_demo',
os.path.abspath(os.path.dirname(__file__)))
# Add ebrick_core top
chip.input('rtl/ebrick_core.v', package='ebrick_demo')
chip.add('option', 'idir', 'config', package='ebrick_demo')
# Import umi and lambdalib libraries
chip.use(umi)
chip.use(lambdalib)
# Set the top module to ebrick_core
chip.set('option', 'entrypoint', 'ebrick_core')
def setup_core_design(chip):
__add_ebrick_sources(chip)
# Add picorv32 data source
chip.register_source(
name='picorv32',
path='git+https://github.com/YosysHQ/picorv32.git',
ref='a7b56fc81ff1363d20fd0fb606752458cd810552')
# Add your core files here
chip.input('picorv32.v', package='picorv32')
# Add your library imports here
def __setup_asicflow(chip):
# Setup asic flow
# set SYNTHESIS macro
chip.add('option', 'define', 'SYNTHESIS')
# Add timing constraints
mainlib = chip.get('asic', 'logiclib')[0] # This is set by the target
chip.input(f'implementation/{mainlib}.sdc', package='ebrick_demo')
# Setup physical constraints
chip.set('constraint', 'density', 40)
# Provide tool specific settings
chip.set('tool', 'openroad', 'task', 'place', 'var',
'gpl_uniform_placement_adjustment',
'0.2')
pdk = chip.get('option', 'pdk')
if pdk == 'asap7':
# Change pin placement settings to allow for multiple layers
# to avoid pin placement congestion
stackup = chip.get('option', 'stackup')
chip.set('pdk', pdk, 'var', 'openroad', 'pin_layer_vertical', stackup, [
'M3',
'M5'
])
chip.set('pdk', pdk, 'var', 'openroad', 'pin_layer_horizontal', stackup, [
'M4',
'M6'
])
# Change minimum pin placement distance to 3 tracks for tasks
# which impact pin placement to reduce routing congestion
for task in ('floorplan', 'place'):
chip.add('tool', 'openroad', 'task', task, 'var', 'ppl_arguments', [
'-min_distance_in_tracks',
'-min_distance', '3'])
elif pdk == 'skywater130':
# Change pin placement settings to allow for multiple layers
# to avoid pin placement congestion
stackup = chip.get('option', 'stackup')
chip.set('pdk', pdk, 'var', 'openroad', 'pin_layer_vertical', stackup, [
'met2',
'met4'
])
chip.set('pdk', pdk, 'var', 'openroad', 'pin_layer_horizontal', stackup, [
'met1',
'met3'
])
def __setup_lintflow(chip):
# Change job name to avoid overwriting asicflow
chip.set('option', 'jobname',
f'{chip.get("option", "jobname")}_lint')
# Import lintflow
chip.use(lintflow)
# Add tool specific settings
chip.add('tool', 'verilator', 'task', 'lint', 'file', 'config',
'config/config.vlt', package='ebrick_demo')
def __setup_testbench(chip):
# Remove the entrypoint setting as this will need to be the testbench
chip.unset('option', 'entrypoint')
# Add tool specific settings
chip.set('tool', 'verilator', 'task', 'compile', 'file', 'config',
'config/config.vlt', package='ebrick_demo')
def setup(chip, testbench=False):
# Add source files for this design
setup_core_design(chip)
if not testbench:
flow = chip.get('option', 'flow')
if flow == 'asicflow':
__setup_asicflow(chip)
elif flow == 'lintflow':
__setup_lintflow(chip)
else:
raise ValueError(f'{flow} is not recognized')
else:
__setup_testbench(chip)
return chip
def main():
chip = Chip("ebrick-demo")
# needed because the test imports ebrick
from ebrick_demo.testbench.test_prv32 import run_test as run_test_prv32
from ebrick_demo.testbench.test_prv32_memagent import run_test as run_test_prv32_memagent
run_test_map = {
'test_prv32': run_test_prv32,
'test_prv32_memagent': run_test_prv32_memagent
}
args = chip.create_cmdline(
switchlist=['-target',
'-flow',
'-clean',
'-jobname',
'-quiet',
'-remote'],
additional_args={
'-test': {
'type': str,
'nargs': '?',
'const': 'test_prv32',
'choices': list(run_test_map.keys()),
'help': 'run a test, defaulting to test_prv32',
'sc_print': False
},
'-trace': {
'action': 'store_true',
'help': "dump waveforms during simulation",
'sc_print': False
},
'-fast': {
'action': 'store_true',
'help': "don't build the simulator if one is found",
'sc_print': False
}
}
)
if args['test']:
run_test_map[args['test']](
trace=args['trace'],
fast=args['fast']
)
return
################################
# Lintflow is the default flow
chip.set('option', 'flow', 'lintflow', clobber=False)
if not chip.get('option', 'target'):
# load the target if it wasn't specified at the CLI
chip.load_target(asap7_demo)
# Setup chip
setup(chip)
chip.run()
chip.summary()
if __name__ == "__main__":
main()