Created
September 17, 2020 11:23
-
-
Save thesps/79edb0d2dfead16bad18de44a40c3070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def report(proj_dir): | |
data = {} | |
data['error'] = False | |
# Check for C Synthesis errors | |
if os.path.exists('{}/vivado_hls.log'.format(proj_dir)): | |
report = open('{}/vivado_hls.log'.format(proj_dir)) | |
lines = np.array(report.readlines()) | |
error = bool(np.sum(np.array(['ERROR' in line for line in lines]))) | |
if error: | |
data['latency_us'] = 0 | |
data['latency_clks'] = 0 | |
data['lut'] = 0 | |
data['ff'] = 0 | |
data['bram'] = 0 | |
data['dsp'] = 0 | |
data['error'] = True | |
return data | |
# Get the latency from the Vivado HLS report | |
if os.path.exists('{}/myproject_prj/solution1/syn/report/myproject_csynth.rpt'.format(proj_dir)): | |
report = open('{}/myproject_prj/solution1/syn/report/myproject_csynth.rpt'.format(proj_dir)) | |
lines = np.array(report.readlines()) | |
lat_line = lines[np.argwhere(np.array(['Latency (cycles)' in line for line in lines])).flatten()[0] + 3] | |
data['latency_clks'] = int(lat_line.split('|')[2]) | |
lat = lat_line.split('|')[4] | |
if 'ns' in lat: | |
# put in microseconds | |
lat = float(lat.replace('ns','')) * 10**-3 | |
elif 'us' in lat: | |
lat = float(lat.replace('us','')) | |
elif 'ms' in lat: | |
lat = float(lat.replace('ms','')) * 10**3 | |
else: | |
print("Unsupported latency suffix: {}".format(lat)) | |
data['latency_us'] = lat | |
else: | |
return None | |
# Get the resources from the logic synthesis report | |
if os.path.exists('{}/vivado_synth.rpt'.format(proj_dir)): | |
report = open('{}/vivado_synth.rpt'.format(proj_dir)) | |
lines = np.array(report.readlines()) | |
data['lut'] = int(lines[np.array(['CLB LUTs*' in line for line in lines])][0].split('|')[2]) | |
data['ff'] = int(lines[np.array(['CLB Registers' in line for line in lines])][0].split('|')[2]) | |
data['bram'] = float(lines[np.array(['Block RAM Tile' in line for line in lines])][0].split('|')[2]) | |
data['dsp'] = int(lines[np.array(['DSPs' in line for line in lines])][0].split('|')[2]) | |
report.close() | |
else: | |
return None | |
return data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment