-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from efabless/gf180mcu_cocotb
add cocotb to Gf180mcu
- Loading branch information
Showing
28 changed files
with
935 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sim/ | ||
*.log | ||
*.vcd | ||
*.pyc |
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,43 @@ | ||
Overview | ||
======== | ||
This directory contain tests to verify the example user project 16 bit counter and 2 other simple tests as examples. | ||
|
||
directory hierarchy | ||
===================== | ||
|
||
# counter_tests | ||
|
||
contain tests for 16 bit counter for more info refer to [counter_tests](counter_tests/README.md) | ||
|
||
# hello_world | ||
|
||
Example test with empty firmware that only power and reset caravel the print "Hello World" | ||
|
||
# hello_world_uart | ||
|
||
Example test That uses the firmware to send "Hello World" using UART TX | ||
|
||
# cocotb_tests.py | ||
|
||
Module that should import all the tests used to be seen for cocotb as a test | ||
|
||
|
||
Run tests | ||
=========== | ||
# run hello_world_uart | ||
```bash | ||
caravel_cocotb -t hello_world_uart -tag hello_world | ||
``` | ||
# run all counter testlist | ||
```bash | ||
caravel_cocotb -tl counter_tests/counter_tests.yaml -tag counter_tests | ||
``` | ||
# run from different directory | ||
```bash | ||
caravel_cocotb -t hello_world_uart -tag hello_world -design_info <path to design_info.yaml> | ||
``` | ||
# run with changing the results directory | ||
```bash | ||
caravel_cocotb -t hello_world_uart -tag hello_world -sim <path to results directory> | ||
``` | ||
|
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,7 @@ | ||
from hello_world.hello_world import hello_world | ||
from hello_world_uart.hello_world_uart import hello_world_uart | ||
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 |
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,9 @@ | ||
CARAVEL_ROOT: /usr/caravel_user_project/caravel | ||
MCW_ROOT: /usr/caravel_user_project/mgmt_core_wrapper | ||
PDK: sky130A | ||
PDK_ROOT: /usr/pdk | ||
USER_PROJECT_ROOT: /usr/caravel_user_project | ||
caravan: false | ||
clk: 25 | ||
emailto: | ||
- null |
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,30 @@ | ||
// 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 | ||
ManagmentGpio_outputEnable(); | ||
ManagmentGpio_write(0); | ||
enableHkSpi(0); // disable housekeeping spi | ||
//GPIOs_configureAll(GPIO_MODE_MGMT_STD_OUT); | ||
GPIOs_configureAll(GPIO_MODE_MGMT_STD_OUTPUT); | ||
GPIOs_loadConfigs(); | ||
GPIOs_writeLow(0x8F); | ||
ManagmentGpio_write(1); // configuration finished | ||
|
||
|
||
return; | ||
} |
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,36 @@ | ||
# 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 | ||
|
||
@cocotb.test() # cocotb test marker | ||
@report_test # wrapper for configure test reporting files | ||
async def gpio_test(dut): | ||
caravelEnv = await test_configure(dut) #configure, start up and reset caravel | ||
#await caravelEnv.release_csb() | ||
await caravelEnv.wait_mgmt_gpio(1) | ||
gpios_value_str = caravelEnv.monitor_gpio(37, 0).binstr | ||
cocotb.log.info (f"All gpios '{gpios_value_str}'") | ||
gpio_value_int = caravelEnv.monitor_gpio(37, 0).integer | ||
#expected_gpio_value = 0xF8 | ||
expected_gpio_value = 0x8F | ||
if (gpio_value_int == expected_gpio_value): | ||
cocotb.log.info (f"[TEST] Pass the gpio value is '{hex(gpio_value_int)}'") | ||
else: | ||
cocotb.log.error (f"[TEST] Fail the gpio value is :'{hex(gpio_value_int)}' expected {hex(expected_gpio_value)}") | ||
|
||
|
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,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. | ||
|
||
|
||
#include <firmware_apis.h> | ||
void main(){ | ||
return; | ||
} |
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,25 @@ | ||
# 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 | ||
|
||
@cocotb.test() | ||
@report_test | ||
async def hello_world(dut): | ||
caravelEnv = await test_configure(dut,timeout_cycles=9373) | ||
cocotb.log.info("Hello World") |
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,27 @@ | ||
--- | ||
# 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] | ||
## sim: [RTL,RTL] | ||
Tests: | ||
- {name: hello_world, sim: RTL} | ||
|
||
|
||
|
||
|
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,28 @@ | ||
// 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(){ | ||
ManagmentGpio_write(0); | ||
ManagmentGpio_outputEnable(); | ||
GPIOs_configure(6,GPIO_MODE_MGMT_STD_OUTPUT); | ||
GPIOs_loadConfigs(); | ||
UART_enableTX(1); | ||
ManagmentGpio_write(1); // configuration finished | ||
|
||
print("Hello World\n"); | ||
return; | ||
} |
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,38 @@ | ||
# 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 | ||
from caravel_cocotb.caravel_interfaces import UART | ||
|
||
@cocotb.test() | ||
@report_test | ||
async def hello_world_uart(dut): | ||
caravelEnv = await test_configure(dut,timeout_cycles=3346140) | ||
|
||
cocotb.log.info(f"[TEST] Start uart test") | ||
expected_msg = "Hello World" | ||
uart = UART(caravelEnv) | ||
# wait for start of sending | ||
await caravelEnv.wait_mgmt_gpio(1) | ||
# read the msg sent | ||
msg = await uart.get_line() | ||
if msg in expected_msg : | ||
cocotb.log.info (f"[TEST] Pass recieve the full expected msg '{msg}'") | ||
else: | ||
cocotb.log.error (f"[TEST] recieved wrong msg from uart msg recieved:'{msg}' expected '{expected_msg}'") |
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,24 @@ | ||
# 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: | ||
- {name: hello_world_uart, sim: RTL} | ||
|
||
|
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,26 @@ | ||
|
||
Tests hierarchy | ||
===================== | ||
|
||
# counter_wb | ||
|
||
Test that overwrite the counter value using wishbone interface | ||
|
||
# counter_la | ||
|
||
Test that overwrite the counter value using logic analyzer interface | ||
|
||
# counter_la_clk | ||
|
||
Counter can work by 2 different clocks wishbone clock or clock provided through logic analyzers. | ||
By default the wishbone clock is the used one. This test uses the logic analyzers clock | ||
|
||
|
||
# counter_la_reset | ||
|
||
Counter reset also provided through wishbone or logic analyzers. this test uses the logic analyzers reset | ||
|
||
# counter_tests.yaml | ||
|
||
Testlist contain all counter tests | ||
|
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,44 @@ | ||
// 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(){ | ||
// Enable managment gpio as output to use as indicator for finishing configuration | ||
ManagmentGpio_outputEnable(); | ||
ManagmentGpio_write(0); | ||
enableHkSpi(0); // disable housekeeping spi | ||
// configure all gpios as user out then chenge gpios from 32 to 37 before loading this configurations | ||
GPIOs_configureAll(GPIO_MODE_USER_STD_OUT_MONITORED); | ||
GPIOs_configure(32,GPIO_MODE_USER_STD_OUT_MONITORED); | ||
GPIOs_configure(33,GPIO_MODE_USER_STD_OUT_MONITORED); | ||
GPIOs_configure(34,GPIO_MODE_USER_STD_OUT_MONITORED); | ||
GPIOs_configure(35,GPIO_MODE_USER_STD_OUT_MONITORED); | ||
GPIOs_configure(36,GPIO_MODE_USER_STD_OUT_MONITORED); | ||
GPIOs_configure(37,GPIO_MODE_USER_STD_OUT_MONITORED); | ||
GPIOs_loadConfigs(); // load the configuration | ||
ManagmentGpio_write(1); // configuration finished | ||
// configure la [63:32] as output from cpu | ||
#ifdef GF180 | ||
LogicAnalyzer_write(1,7<<14); | ||
LogicAnalyzer_outputEnable(1,0xC0000000); | ||
#else | ||
LogicAnalyzer_write(1,7<<16); | ||
LogicAnalyzer_outputEnable(1,0); | ||
#endif // GF180 | ||
ManagmentGpio_write(0); // configuration finished | ||
LogicAnalyzer_outputEnable(1,0xFFFFFFFF); | ||
return; | ||
} |
Oops, something went wrong.