Skip to content

Commit

Permalink
Merge pull request #76 from efabless/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
M0stafaRady authored Jan 6, 2025
2 parents c25563f + 8522837 commit a4fa246
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish_pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- main
paths:
- cocotb/caravel_cocotb/version.py # Trigger the workflow only if the VERSION file changes
- cocotb/caravel_cocotb/__version__.py # Trigger the workflow only if the VERSION file changes

jobs:
publish:
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Read version number
id: read_version
run: |
VERSION_FILE=cocotb/caravel_cocotb/version.py
VERSION_FILE=cocotb/caravel_cocotb/__version__.py
NEW_VERSION=$(cat $VERSION_FILE)
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> $GITHUB_ENV
Expand Down
3 changes: 3 additions & 0 deletions cocotb/caravel_cocotb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .__version__ import __version__ # noqa: F401

from .__main__ import RunFLow, CocotbArgs # noqa: F401
2 changes: 1 addition & 1 deletion cocotb/caravel_cocotb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
from caravel_cocotb.scripts.verify_cocotb.RunFlow import RunFLow, CocotbArgs
import argparse
from caravel_cocotb.version import __version__
from caravel_cocotb.__version__ import __version__


def main():
Expand Down
File renamed without changes.
34 changes: 30 additions & 4 deletions cocotb/caravel_cocotb/scripts/verify_cocotb/RunTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def hex_riscv_command_gen(self):
CPUFLAGS = "-O2 -g -march=rv32i_zicsr -mabi=ilp32 -D__vexriscv__ -ffreestanding -nostdlib"
# CPUFLAGS = "-O2 -g -march=rv32imc_zicsr -mabi=ilp32 -D__vexriscv__ -ffreestanding -nostdlib"
includes = f" -I{self.paths.FIRMWARE_PATH} -I{self.paths.FIRMWARE_PATH}/APIs -I{self.paths.VERILOG_PATH}/dv/generated -I{self.paths.VERILOG_PATH}/dv/ -I{self.paths.VERILOG_PATH}/common"
includes += f" -I{self.paths.USER_PROJECT_ROOT}/verilog/dv/cocotb "
includes += f" -I{self.paths.USER_PROJECT_ROOT}/verilog/dv/cocotb {' '.join([f'-I{ip}' for ip in self.get_ips_fw()])}"
elf_command = (
f"{GCC_COMPILE}-gcc {includes} {CPUFLAGS} {LINKER_SCRIPT}"
f" -o {self.hex_dir}/{self.test.name}.elf {SOURCE_FILES} {self.c_file}"
Expand Down Expand Up @@ -84,7 +84,7 @@ def hex_generate(self) -> str:
else:
command = self.hex_riscv_command_gen()

docker_dir = f"-v {self.hex_dir}:{self.hex_dir} -v {self.paths.RUN_PATH}:{self.paths.RUN_PATH} -v {self.paths.CARAVEL_ROOT}:{self.paths.CARAVEL_ROOT} -v {self.paths.MCW_ROOT}:{self.paths.MCW_ROOT} -v {self.test.test_dir}:{self.test.test_dir} "
docker_dir = f"-v {self.hex_dir}:{self.hex_dir} -v {self.paths.RUN_PATH}:{self.paths.RUN_PATH} -v {self.paths.CARAVEL_ROOT}:{self.paths.CARAVEL_ROOT} -v {self.paths.MCW_ROOT}:{self.paths.MCW_ROOT} -v {self.test.test_dir}:{self.test.test_dir} {' '.join([f'-v {link}:{link} ' for link in self.get_ips_fw()])} "
docker_dir = (
docker_dir
+ f"-v {self.paths.USER_PROJECT_ROOT}:{self.paths.USER_PROJECT_ROOT}"
Expand Down Expand Up @@ -118,6 +118,19 @@ def hex_generate(self) -> str:
)
return "hex_generated"

def get_ips_fw(self, flag_type="-I"):
fw_list = []
if not os.path.exists(f"{self.paths.USER_PROJECT_ROOT}/ip"):
return fw_list
for file in os.listdir(f"{self.paths.USER_PROJECT_ROOT}/ip"):
if os.path.isdir(f"{self.paths.USER_PROJECT_ROOT}/ip/{file}"):
for f in os.listdir(f"{self.paths.USER_PROJECT_ROOT}/ip/{file}"):
if f == "fw":
fw_list.append(os.path.realpath(f"{self.paths.USER_PROJECT_ROOT}/ip/{file}/{f}"))
# send it as string
# ips_fw = f"{flag_type}" + f" {flag_type}".join(fw_list)
return fw_list

def test_path(self, test_name=None):
if test_name is None:
test_name = self.test.name
Expand Down Expand Up @@ -155,11 +168,11 @@ def runTest_iverilog(self):
self.iverilog_compile()
self.write_hash(self.test.netlist)
elif not self.is_same_hash(self.test.netlist) and f"{self.test.compilation_dir}/sim.vvp" not in RunTest.COMPILE_LOCK:
print(f"{bcolors.OKCYAN}Compiling since netlist has has changed{bcolors.ENDC}")
print(f"{bcolors.OKCYAN}Compiling since netlist has changed{bcolors.ENDC}")
self.iverilog_compile()
else:
if f"{self.test.compilation_dir}/sim.vvp" not in RunTest.COMPILE_LOCK:
print(f"{bcolors.OKCYAN}Skipping compilation as netlist has not changed{bcolors.ENDC}")
print(f"{bcolors.OKGREEN}Skipping compilation as netlist has not changed{bcolors.ENDC}")
RunTest.COMPILE_LOCK.add(f"{self.test.compilation_dir}/sim.vvp") # locked means if it is copiled for the first time then it will not be compiled again even if netlist changes
if not self.args.compile_only:
self.iverilog_run()
Expand Down Expand Up @@ -209,6 +222,8 @@ def _iverilog_docker_command_str(self, command=""):
docker_dir += (
f"-v {self.paths.USER_PROJECT_ROOT}:{self.paths.USER_PROJECT_ROOT}"
)
docker_dir += " ".join([f' -v {link}:{link} ' for link in self.find_symbolic_links(self.paths.USER_PROJECT_ROOT)])
print(docker_dir)
if os.path.exists("/mnt/scratch/"):
docker_dir += " -v /mnt/scratch/cocotb_runs/:/mnt/scratch/cocotb_runs/ "
display = " -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/.Xauthority --network host --security-opt seccomp=unconfined "
Expand All @@ -221,6 +236,17 @@ def _iverilog_docker_command_str(self, command=""):
)
return command

def find_symbolic_links(self, directory):
sym_links = []
if not os.path.exists(directory):
return sym_links
for root, dirs, files in os.walk(directory):
for dir_name in dirs:
dir_path = os.path.join(root, dir_name)
if os.path.islink(dir_path):
sym_links.append(dir_path)
return sym_links

# vcs function
def runTest_vcs(self):
self.write_vcs_includes_file()
Expand Down
2 changes: 1 addition & 1 deletion cocotb/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PyYAML>=6
anytree>=2.12.0,<3
click>=8
cocotb>=1.9.0,<2
cocotb_coverage==1.1.0
oyaml==1.0
prettytable>=3.7.0,<4
PyYAML>=6
rich>=12,<14
ruamel.yaml>=0.18.6
volare>=0.18.0
Expand Down
5 changes: 2 additions & 3 deletions cocotb/setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python3
from setuptools import setup, find_packages
from caravel_cocotb.version import __version__

requirements = open("requirements.txt").read().strip().split("\n")

version = open("caravel_cocotb/__version__.py").read().strip().split()[-1][1:-1]
setup(
name="caravel_cocotb",
packages=find_packages(),
version=__version__,
version=version,
description="efabless caravel cocotb verification flow.",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
Expand Down

0 comments on commit a4fa246

Please sign in to comment.