Skip to content

Commit

Permalink
update running cocotb tests from makefile and add cocotb to the CI an…
Browse files Browse the repository at this point in the history
…d update documentation to run cocotb using makefile
  • Loading branch information
M0stafaRady committed Aug 10, 2023
1 parent 587a12a commit 1b1f5ff
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 34 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/user_project_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,8 @@ jobs:
- name: Run DV RTL tests
run: |
make verify-io_ports-rtl
make verify-la_test1-rtl
make verify-la_test2-rtl
make verify-mprj_stimulus-rtl
make verify-wb_port-rtl
# - name: Run DV GL tests
# run: |
# make verify-io_ports-gl
# make verify-la_test1-gl
# make verify-la_test2-gl
# make verify-mprj_stimulus-gl
# make verify-wb_port-gl
make cocotb-verify-all-rtl
-name : Run DV GL tests
run: |
make cocotb-verify-all-gl
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,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))
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 @@ -324,13 +328,19 @@ setup-cocotb:
@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 )
.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 )

.PHONY: cocotb-verify-gl
cocotb-verify-gl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -tl counter_tests/counter_tests_gl.yaml -verbosity quiet)
.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)

$(cocotb-dv-targets-rtl): cocotb-verify-%-rtl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -t $* )

$(cocotb-dv-targets-gl): cocotb-verify-%-gl:
@(cd $(PROJECT_ROOT)/verilog/dv/cocotb && caravel_cocotb -t $* -verbosity quiet)

./verilog/gl/user_project_wrapper.v:
$(error you don't have $@)
Expand Down
15 changes: 11 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,19 @@ Starting your 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
# RTL tests
make cocotb-verify-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
# OR GL simulation using
make cocotb-verify-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>`_
Expand Down
8 changes: 4 additions & 4 deletions verilog/dv/cocotb/cocotb_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

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
File renamed without changes.
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.

# 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@


# yaml file contain general design information that would mostly need to be updated in the first run only
includes:
- counter_la/counter_la.yaml
- counter_wb/counter_wb.yaml
- counter_la_reset/counter_la_reset.yaml
- counter_la_clk/counter_la_clk.yaml


Tests:
- {name: counter_wb, sim: RTL}
- {name: counter_la, sim: RTL}
- {name: counter_la_reset, sim: RTL}
- {name: counter_la_clk, sim: RTL}

0 comments on commit 1b1f5ff

Please sign in to comment.