Feedback loop example now working...
import os
import sys
+import re
import multiprocessing
import siliconcompiler
# Setting up the experiment
rootdir = (os.path.dirname(os.path.abspath(__file__)) +
"/../../third_party/designs/oh/")
+
design = 'oh_add'
library = 'mathlib'
width = 100
height = 100
-N = 16
+N = 8
+# Pluggin design into SC
chip = siliconcompiler.Chip(loglevel='INFO')
chip.set('design', design)
-chip.add('source', rootdir+'/mathlib/hdl/'+design+'.v')
+chip.add('source', rootdir+'/stdlib/hdl/'+design+'.v')
chip.set('param', 'N', str(N))
-chip.set('jobid', '0')
chip.set('relax', True)
chip.set('quiet', True)
-chip.set('steplist', ['import', 'syn'])
chip.target("asicflow_freepdk45")
# First run
+steplist = ['import', 'syn']
+chip.set('steplist', steplist)
chip.run()
-oldid = int(chip.set('jobid', '0'))
-old_manifest = chip.find_output(str(oldid), step, index, 'pkg.json')
-old_cfg = chip.read_manifest(old_manifest)
-
-# make sure we are going in the right direction
-while true:
- oldid = int(chip.get('jobid')[-1])
- old_manifest = chip.find_output(str(oldid), step, index, 'pkg.json')
+while True:
+ N = N * 2
+ # Read in last run
+ oldid = chip.get('jobname')[-1]
+ old_manifest = chip.find_result('.pkg.json', 'syn', jobname=oldid)
old_cfg = chip.read_manifest(old_manifest)
- newid = oldid + 1;
- chip.append('jobid', str(newid))
+ #Update ID
+ match = re.match(r'(.*)(\d+)$', oldid)
+ newid = match.group(1) + str(int(match.group(2))+1)
+ # Running syn only
+ chip.add('jobname', newid)
+ chip.set('param', 'N', str(N), clobber=True)
+ print(chip.get('param', 'N'))
+ chip.write_manifest("tmp.json")
chip.run()
- new_manifest = chip.find_output(str(newid), step, index, 'pkg.json')
- new_cfg = chip.read_manifest(mew_manifest)
+ new_area = chip.get('metric','syn','0','cellarea','real')
+ old_area = chip.get('metric','syn','0','cellarea','real', cfg=old_cfg)
- if (chip.get('metric','syn','0','cellarea','real', cfg=new_cfg) >=
- chip.get('metric','syn','0','cellarea','real', cfg=old_cfg)):
+ factor = new_area/old_area
+
+ print(N, new_area, old_area, newid, chip.get('jobname'))
+
+ # compare result
+ if (new_area/old_area) > 2.1:
+ print("Stopping, area is exploding")
break
+
