Skip to content

Commit

Permalink
Update how to run cocotb tests documention and add SPDX-FileCopyright…
Browse files Browse the repository at this point in the history
…Text to cocotb files
  • Loading branch information
M0stafaRady committed Aug 10, 2023
1 parent a848e3a commit f81d9f7
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 13 deletions.
22 changes: 14 additions & 8 deletions verilog/dv/cocotb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ Overview
========
This directory contain tests to verify the example user project 16 bit counter and 2 other simple tests as examples.

Prerequisites
==============

- ```bash pip install caravel-cocotb```
- update design_info.yaml

directory hierarchy
=====================

# counter_tests
contain tests for 16 bit counter for more info refer to [counter_tests](counter_tests/README.md)
# mprj_por

Example test for the PoR user project example

# hello_world

Expand All @@ -24,14 +30,15 @@ Module that should import all the tests used to be seen for cocotb as a test

Run tests
===========
# run hello_world_uart
# run mprj_por
```bash
caravel_cocotb -t hello_world_uart -tag hello_world
caravel_cocotb -t mprj_por -tag mprj_por_run
```
# run all counter testlist
# run hello_world_uart
```bash
caravel_cocotb -tl counter_tests/counter_tests.yaml -tag counter_tests
caravel_cocotb -t hello_world_uart -tag hello_world
```

# run from different directory
```bash
caravel_cocotb -t hello_world_uart -tag hello_world -design_info <path to design_info.yaml>
Expand All @@ -40,4 +47,3 @@ Run tests
```bash
caravel_cocotb -t hello_world_uart -tag hello_world -sim <path to results directory>
```

17 changes: 17 additions & 0 deletions verilog/dv/cocotb/cocotb_tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# SPDX-FileCopyrightText: 2020 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 hello_world.hello_world import hello_world
from hello_world_uart.hello_world_uart import hello_world_uart
from mprj_por.mprj_por import mprj_por
16 changes: 16 additions & 0 deletions verilog/dv/cocotb/design_info.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# SPDX-FileCopyrightText: 2020 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


CARAVEL_ROOT: <path to>/caravel
MCW_ROOT: <path to>/litex
PDK: sky130A
Expand Down
18 changes: 18 additions & 0 deletions verilog/dv/cocotb/hello_world/hello_world.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
// SPDX-FileCopyrightText: 2020 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



#include <firmware_apis.h>
void main(){
return;
Expand Down
17 changes: 17 additions & 0 deletions verilog/dv/cocotb/hello_world/hello_world.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# SPDX-FileCopyrightText: 2020 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/hello_world.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
---
# SPDX-FileCopyrightText: 2020 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
17 changes: 17 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,20 @@
// SPDX-FileCopyrightText: 2020 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


#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: 2020 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: 2020 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
2 changes: 1 addition & 1 deletion verilog/dv/cocotb/mprj_por/mprj_por.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020 Efabless Corporation
* 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.
Expand Down
15 changes: 15 additions & 0 deletions verilog/dv/cocotb/mprj_por/mprj_por.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# SPDX-FileCopyrightText: 2020 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
5 changes: 3 additions & 2 deletions verilog/dv/mprj_por/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ PDK_PATH = $(PDK_ROOT)/$(PDK)

## Caravel Pointers
CARAVEL_ROOT ?= ../../../caravel
MCW_ROOT ?= ../../../caravel_mgmt_soc_litex
CARAVEL_PATH ?= $(CARAVEL_ROOT)
CARAVEL_FIRMWARE_PATH = $(CARAVEL_PATH)/verilog/dv/caravel
CARAVEL_VERILOG_PATH = $(CARAVEL_PATH)/verilog
Expand All @@ -31,7 +32,7 @@ UPRJ_RTL_PATH = $(UPRJ_VERILOG_PATH)/rtl
UPRJ_BEHAVIOURAL_MODELS = ../

## RISCV GCC
GCC_PATH?=/ef/apps/bin
GCC_PATH?=/opt/riscv/bin
GCC_PREFIX?=riscv32-unknown-elf

## Simulation mode: RTL/GL
Expand All @@ -50,7 +51,7 @@ hex: ${PATTERN:=.hex}
ifeq ($(SIM),RTL)
iverilog $(SIM_DEFINES) -I $(PDK_PATH) \
-I $(CARAVEL_BEHAVIOURAL_MODELS) -I $(CARAVEL_RTL_PATH) \
-I $(UPRJ_BEHAVIOURAL_MODELS) -I $(UPRJ_RTL_PATH) \
-I $(UPRJ_BEHAVIOURAL_MODELS) -I $(UPRJ_RTL_PATH) -I $(MCW_ROOT)/verilog/rtl \
$< -o $@
else
iverilog $(SIM_DEFINES) -DGL -I $(PDK_PATH) \
Expand Down

0 comments on commit f81d9f7

Please sign in to comment.