-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_coco.py
executable file
·75 lines (61 loc) · 2.89 KB
/
run_coco.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
#!/usr/bin/env python3
from pprint import pprint
import pathlib
from cocorun.sim.ghdl import Ghdl
from cocorun.synth.vivado import Vivado
from cocorun.synth.synopsys_dc import DesignCompiler
from cocorun.conf import Manifest
from random import randint, shuffle
manifest = Manifest.load_from_file()
manifest.parser.add_argument('--synth', dest='synth', action='store',
help='Run synthesis flow <synth>')
manifest.parser.add_argument('--report', dest='report_path', action='store', help='report path')
manifest.parser.add_argument('--debug', dest='debug', action='store_const', const=True, default=False,
help='turn debug on')
manifest.parser.add_argument('bundle_name', action='store',
help='target bundle name in Manifest')
manifest.parser.add_argument('--dump', dest='sim_dump', action='store_const', const=True, default=False, help='dump wave in simulation')
args = manifest.parser.parse_args()
if args.report_path:
vivado = Vivado.from_manifest(manifest)
vivado.print_utilization(path=args.report_path)
exit(0)
if args.synth:
if args.synth == 'vivado':
vivado = Vivado.from_manifest(manifest)
frequency = 200 # Mhz
vivado.run_flow(args.bundle_name, target_frequency=frequency,
part='xc7a100tcsg324-1', synth_directive='AreaOptimized_high', opt_directive='ExploreWithRemap')
summary = vivado.lastrun_timing_summary()
pprint(summary)
wns = summary['WNS(ns)']
if isinstance(wns, float):
if wns <= 0:
vivado.log.error("Timing not met!")
vivado.log.error(
f"Frequency to try next: {1000.0/(1000.0/frequency - wns):.3f} Mhz")
else:
vivado.log.info(f"Suggested frequency to try: {1000.0/(1000.0/frequency - wns ):.3f} Mhz")
print(f"Suggested frequency to try: {1000.0/(1000.0/frequency - wns ):.3f} Mhz")
else:
print(f"Worst Negative Slack was reported as {wns}. Combinational datapath?")
vivado.print_utilization()
elif args.synth == 'dc':
synth = DesignCompiler.from_manifest(manifest)
synth.run_flow(args.bundle_name, target_frequency=800)
else:
sim = Ghdl(manifest, log_level='DEBUG' if args.debug else 'INFO')
if args.sim_dump:
sim.wave_dump = args.bundle_name + "_dump.ghw"
if args.bundle_name == "asymmetric_fifo":
for in_width in [8]: # [randint(1,13) for _ in range (10) ]:
print("in_width =", in_width)
l = [4] #[x for x in range(1, 33) ]
shuffle(l)
print(l)
for out_width in l:
sim.generics = {'G_IN_WIDTH': in_width,
'G_OUT_WIDTH': out_width}
sim.run_test(args.bundle_name)
else:
sim.run_test(args.bundle_name)