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

Update Makefile to pip caravel-cocotb #307

Merged
merged 7 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export PDK?=sky130A
#export PDK?=gf180mcuC
export PDKPATH?=$(PDK_ROOT)/$(PDK)

PYTHON_BIN ?= python3

ROOTLESS ?= 0
USER_ARGS = -u $$(id -u $$USER):$$(id -g $$USER)
ifeq ($(ROOTLESS), 1)
Expand Down Expand Up @@ -106,6 +108,11 @@ install:
simenv:
docker pull efabless/dv:latest

# Install cocotb docker
.PHONY: simenv-cocotb
simenv-cocotb:
docker pull efabless/dv:cocotb

.PHONY: setup
setup: check_dependencies install check-env install_mcw openlane pdk-with-volare setup-timing-scripts setup-cocotb precheck

Expand All @@ -116,8 +123,12 @@ $(blocks): % :
$(MAKE) -C openlane $*

dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
cocotb-dv_patterns=$(shell cd verilog/dv/cocotb && find . -name "*.c" | sed -e 's|^.*/||' -e 's/.c//')
$(info VAR1 is $(cocotb-dv_patterns))
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved
dv-targets-rtl=$(dv_patterns:%=verify-%-rtl)
cocotb-dv-targets-rtl=$(cocotb-dv_patterns:%=cocotb-verify-%-rtl)
dv-targets-gl=$(dv_patterns:%=verify-%-gl)
cocotb-dv-targets-gl=$(cocotb-dv_patterns:%=cocotb-verify-%-gl)
dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf)

TARGET_PATH=$(shell pwd)
Expand Down Expand Up @@ -322,20 +333,33 @@ setup-timing-scripts: $(TIMING_ROOT)
@( cd $(TIMING_ROOT) && git pull )
@#( cd $(TIMING_ROOT) && git fetch && git checkout $(MPW_TAG); )

.PHONY: setup-cocotb
setup-cocotb:
@pip install caravel-cocotb==1.0.0
.PHONY: install-caravel-cocotb
install-caravel-cocotb:
rm -rf ./venv
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved
$(PYTHON_BIN) -m venv ./venv
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved
./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir pip
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved
./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir caravel-cocotb
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: setup-cocotb-env
setup-cocotb-env:
@(python3 $(PROJECT_ROOT)/verilog/dv/setup-cocotb.py $(CARAVEL_ROOT) $(MCW_ROOT) $(PDK_ROOT) $(PDK) $(PROJECT_ROOT))
@docker pull efabless/dv:latest
@docker pull efabless/dv:cocotb

.PHONY: cocotb-verify-rtl
cocotb-verify-rtl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -tl counter_tests/counter_tests.yaml -v )
.PHONY: setup-cocotb
setup-cocotb: install-caravel-cocotb setup-cocotb-env simenv-cocotb

.PHONY: cocotb-verify-all-rtl
cocotb-verify-all-rtl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -tl user_proj_tests/user_proj_tests.yaml )
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: cocotb-verify-all-gl
cocotb-verify-all-gl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -tl user_proj_tests/user_proj_tests_gl.yaml -verbosity quiet)
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved

$(cocotb-dv-targets-rtl): cocotb-verify-%-rtl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -t $* )
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: cocotb-verify-gl
cocotb-verify-gl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -tl counter_tests/counter_tests_gl.yaml -v -verbosity quiet)
$(cocotb-dv-targets-gl): cocotb-verify-%-gl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -t $* -verbosity quiet)
M0stafaRady marked this conversation as resolved.
Show resolved Hide resolved

./verilog/gl/user_project_wrapper.v:
$(error you don't have $@)
Expand Down Expand Up @@ -403,4 +427,4 @@ caravel-sta: ./env/spef-mapping.tcl
@echo =================================================================================================
@echo "You can find results for all corners in $(CUP_ROOT)/signoff/caravel/openlane-signoff/timing/"
@echo "Check summary.log of a specific corner to point to reports with reg2reg violations"
@echo "Cap and slew violations are inside summary.log file itself"
@echo "Cap and slew violations are inside summary.log file itself"
21 changes: 21 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@ Starting your project
# for example
make verify-io_ports-rtl

#. Run cocotb simulation on your design

* You need to include your rtl/gl/gl+sdf files in ``verilog/includes/includes.<rtl/gl/gl+sdf>.caravel_user_project``

* To make sure the cocotb flow works, run the following commands for testing the counter example

.. code:: bash
# To run all tests in user_project_tests list found at ``verilog/dv/cocotb/user_project_tests/user_project_tests.yaml``
# RTL tests
make cocotb-verify-all-rtl
# OR GL simulation using
make cocotb-verify-all-gl
# To run any test under ``verilog/dv/cocotb/*``
# RTL
make cocotb-verify-<test_name>-rtl
# GL
make cocotb-verify-<test_name>-gl
* To run cocotb tests on your design, Follow the steps below
* Add cocotb tests under ``verilog/dv/cocotb`` follow steps at `Adding_cocotb_test <https://caravel-sim-infrastructure.readthedocs.io/en/latest/usage.html#adding-a-test>`_
* Run cocotb tests using ``caravel_cocotb`` command steps at `Running_cocotb_tests <https://caravel-sim-infrastructure.readthedocs.io/en/latest/usage.html#running-a-test>`_

#. Run opensta on your design

* Extract spefs for ``user_project_wrapper`` and macros inside it:
Expand Down
8 changes: 4 additions & 4 deletions verilog/dv/cocotb/cocotb_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from hello_world.hello_world import hello_world
from hello_world_uart.hello_world_uart import hello_world_uart
from counter_tests.counter_wb.counter_wb import counter_wb
from counter_tests.counter_la.counter_la import counter_la
from counter_tests.counter_la_reset.counter_la_reset import counter_la_reset
from counter_tests.counter_la_clk.counter_la_clk import counter_la_clk
from user_proj_tests.counter_wb.counter_wb import counter_wb
from user_proj_tests.counter_la.counter_la import counter_la
from user_proj_tests.counter_la_reset.counter_la_reset import counter_la_reset
from user_proj_tests.counter_la_clk.counter_la_clk import counter_la_clk
from gpio_test.gpio_test import gpio_test
7 changes: 0 additions & 7 deletions verilog/dv/cocotb/counter_tests/counter_la/counter_la.yaml

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions verilog/dv/cocotb/counter_tests/counter_tests.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions verilog/dv/cocotb/counter_tests/counter_wb/counter_wb.yaml

This file was deleted.

42 changes: 7 additions & 35 deletions verilog/dv/cocotb/design_info.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
# yaml file contain general design information that would mostly need to be updated in the first run only

#eg CARAVEL_ROOT: "/usr/Desktop/caravel_project/caravel/"
#like repo https://github.com/efabless/caravel
# CARAVEL_ROOT: "/home/usr/caravel/swift/swift2"
CARAVEL_ROOT: /home/usr/caravel/caravel

#eg MCW_ROOT: "/usr/Desktop/caravel_project/caravel_mgmt_soc_litex/"
#like repo https://github.com/efabless/caravel_mgmt_soc_litex
# MCW_ROOT: "/home/usr/caravel/swift/swift2"
MCW_ROOT: /home/usr/caravel/caravel_mgmt_soc_litex/

#eg USER_PROJECT_ROOT: "/usr/Desktop/caravel_project/caravel_user_project/"
#like repo https://github.com/efabless/caravel_user_project
USER_PROJECT_ROOT: /home/usr/caravel/caravel_user_project/
# USER_PROJECT_ROOT: "/home/usr/caravel/swift/caravel_user_project"
# USER_PROJECT_ROOT: None
# USER_PROJECT_ROOT: None



#eg PDK_ROOT: "/usr/Desktop/caravel_project/pdk/"
#exported by volare
PDK_ROOT: /home/usr/pdk

#eg PDK: "sky130A"
CARAVEL_ROOT: /home/rady/temp/caravel_user_project/caravel
MCW_ROOT: /home/rady/temp/caravel_user_project/mgmt_core_wrapper
PDK: sky130A
#PDK: gf180mcuC

#clock in ns
clk: 25

# true when caravan are simulated instead of caravel
PDK_ROOT: /home/rady/caravel/caravel_litex/pdk
USER_PROJECT_ROOT: /home/rady/temp/caravel_user_project
marwaneltoukhy marked this conversation as resolved.
Show resolved Hide resolved
caravan: false

# optional email address to send the results to
emailto: [None]
clk: 25
emailto:
- null
15 changes: 15 additions & 0 deletions verilog/dv/cocotb/gpio_test/gpio_test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// SPDX-FileCopyrightText: 2023 Efabless Corporation

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#include <firmware_apis.h> // include required APIs
void main(){
// Enable managment gpio as output to use as indicator for finishing configuration
Expand Down
16 changes: 16 additions & 0 deletions verilog/dv/cocotb/gpio_test/gpio_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# SPDX-FileCopyrightText: 2023 Efabless Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# SPDX-License-Identifier: Apache-2.0

from caravel_cocotb.caravel_interfaces import * # import python APIs
import cocotb

Expand Down
15 changes: 15 additions & 0 deletions verilog/dv/cocotb/hello_world/hello_world.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// SPDX-FileCopyrightText: 2023 Efabless Corporation

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#include <firmware_apis.h>
void main(){
return;
Expand Down
16 changes: 16 additions & 0 deletions verilog/dv/cocotb/hello_world/hello_world.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# SPDX-FileCopyrightText: 2023 Efabless Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# SPDX-License-Identifier: Apache-2.0

from caravel_cocotb.caravel_interfaces import test_configure
from caravel_cocotb.caravel_interfaces import report_test
import cocotb
Expand Down
16 changes: 16 additions & 0 deletions verilog/dv/cocotb/hello_world/hello_world.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
---
# SPDX-FileCopyrightText: 2023 Efabless Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# SPDX-License-Identifier: Apache-2.0

# Yalm file contain general design information that would mostly need to be updated in the first run only
# example
## tests: [debug,clock_redirect]
Expand Down
15 changes: 15 additions & 0 deletions verilog/dv/cocotb/hello_world_uart/hello_world_uart.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// SPDX-FileCopyrightText: 2023 Efabless Corporation

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#include <firmware_apis.h>

void main(){
Expand Down
17 changes: 17 additions & 0 deletions verilog/dv/cocotb/hello_world_uart/hello_world_uart.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# SPDX-FileCopyrightText: 2023 Efabless Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# SPDX-License-Identifier: Apache-2.0


from caravel_cocotb.caravel_interfaces import test_configure
from caravel_cocotb.caravel_interfaces import report_test
import cocotb
Expand Down
19 changes: 18 additions & 1 deletion verilog/dv/cocotb/hello_world_uart/hello_world_uart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
---
# SPDX-FileCopyrightText: 2023 Efabless Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# SPDX-License-Identifier: Apache-2.0



# Yalm file contain general design information that would mostly need to be updated in the first run only

Tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// SPDX-FileCopyrightText: 2023 Efabless Corporation

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#include <firmware_apis.h>

void main(){
Expand Down
Loading
Loading