您的位置:首页 > 科技 > IT业 > 东莞企业信息查询系统官网_网页的制作_百度关键词seo_百度一下手机版

东莞企业信息查询系统官网_网页的制作_百度关键词seo_百度一下手机版

2025/2/25 5:01:48 来源:https://blog.csdn.net/weixin_39060517/article/details/144217438  浏览:    关键词:东莞企业信息查询系统官网_网页的制作_百度关键词seo_百度一下手机版
东莞企业信息查询系统官网_网页的制作_百度关键词seo_百度一下手机版

cocotb—基础语法对照篇

在这里插入图片描述

import cocotb
from cocotb.triggers import Timer
from adder_model import adder_model
from cocotb.clock import Clock
from cocotb.triggers import RisingEdge
import random@cocotb.test()
async def adder_basic_test(dut):"""Test for 5 + 10"""cocotb.fork(Clock(dut.clk, 10, units='ns').start())A = 5B = 10#dut.A <= A#dut.B <= B  # 和下边两行等价dut.A.value =Adut.B.value =Bawait RisingEdge(dut.clk)await RisingEdge(dut.clk)assert dut.X.value == adder_model(A, B), "Adder result is incorrect: {} != 15".format(dut.X.value)@cocotb.test()
async def adder_randomised_test(dut):"""Test for adding 2 random numbers multiple times"""cocotb.fork(Clock(dut.clk, 5, units='ns').start())for i in range(10):A = random.randint(0, 15)B = random.randint(0, 15)#dut.A <= A#dut.B <= Bdut.A.value = Adut.B.value = Bawait RisingEdge(dut.clk)await RisingEdge(dut.clk)assert dut.X.value == adder_model(A, B), "Randomised test failed with: {A} + {B} = {X}".format(A=dut.A.value, B=dut.B.value, X=dut.X.value)
#adder_model.py
def adder_model(a: int, b: int) -> int:""" model of adder """return a + b
# Makefile
TOPLEVEL_LANG= verilog
PWD=$(shell pwd)VERILOG_SOURCES=./adder.vTOPLEVEL=adder
MODULE= test_adderSIM=icarusinclude $(shell cocotb-config --makefiles)/Makefile.sim

多文件tb, 多文件dut

# makefile templateVERILOG_SOURCES = $(PWD)/submodule.sv $(PWD)/my_design.sv
# TOPLEVEL is the name of the toplevel module in your Verilog or VHDL file:
TOPLEVEL=my_design
# MODULE is the name of the Python test file:
MODULE=test_my_designinclude $(shell cocotb-config --makefiles)/Makefile.sim

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com