lint and partially working

This commit is contained in:
matt venn
2023-03-13 18:05:56 +01:00
parent 28a4340240
commit 97cfa3b15e
7 changed files with 36 additions and 67 deletions
+10 -35
View File
@@ -1,22 +1,16 @@
import yaml
import logging
import requests
import glob
import os
import subprocess
import logging
import re
import subprocess
import os
import glob
import gdstk
import cairosvg
import os
import csv
import json
import re
import glob
import git_utils
import git
import shutil
# can't find a google version
CELL_URL = 'https://antmicro-skywater-pdk-docs.readthedocs.io/en/test-submodules-in-rtd/contents/libraries/sky130_fd_sc_ls/cells/'
@@ -43,7 +37,6 @@ class Project():
except FileNotFoundError:
self.metrics = {}
def check_ports(self):
top = self.get_macro_name()
sources = [os.path.join(self.local_dir, 'src', src) for src in self.src_files]
@@ -69,7 +62,6 @@ class Project():
logging.error(f"{self} {port} doesn't have 8 bits")
exit(1)
def check_num_cells(self):
num_cells = self.get_cell_count_from_gl()
if self.is_hdl():
@@ -79,16 +71,13 @@ class Project():
if num_cells < 11:
logging.warning(f"{self} only has {num_cells} cells")
def is_fill(self):
return self.fill
def is_wokwi(self):
if self.wokwi_id != 0:
return True
def is_hdl(self):
return not self.is_wokwi()
@@ -100,7 +89,6 @@ class Project():
logging.error(f"yaml file not found for {self} - do you need to --clone the project repos?")
exit(1)
# find and save the location of the source files
# get name of top module and the verilog module that contains the top
def setup_source_files(self):
@@ -125,13 +113,10 @@ class Project():
self.macro_instance = f"{self.top_module}_{self.index :03}"
self.scanchain_instance = f"scanchain_{self.index :03}"
def get_wokwi_source(self):
src_file = "user_module_{}.v".format(self.wokwi_id)
return [src_file, 'cells.v']
def get_hdl_source(self):
if 'source_files' not in self.yaml['project']:
logging.error("source files must be provided if wokwi_id is set to 0")
@@ -164,7 +149,6 @@ class Project():
return source_files
def get_yaml(self):
return self.yaml
@@ -224,18 +208,19 @@ class Project():
o = repo.remotes.origin
o.pull()
def __str__(self):
# if self.args.log_email:
# return f"[{self.index:03} : {self.email} : {self.git_url}]"
# else:
"""
if self.args.log_email:
return f"[{self.index:03} : {self.email} : {self.git_url}]"
else:
"""
return f"[{self.index:03} : {self.git_url}]"
def fetch_gds(self):
install_artifacts(self.git_url, self.local_dir)
git_utils.install_artifacts(self.git_url, self.local_dir)
def get_latest_action_url(self):
return get_latest_action_url(self.git_url, self.local_dir)
return git_utils.get_latest_action_url(self.git_url, self.local_dir)
def get_macro_name(self):
return self.top_module
@@ -296,13 +281,12 @@ class Project():
logging.debug(f"copy {from_path} to {to_path}")
shutil.copyfile(from_path, to_path)
def print_wokwi_id(self):
print(self.wokwi_id)
def fetch_wokwi_files(self):
logging.info("fetching wokwi files")
src_file = self.src_files[0]
url = "https://wokwi.com/api/projects/{}/verilog".format(self.wokwi_id)
git_utils.fetch_file(url, os.path.join(self.local_dir, "src", src_file))
@@ -311,7 +295,6 @@ class Project():
diagram_file = "wokwi_diagram.json"
git_utils.fetch_file(url, os.path.join(self.local_dir, "src", diagram_file))
def create_user_config(self):
self.fetch_wokwi_files()
@@ -326,7 +309,6 @@ class Project():
fh.write(' \\\n')
fh.write('"\n')
"""
def harden(self):
logging.info(f"hardening {self}")
@@ -392,7 +374,6 @@ class Project():
logging.error('Invalid format for discord username')
exit(1)
# use pandoc to create a single page PDF preview
def create_pdf(self):
yaml = self.yaml
@@ -430,7 +411,6 @@ class Project():
if p.returncode != 0:
logging.error("pdf command failed")
# SVG and PNG renders of the GDS
def create_svg(self):
gds = glob.glob(os.path.join(self.local_dir, 'runs/wokwi/results/final/gds/*gds'))
@@ -441,7 +421,6 @@ class Project():
if self.args.create_png:
cairosvg.svg2png(url='gds_render.svg', write_to='gds_render.png')
def print_warnings(self):
warnings = []
with open(os.path.join(self.local_dir, 'runs/wokwi/logs/synthesis/1-synthesis.log')) as f:
@@ -456,7 +435,6 @@ class Project():
for warning in warnings:
print(f'* {warning}')
def print_stats(self):
print('# Routing stats')
print()
@@ -464,7 +442,6 @@ class Project():
print('|-------------|------------------|')
print('| {} | {} |'.format(self.metrics['OpenDP_Util'], self.metrics['wire_length']))
# Print the summaries
def summarize(self):
cell_count = self.get_cell_count_from_gl()
@@ -509,7 +486,6 @@ class Project():
cell_links = [f'[{name}]({CELL_URL}{name})' for name in cat_dict['examples']]
print(f'|{cat_name} | {" ".join(cell_links)} | {cat_dict["count"]}|')
# Parse the lib, cell and drive strength an OpenLane gate-level Verilog file
def get_cell_count_from_gl(self):
cell_count = {}
@@ -531,7 +507,6 @@ class Project():
cell_count[cell_name] = 1
return (cell_count)
# Load all the json defs and combine into one big dict, keyed by cellname
# Needs access to the PDK
def create_defs(self):