Initial commit
This commit is contained in:
26
verilog/dv/cocotb/user_proj_tests/README.md
Normal file
26
verilog/dv/cocotb/user_proj_tests/README.md
Normal file
@@ -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
|
||||
|
||||
39
verilog/dv/cocotb/user_proj_tests/counter_la/counter_la.c
Normal file
39
verilog/dv/cocotb/user_proj_tests/counter_la/counter_la.c
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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
|
||||
LogicAnalyzer_write(1,7<<16);
|
||||
LogicAnalyzer_outputEnable(1,0);
|
||||
ManagmentGpio_write(0); // configuration finished
|
||||
LogicAnalyzer_outputEnable(1,0xFFFFFFFF);
|
||||
return;
|
||||
}
|
||||
53
verilog/dv/cocotb/user_proj_tests/counter_la/counter_la.py
Normal file
53
verilog/dv/cocotb/user_proj_tests/counter_la/counter_la.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# 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 counter_la(dut):
|
||||
caravelEnv = await test_configure(dut, timeout_cycles=59844)
|
||||
|
||||
cocotb.log.info(f"[TEST] Start counter_la test")
|
||||
# wait for start of sending
|
||||
await caravelEnv.release_csb()
|
||||
await caravelEnv.wait_mgmt_gpio(1)
|
||||
cocotb.log.info(f"[TEST] finish configuration")
|
||||
overwrite_val = 7 # value will be written to the counter by la
|
||||
# expect value bigger than 7
|
||||
await caravelEnv.wait_mgmt_gpio(0) # wait until writing 7 through la
|
||||
received_val = int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2)
|
||||
counter = overwrite_val
|
||||
|
||||
if received_val != counter :
|
||||
cocotb.log.fatal(f"LA writing is incorrect: {overwrite_val} receieved: {received_val}")
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
|
||||
# wait until the LA writing is disabled
|
||||
while (received_val == counter):
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
received_val = int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2)
|
||||
|
||||
counter = received_val
|
||||
for i in range(100):
|
||||
if counter != int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2) :
|
||||
cocotb.log.error(f"counter have wrong value expected = {counter} recieved = {int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2) }")
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
counter +=1
|
||||
|
||||
21
verilog/dv/cocotb/user_proj_tests/counter_la/counter_la.yaml
Normal file
21
verilog/dv/cocotb/user_proj_tests/counter_la/counter_la.yaml
Normal file
@@ -0,0 +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:
|
||||
- {name: counter_la, sim: RTL}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(33,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(34,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(35,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(36,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(37,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_loadConfigs(); // load the configuration
|
||||
// configure la 64 (clk enable by la) as output from cpu
|
||||
// writing 1 in bit 64(first bit in reg 2) to reset
|
||||
LogicAnalyzer_write(2,0);
|
||||
// LogicAnalyzer_inputEnable(2,0x1);
|
||||
LogicAnalyzer_outputEnable(2,0xFFFFFFFC);
|
||||
// reset counter
|
||||
// reset 1
|
||||
LogicAnalyzer_write(2,3); // clk pose edge
|
||||
LogicAnalyzer_write(2,2);// clk pose edge
|
||||
// reset 0
|
||||
LogicAnalyzer_write(2,1); // clk pose edge
|
||||
LogicAnalyzer_write(2,0);// clk pose edge
|
||||
|
||||
ManagmentGpio_write(1); // configuration finished
|
||||
|
||||
for (int i = 0; i < 7; i++){
|
||||
LogicAnalyzer_write(2,1); // clk pose edge
|
||||
ManagmentGpio_write(0);
|
||||
LogicAnalyzer_write(2,0);// clk pose edge
|
||||
ManagmentGpio_write(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
# 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 counter_la_clk(dut):
|
||||
caravelEnv = await test_configure(dut,timeout_cycles=61011)
|
||||
|
||||
cocotb.log.info(f"[TEST] Start counter_wb test")
|
||||
# wait for start of sending
|
||||
await caravelEnv.release_csb()
|
||||
await caravelEnv.wait_mgmt_gpio(1)
|
||||
cocotb.log.info(f"[TEST] finish configuration")
|
||||
overwrite_val = 0 # because of the reset
|
||||
# expect value bigger than 7
|
||||
received_val = int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2)
|
||||
counter = received_val
|
||||
|
||||
for i in range(5):
|
||||
if counter != int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2) :
|
||||
cocotb.log.error(f"counter have wrong value expected = {counter} recieved = {int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2) }")
|
||||
await wait_la_clock_cycle(caravelEnv)
|
||||
counter +=1
|
||||
|
||||
|
||||
async def wait_la_clock_cycle(caravelEnv):
|
||||
# clock is synced with mgmt_gpio
|
||||
await caravelEnv.wait_mgmt_gpio(0)
|
||||
await caravelEnv.wait_mgmt_gpio(1)
|
||||
@@ -0,0 +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:
|
||||
- {name: counter_la_clk, sim: RTL}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(33,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(34,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(35,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(36,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_configure(37,GPIO_MODE_MGMT_STD_OUTPUT);
|
||||
GPIOs_loadConfigs(); // load the configuration
|
||||
// reset counter
|
||||
LogicAnalyzer_outputEnable(2,0xFFFFFFFD);
|
||||
LogicAnalyzer_write(2,2);
|
||||
LogicAnalyzer_write(2,0);
|
||||
|
||||
ManagmentGpio_write(1); // configuration finished
|
||||
// configure la 65 (reset enable by la) as output from cpu
|
||||
// writing 1 in bit 65(second bit in reg 2) to reset
|
||||
// asset reset
|
||||
LogicAnalyzer_write(2,2);
|
||||
LogicAnalyzer_inputEnable(2,0x2);
|
||||
LogicAnalyzer_outputEnable(2,0xFFFFFFFD);
|
||||
// deassert reset
|
||||
LogicAnalyzer_inputEnable(2,0);
|
||||
LogicAnalyzer_outputEnable(2,0xFFFFFFFF);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
# 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 counter_la_reset(dut):
|
||||
caravelEnv = await test_configure(dut,timeout_cycles=1346140)
|
||||
|
||||
cocotb.log.info(f"[TEST] Start counter_wb test")
|
||||
# wait for start of sending
|
||||
await caravelEnv.release_csb()
|
||||
await caravelEnv.wait_mgmt_gpio(1)
|
||||
cocotb.log.info(f"[TEST] finish configuration")
|
||||
overwrite_val = 0 # because of the reset
|
||||
# expect value bigger than 7
|
||||
received_val = int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2)
|
||||
counter = received_val
|
||||
if received_val <= overwrite_val :
|
||||
cocotb.log.error(f"counter started late and value captured after configuration is smaller than overwrite value: {overwrite_val} receieved: {received_val}")
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
|
||||
while True: # wait until reset asserted
|
||||
if await get_reset_val(caravelEnv) == 1:
|
||||
cocotb.log.info(f"[TEST] Reset asserted by la")
|
||||
break
|
||||
while True: # wait until reset deasserted
|
||||
if await get_reset_val(caravelEnv) == 0:
|
||||
cocotb.log.info(f"[TEST] Reset deasserted by la")
|
||||
break
|
||||
counter =0
|
||||
|
||||
for i in range(100):
|
||||
if counter != int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2) :
|
||||
cocotb.log.error(f"counter have wrong value expected = {counter} recieved = {int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2) }")
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
counter +=1
|
||||
|
||||
async def get_reset_val(caravelEnv):
|
||||
""" get the counter reset value"""
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
return caravelEnv.user_hdl.mprj.counter.reset.value
|
||||
@@ -0,0 +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:
|
||||
- {name: counter_la_reset, sim: RTL}
|
||||
|
||||
|
||||
39
verilog/dv/cocotb/user_proj_tests/counter_wb/counter_wb.c
Normal file
39
verilog/dv/cocotb/user_proj_tests/counter_wb/counter_wb.c
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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_loadConfigs(); // load the configuration
|
||||
User_enableIF(); // this necessary when reading or writing between wishbone and user project if interface isn't enabled no ack would be recieve and the command will be stuck
|
||||
// user la reset and wb clk
|
||||
LogicAnalyzer_outputEnable(2,1);
|
||||
// reset counter
|
||||
LogicAnalyzer_write(2,2);
|
||||
LogicAnalyzer_write(2,0);
|
||||
ManagmentGpio_write(1); // configuration finished
|
||||
// writing to any address inside user project address space would reload the counter value
|
||||
USER_writeWord(0x7,0x88);
|
||||
ManagmentGpio_write(0); // start counting from 0
|
||||
|
||||
return;
|
||||
}
|
||||
63
verilog/dv/cocotb/user_proj_tests/counter_wb/counter_wb.py
Normal file
63
verilog/dv/cocotb/user_proj_tests/counter_wb/counter_wb.py
Normal file
@@ -0,0 +1,63 @@
|
||||
# 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 counter_wb(dut):
|
||||
caravelEnv = await test_configure(dut,timeout_cycles=32620)
|
||||
|
||||
cocotb.log.info(f"[TEST] Start counter_wb test")
|
||||
# wait for start of sending
|
||||
await caravelEnv.release_csb()
|
||||
await caravelEnv.wait_mgmt_gpio(1)
|
||||
cocotb.log.info(f"[TEST] finish configuration")
|
||||
overwrite_val = 7 # value will be written to the counter by wishbone
|
||||
# expect value bigger than 7
|
||||
received_val = int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2)
|
||||
counter = received_val
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
|
||||
while True: # wait until the value 1 start counting after the initial
|
||||
received_val = int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2)
|
||||
if counter == 0xFFFF: # rollover
|
||||
counter = 0
|
||||
else:
|
||||
counter +=1
|
||||
if received_val != counter:
|
||||
if received_val == overwrite_val:
|
||||
counter = received_val +1
|
||||
cocotb.log.info(f"Counter value has been overwritten by wishbone to be {received_val}")
|
||||
while True: #wait until the wishbone writing finished and the counter start running again
|
||||
received_val = int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2)
|
||||
if counter == received_val:
|
||||
break
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
cocotb.log.info(f"Counter value has been overwritten by wishbone to be {received_val}")
|
||||
break
|
||||
else:
|
||||
cocotb.log.error(f"Counter has wrong value before overwrite happened expected: {counter} received: {received_val}")
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
|
||||
for i in range(100):
|
||||
if counter != int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2) :
|
||||
cocotb.log.error(f"Counter have wrong value expected = {counter} recieved = {int ((caravelEnv.monitor_gpio(37,30).binstr + caravelEnv.monitor_gpio(7,0).binstr ),2) }")
|
||||
await cocotb.triggers.ClockCycles(caravelEnv.clk,1)
|
||||
counter +=1
|
||||
21
verilog/dv/cocotb/user_proj_tests/counter_wb/counter_wb.yaml
Normal file
21
verilog/dv/cocotb/user_proj_tests/counter_wb/counter_wb.yaml
Normal file
@@ -0,0 +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:
|
||||
- {name: counter_wb, sim: RTL}
|
||||
|
||||
|
||||
24
verilog/dv/cocotb/user_proj_tests/user_proj_tests.yaml
Normal file
24
verilog/dv/cocotb/user_proj_tests/user_proj_tests.yaml
Normal file
@@ -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
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
# yaml file contain general design information that would mostly need to be updated in the first run only
|
||||
Tests:
|
||||
- {name: counter_wb, sim: GL}
|
||||
- {name: counter_la, sim: GL}
|
||||
- {name: counter_la_reset, sim: GL}
|
||||
- {name: counter_la_clk, sim: GL}
|
||||
|
||||
Reference in New Issue
Block a user