- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试了解如何创建一个 C++ 测试台以在 Verilog 中驱动对 DUT 的激励。假设我有一个简单的场景:
// Testbench Top.
module tb_top();
import "DPI-C" function void wait_for_input_ready();
initial
wait_for_input_ready();
import "DPI-C" function void notify_input_ready();
always @(posedge clk or negedge rst)
begin
// based on some condition here I want to send input-ready notify.
notify_input_ready();
end
endmodule
这是我的 C++ 代码:
测试用例.h
extern "C" void wait_for_input_ready();
extern "C" void notify_input_ready();
测试用例.cpp
#include "test_case.h"
std::conditional_variable cond_var;
std::mutex input_mutex;
bool input_ready = false;
void wait_for_input_ready()
{
std::unique_lock<std::mutex> lock(input_mutex);
while(input_ready != true)
cond_var.wait(lock, [&]{return input_ready == true;}); // This is where the problem happens.
}
void notify_input_ready()
{
std::unique_lock<std::mutex> lock(input_mutex);
is_ready = true;
cond_var.notify_one(); // Unblock to wait statement.
}
在这个例子中,条件变量上的等待语句永远阻塞并且不会让模拟器执行 Verilog 代码的任何其他部分。那么这里正确的方法是什么?我应该在 wait_for_input_ready 函数内用 C++ 创建一个线程并将其完全分离吗?
最佳答案
您不能将 SystemVerilog 线程的概念与 C++ 线程混合使用。从 DPI 的角度来看,一切都在同一个线程中执行。如果您希望 C++ 代码看起来像一个 SystemVerilog 线程,您需要将 C++ 代码作为任务导入,并让它调用导出的 SystemVerilog 任务。
关于c++ - 创建 C++ 测试台以驱动 Verilog DUT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33208099/
我正在尝试了解如何创建一个 C++ 测试台以在 Verilog 中驱动对 DUT 的激励。假设我有一个简单的场景: // Testbench Top. module tb_top(); impor
我想启动 Linux 服务器并发出命令,等待 5 秒,然后使用 python 脚本在 DUT 上发出命令。 是否可以在单个 python 脚本中完成,或者如果我们使用 2 个 python 脚本该怎么
我有两个表 表库存: item_no item_name item_qty 表格位置: orderno qty 我想将购买的商品(qty) 扣除到库存商品(item_qty) 中。所以我可以直接更新
我是一名优秀的程序员,十分优秀!