如何使用 Unix 脚本选择 Verilog 测试文件?

发布于 2024-10-22 21:55:31 字数 298 浏览 2 评论 0原文

我必须对DPRAM进行验证。

每个测试用例都写在名为 test1.v、test2.v 等的不同文件中。

我想编写一个脚本(unix),这样当我输入 run test1.v 时,只有该测试用例才会运行。

注意:- test1.v 仅包含任务,包括读断言、写断言等。

测试平台是一个单独的文件,其中包括时钟和组件实例化。

当 run test1.v 完成后,它应该将 test1.v 任务链接到测试平台,然后获得输出。

我已经用 verilog 完成了编码

如何做到这一点?

I have to do the verification of DPRAM.

Each test case is written in different file named test1.v,test2.v etc.

I want to write a script(unix) such that when I type run test1.v then only that test case will run.

Note :- test1.v contents only task which includes read assert,write assert etc.

The test bench is a separate file which includes clock and component instantiation.

when run test1.v is done then it should link the test1.v task to the testbench and then output is obtained.

I have done the coding in verilog

How to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

第几種人 2024-10-29 21:55:31

因此,据我所知,您的不同测试或“测试用例”位于名为 test.v 的文件中。我假设每个测试用例都有一个在所有文件中具有相同名称的任务,例如 run_testcase。这意味着您的测试平台(例如 testbench.v)必须类似于:

module testbench();   
   ...
   `include "test.v" // <- problem is this line
   ...
   initial begin 
     // Some setup
     run_testcase();
     //
     $finish;
  end
endmodule

所以您的问题是 include 行 - 根据测试用例需要包含不同的文件。我可以想到解决这个问题的两种方法,第一种方法是 toolic 建议的 - 使用符号链接“重命名”测试用例文件。因此,启动 sim 的示例包装脚本 (run_sim1) 可能看起来有点像:

#! /usr/bin/env sh
testcase=$1
ln -sf ${testcase} test.v
my_simulator testbench.v

另一种方法是使用宏,并在模拟的包装脚本中定义它。您的测试平台将修改为如下所示:

   ...
   `include `TESTCASE
   ...

包装脚本 (run_sim2):

#! /usr/bin/env sh
testcase=$1
my_simulator testbench.v +define+TESTCASE=\"${testcase}\"

引号在这里很重要,因为 verilog include 指令需要它们。不幸的是,我们不能在测试台中留下引号,因为它在 verilog 中看起来就像一个字符串,并且 TESTCASE 宏不会被扩展。

So, as far as I can make out, your different tests, or 'testcases' are in files named test<n>.v. And I'll assume that each of these testcases has a task that has the same name in all files, say run_testcase. This means that your testbench (testbench.v, say) must look something like:

module testbench();   
   ...
   `include "test.v" // <- problem is this line
   ...
   initial begin 
     // Some setup
     run_testcase();
     //
     $finish;
  end
endmodule

So your problem is the include line - a different file needs to be included depending on the testcase. I can think of two ways of solving this first one is as toolic suggested - using a symbolic link to 'rename' the testcase file. So an example wrapper script (run_sim1) to launch your sim might look a bit like:

#! /usr/bin/env sh
testcase=$1
ln -sf ${testcase} test.v
my_simulator testbench.v

Another way is to use a macro, and define this in the wrapper script for your simulation. Your testbench would be modified to look like:

   ...
   `include `TESTCASE
   ...

And the wrapper script (run_sim2):

#! /usr/bin/env sh
testcase=$1
my_simulator testbench.v +define+TESTCASE=\"${testcase}\"

The quotes are important here, as the verilog include directive expects them. Unfortunately, we can't leave the quotes in the testbench because it will then look like a string to verilog, and the TESTCASE macro won't be expanded.

寂寞花火° 2024-10-29 21:55:31

一种方法是让测试台文件包含一个具有通用名称的测试文件:

`include "test.v"

然后,让您的脚本创建指向您要运行的测试的符号链接。例如,在 shell 脚本或 Makefile 中,要运行 test1.v

ln -sf test1.v test.v
run_sim

要运行 test2.v,您的脚本将用 test2 替换 test1,等等。

One way to do it is to have the testbench file include a test file with a generic name:

`include "test.v"

Then, have your script create a symbolic link to the test you want to run. For example, in a shell script or Makefile, to run test1.v:

ln -sf test1.v test.v
run_sim

To run test2.v, your script would substitute test2 for test1, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文