Modelsim/读取信号值 [英] Modelsim / reading a signal value

查看:42
本文介绍了Modelsim/读取信号值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的模拟中,我希望能够以读写方式访问项目中任何位置的信号.为了获得写入权限,我使用了modelsim_lib 库中的signal_force"过程.但是为了获得读取权限,我还没有找到相应的功能.

In my simulation, I want to have RW access to signals whereever there are in the project. To get the write access, I use the "signal_force" procedure from the modelsim_lib library. But to get the read access I havn't find the corresponding function.

signal_force 适合我的需求的原因是我正在处理输入文本文件,所以我有来自字符串"或行"变量的信号的名称和值,我可以直接给出这些变量到函数.我不能使用init_signal_spy"过程,因为该过程不会将值返回到字符串中,而只是将信号的行为复制到另一个上.由于我的项目必须尽可能通用,因此我使用在过程中声明的变量,并且我无法将信号链接到变量上.

The reason why signal_force fit my needs is that I'm working with input text files, so I have the name and the value of the signal from a "string" or a "line" variable and I can directly give these variable to the fonction. I cannot use the "init_signal_spy" procedure because this procedure doesn't give back a value into a string but just duplicates the behavior of a signal onto an other. As my project has to be as generic as possible, I work with variables declared into procedures and I cannot link a signal onto a variable.

感谢您的帮助

推荐答案

如果您习惯于编写 C 代码,那么使用 VHPI 实现您想要的应该很简单,尽管遗憾的是,尽管 Mentor 是 VHDL 标准的一部分,但并非如此计划实施它.但是,尽管您被锁定在专有接口中,但也可以使用 FLI.

If you're comfortable writing C code it should be straightforward to achieve what you want using the VHPI, although sadly despite being part of the VHDL standard Mentor are not planning to implement it. However it will also be possible using FLI although you're locked into a proprietary interface.

像这样:

procedure get_signal_value_as_string(
    vhdl_path : IN string;
    vhdl_value: OUT string);

attribute FOREIGN of get_signal_value_as_string : procedure is "my_func mylib.so";

procedure get_signal_value_as_string(
    vhdl_path : IN string;
    vhdl_value: OUT string) is
begin
    report "ERROR: foreign subprogram get_signal_value_as_string not called";
end;

然后在 C:

#include <stdio.h>
#include "mti.h"


/* Convert a VHDL String array into a NULL terminated string */ 
static char *get_string(mtiVariableIdT id)
{
    static char buf[1000];
    mtiTypeIdT type;
    int len;
    mti_GetArrayVarValue(id, buf);
    type = mti_GetVarType(id);
    len = mti_TickLength(type);
    buf[len] = 0;
    return buf;
}


void my_func (
    mtiVariableIdT vhdl_path /* IN string */
    mtiVariableIdT vhdl_value /* OUT string */
    )
{
    mtiSignalIdT sigID = mti_FindSignal(get_string(vhdl_path));
    mtiInt32T value = mti_GetSignalValue(sigID);

    ...
}

FLI 手册中有大量示例代码.

Plenty of example code in the FLI manual.

这篇关于Modelsim/读取信号值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆