我已经成功地为我的设计设置了COCOTB验证环境,我很高兴它对RTL的工作方式(在我的情况下为VHDL)。
我的设计是使用仿制药,我正在遵循模板:
,在Python代码的几个位置(主要是在run_test和模型中)检索这些仿制药的价值:
my_generic = dut.gen_name.value
不幸的是,在Gate级别模拟的情况下,这不起作用,因为我的合成设计不再具有通用,因此不存在dut.gen_name.value。
我是否应该从模拟流(CocotB的makefile)中获取参数/普遍值的方向?
如果是这样,最干净的方法是什么?使用Env变量?
(顺便说一句,我使用Questa,即使我不希望这方面取决于模拟器...)
感谢您的帮助和建议...
将配置传递到python cocotb代码可能是可能的,但是这是错误的,因为您必须确保传递已用于合成的相同值。
另一个解决方案是为存储在单独文件中的顶级实体的配置软件包,例如, top_config.vhdl
带有内容:
library ieee;
use ieee.std_logic_1164.all;
package top_config is
constant AA : positive := 5;
constant BB : integer := 10;
end package top_config;
此处定义的常数随后用作顶级实体的通用物的默认值或直接在顶级实体内。
现在可以通过CocotB TestBench中的一些Python代码对该软件包进行解析:
from re import compile as re_compile
constantRegExpStr = r"^s*constants*" # keyword and spaces
constantRegExpStr += r"(?P<name>w+)" # name fo constant
constantRegExpStr += r"s*:s*" # divider and spaces
constantRegExpStr += r"(?P<type>w+)" # type name
constantRegExpStr += r"s*:=s*" # assignment and spaces
constantRegExpStr += r"(?P<value>[0-9]+)" # value
constantRegExpStr += r"s*;" # end of statement
constantRegExp = re_compile(constantRegExpStr)
with open("top_config.vhdl") as f:
for line in f.readlines():
m = constantRegExp.match(line)
if m is not None:
print("constant '{0}' with value '{1}'".format(m.group('name'), m.group('value')))
您可以将其添加到字典中或做其他事情。