Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for cores outside of riscv-formal repository #11

Open
wants to merge 1 commit into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Added support for cores outside of riscv-formal repository by adding …

…--basedir arg

to genchecks.py.
  • Loading branch information
stevehoover committed Sep 20, 2018
commit 8071235ad3d474680d3beb5c89c1b823e0da1932
@@ -14,7 +14,7 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

import os, sys, shutil, re
import os, sys, shutil, re, getopt

nret = 1
isa = "rv32i"
@@ -26,16 +26,36 @@
blackbox = False

cfgname = "checks"
basedir = "%s/../.." % os.getcwd()
basedir = "../.." # Assuming run from within riscv-formal/cores/<core>. Relative path for now.

This comment has been minimized.

@cliffordwolf

cliffordwolf Nov 5, 2018
Collaborator

This will break existing cores. The "run from within riscv-formal/cores/<core>" assumption is bogus. There are different tools being run in different directories (for example most checks are run in riscv-formal/cores/<core>/checks) that all inherit this basedir string. It must be an absolute path.

This comment has been minimized.

@stevehoover

stevehoover Dec 20, 2018
Author

Finally getting back to this. It looks like I was allowing the --basedir argument to be a relative path, in which case I append os.getcwd() after arg processing. Thus prepending os.getcwd() on line 29 isn't necessary as it will happen below. If you'd prefer to keep line 29 as it was, I can put another pull request together.

corename = os.getcwd().split("/")[-1]
solver = "boolector"
dumpsmt2 = False
sbycmd = "sby"
config = dict()

if len(sys.argv) > 1:
assert len(sys.argv) == 2
cfgname = sys.argv[1]
# Parse command-line options.

def usage():
print("Usage: " + sys.argv[0] + " [--basedir <riscv-formal-repo-dir>] [<checks-dir>]")
sys.exit(1)

try:
opts, argv = getopt.getopt(sys.argv[1:], "", ["basedir="])
except getopt.GetoptError:
usage()
for opt, val in opts:
if opt == "--basedir":
basedir = val
if len(argv) > 1:
cfgname = argv[1]
if len(argv) > 2:
usage()

# basedir must be absolute.
if (basedir[0] != "/"):
basedir = "%s/%s" % (os.getcwd(), basedir)

# Read config file.

print("Reading %s.cfg." % cfgname)
with open("%s.cfg" % cfgname, "r") as f:
@@ -263,7 +283,7 @@ def check_insn(insn, chanidx, csr_mode=False):
: `include "insn_@insn@.v"
""", **hargs)

with open("../../insns/isa_%s.txt" % isa) as isa_file:
with open("%s/insns/isa_%s.txt" % (basedir, isa)) as isa_file:
for insn in isa_file:
for chanidx in range(nret):
check_insn(insn.strip(), chanidx)
ProTip! Use n and p to navigate between commits in a pull request.