Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 无法传给 Verilator 多参数 #30

Open
Devil-SX opened this issue Feb 3, 2025 · 3 comments
Open

[BUG] 无法传给 Verilator 多参数 #30

Devil-SX opened this issue Feb 3, 2025 · 3 comments

Comments

@Devil-SX
Copy link

Devil-SX commented Feb 3, 2025

我原本各种版本代码都放在某个目录下,靠传入 -y 参数 verilator 自动 search module 解析需要的文件。我尝试用在 picker 中指定 -V + -y 的方法指定 include dir

  • 如果使得 makefile 的 SIMULATOR_FLAGS 中没有任何引号,似乎 -y 会被 CMake 识别到而非被 simulator 捕捉到,报错 CMake Error: Unknown argument -f
  • 如果使得 SIMULATOR_FLAGS 包含引号,这个参数整体会被当做一个位置参数输入 verilator,从而定义为模块名,使得 verilator 开始寻找 -y xxx 的模块名。无论是单个单引号、单个双引号、还是 README 中给出的单双引号结合都是这样的结果。

我又尝试了只传输一个 verilator 选项,能够正确识别传输。现有仓库似乎无法正确传输多个参数给 verilator backend。

@Makiras
Copy link
Contributor

Makiras commented Feb 4, 2025

可以尝试使用分号切分不同参数

@Devil-SX
Copy link
Author

Devil-SX commented Feb 4, 2025

尝试添加分号,报错

不给参数加引号

生成的 makefile 的 SIMULATOR_FLAGS 变量是这样的

export SIMULATOR_FLAGS := -y <pathA>; -y <pathA>; -y <pathA>

报错

-- Executing Verilator...
Verilator command: "... verilator_bin ... -y <pathA> -y <pathB> -y<pathC> ..."
Output:
%Error: Invalid option: -y <pathA>
...
/bin/sh: 2: -y: not found
/bin/sh: 2: -y: not found
/bin/sh: 2: -y: not found
/bin/sh: 2: -y: not found

似乎将 -y <path> 当作一个整体了,即使中间有空格,并且之后的 -y 都识别为新的命令了而不是 -V 的参数。

给参数加引号

生成的 makefile 的 SIMULATOR_FLAGS 变量是这样的

export SIMULATOR_FLAGS := "-y <pathA>; -y <pathB>; -y <pathC>"

报错

-- Executing Verilator...
Verilator command: "... verilator_bin ... -y <pathA> -y <pathB> -y<pathC> ..."
Output:
%Error: Invalid option: -y <pathB>
...

无论哪种,将 log 中显示的 Verilator command 复制到终端直接调用是能够正常通过的

@Makiras
Copy link
Contributor

Makiras commented Feb 5, 2025

这个问题大概率是由于CMAKE处理ARG数组时的行为导致的,CMAKE使用分号切分arg array到arg。
verilator期望得到 ["-y", "path1", "-y", "path2"],但example传入时 ["-y path1", "-y path2"]。

export SIMULATOR_FLAGS := "-y;<pathA>;-y;<pathB>;-y;<pathC>"

或许可以尝试将所有的空格替换为分号来完成,这部分bug我们已经注意到了,正在想办法修复,也非常欢迎您能在空闲之余能看看有没有什么更优雅的解决方案。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants