-1

我想看看 Yosys 是否符合我的要求。我想做的是在 Verilog 代码中找到一个操作(例如 temp = 16*val1 + 8*val2 )并将其替换为另一个操作,例如( temp = val1 << 4 + val2 << 3 )。

我需要向 Yosys 学习和使用哪些部分?如果有人知道要使用的命令集,他/她可以告诉我以提高我的学习曲线吗?

谢谢。

4

1 回答 1

0

例如,考虑以下 verilog 输入 ( test.v):

module test(input [7:0] val1, val2, output [7:0] temp);
  assign temp = 16*val1 + 8*val2;
endmodule

该命令yosys -p 'prep; opt -full; show' test.v将生成以下电路图:

在此处输入图像描述

写入控制台的输出包含以下内容:

3.1. Executing OPT_EXPR pass (perform const folding).
Replacing multiply-by-16 cell `$mul$test.v:2$1' in module `\test' with shift-by-4.
Replacing multiply-by-8 cell `$mul$test.v:2$2' in module `\test' with shift-by-3.
Replacing $shl cell `$mul$test.v:2$1' (B=3'100, SHR=-4) in module `test' with fixed wiring: { \val1 [3:0] 4'0000 }
Replacing $shl cell `$mul$test.v:2$2' (B=2'11, SHR=-3) in module `test' with fixed wiring: { \val2 [4:0] 3'000 }

阅读的两行Replacing multiply-by-* cell是您提到的转换。之后的两行用接线代替了恒定移位操作,使用{val1[3:0], 4'b0000}{val2[4:0], 3'b000}作为加法器的输入。

这是在opt_expr通行证中完成的。查看passes/opt/opt_expr.cc它的源代码以了解它是如何完成的。

于 2016-04-12T08:29:40.677 回答