-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,502 additions
and
193 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
__pycache__ | ||
openroad/* | ||
!openroad/nangate45 | ||
openroad/logs | ||
openroad/objects | ||
openroad/reports | ||
openroad/results | ||
openroad/vsrc/* | ||
!openroad/vsrc/Core.v | ||
!openroad/vsrc/CoreWrapper.v | ||
!openroad/vsrc/CSRFileWrapper.v | ||
output | ||
emulator-debug |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import subprocess | ||
from pathlib import Path | ||
from rich import print | ||
from rich.console import Console | ||
|
||
from trace import * | ||
from cpi import * | ||
from constants import * | ||
|
||
|
||
console = Console() | ||
|
||
|
||
def run_tests(total_tests): | ||
count = 0 | ||
|
||
for tb in bench_dir.iterdir(): | ||
tb_filename = tb.name | ||
if tb.is_file() and not tb.suffix in [".dump", ".trace"]: | ||
count += 1 | ||
vcd_option = f"-v{log_dir}/{tb_filename}.vcd" if waves_flag else "" | ||
txt_file = log_dir / f"{tb_filename}.txt" | ||
|
||
console.print(f"Extract trace from benchmark ({count}/{total_tests}): {tb_filename} .. ", end="") | ||
result = subprocess.run( | ||
f"{emulator} {vcd_option} +max-cycles=100000 {tb}", | ||
stdout=open(txt_file, "w"), | ||
stderr=subprocess.STDOUT, | ||
shell=True | ||
) | ||
|
||
console.print("DONE") | ||
|
||
|
||
if __name__ == "__main__": | ||
# Current file absolute directory path | ||
curr_dir = Path(__file__).resolve().parent | ||
log_dir = curr_dir / "output" | ||
emulator = curr_dir / "emulator-debug" | ||
bench_dir = curr_dir / "program/bench" | ||
|
||
# Check if the emulator exists | ||
if not emulator.is_file(): | ||
logger.error(f"{emulator} does not exist.") | ||
logger.error("Please run `python3 scripts/cpu/build.py` first.") | ||
sys.exit(1) | ||
|
||
# Flags | ||
trace_flag = False | ||
cpi_flag = False | ||
waves_flag = False | ||
|
||
# Parse arguments | ||
for arg in sys.argv[1:]: | ||
if arg == "trace": | ||
trace_flag = True | ||
elif arg == "cpi": | ||
cpi_flag = True | ||
elif arg == "--waves": | ||
waves_flag = True | ||
|
||
# Ensure log directory exists | ||
log_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
# Running tests | ||
if trace_flag: | ||
logger.info("Running benchmark trace tests") | ||
run_tests(9) | ||
check_trace() | ||
elif cpi_flag: | ||
logger.info("Running benchmark cpi tests") | ||
run_tests(9) | ||
calculate_cpi_hf("branch_prediction") |
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import subprocess | ||
from pathlib import Path | ||
from rich import print | ||
from rich.console import Console | ||
|
||
from constants import * | ||
|
||
|
||
console = Console() | ||
|
||
|
||
def run_tests(test_dir, total_tests): | ||
count = 0 | ||
count_passed = 0 | ||
count_failed = 0 | ||
|
||
for tb in test_dir.iterdir(): | ||
tb_filename = tb.name | ||
if tb.is_file() and not tb.suffix == ".dump": | ||
count += 1 | ||
vcd_option = f"-v{log_dir}/{tb_filename}.vcd" if waves_flag else "" | ||
txt_file = log_dir / f"{tb_filename}.txt" | ||
|
||
console.print(f"Test ({count}/{total_tests}): {tb_filename} .. ", end="") | ||
result = subprocess.run( | ||
f"{emulator} {vcd_option} {tb}", | ||
stdout=open(txt_file, "w"), | ||
stderr=subprocess.STDOUT, | ||
shell=True, | ||
) | ||
|
||
if result.returncode == 0: | ||
console.print("[green]PASSED[/green]") | ||
count_passed += 1 | ||
else: | ||
console.print("[red]FAILED[/red]") | ||
count_failed += 1 | ||
|
||
logger.info(f"Number of success tests: {count_passed} / {total_tests}") | ||
|
||
if count_failed > 0: | ||
logger.error(f"You can check the log file for failed test cases in `{cpu_script_dir}/output` directory.") | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
# Setup | ||
curr_dir = Path(__file__).resolve().parent | ||
log_dir = curr_dir / "output" | ||
emulator = curr_dir / "emulator-debug" | ||
|
||
# Check if the emulator exists | ||
if not emulator.is_file(): | ||
logger.error(f"{emulator} does not exist.") | ||
logger.error("Please run `python3 scripts/cpu/build.py` first.") | ||
sys.exit(1) | ||
|
||
# Flags | ||
base_flag = False | ||
mext_flag = False | ||
waves_flag = False | ||
|
||
# Parse arguments | ||
for arg in sys.argv[1:]: | ||
if arg == "base": | ||
base_flag = True | ||
elif arg == "mext": | ||
mext_flag = True | ||
elif arg == "--waves": | ||
waves_flag = True | ||
|
||
# Ensure log directory exists | ||
log_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
# Running tests | ||
if base_flag: | ||
logger.info("Running base ISA tests") | ||
base_dir = curr_dir / "program/isa/base" | ||
run_tests(base_dir, 43) | ||
|
||
elif mext_flag: | ||
logger.info("Running M-extension ISA tests") | ||
mext_dir = curr_dir / "program/isa/mext" | ||
run_tests(mext_dir, 8) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.