首页 > 解决方案 > 是否可以选择将一些代码合成为 verilog 内置原语?

问题描述

我以为techmap没有任何争论就可以做到,但事实并非如此。可能我误解了“逻辑综合”的含义。

基本示例:

AND_GATE.v:

module AND_GATE( input A, input B, output X);
    assign X = A & B;
endmodule
yosys> read_verilog AND_GATE.v
yosys> synth
....................
   Number of wires:                  3
   Number of wire bits:              3
   Number of public wires:           3
   Number of public wire bits:       3
   Number of memories:               0
   Number of memory bits:            0
   Number of processes:              0
   Number of cells:                  1
     $_AND_                          1
yosys> abc -g AND,NAND,OR,NOR,XOR,XNOR
........................
3.1.2. Re-integrating ABC results.
ABC RESULTS:               AND cells:        1
ABC RESULTS:        internal signals:        0
ABC RESULTS:           input signals:        2
ABC RESULTS:          output signals:        1
Removing temp directory.

yosys> clean
Removed 0 unused cells and 3 unused wires.
yosys> write_verilog net.v

网络.v

module AND_GATE(A, B, X);
  (* src = "AND_GATE.v:1" *)
  input A;
  (* src = "AND_GATE.v:1" *)
  input B;
  (* src = "AND_GATE.v:1" *)
  output X;
  assign X = B & A;
endmodule

标签: yosys

解决方案


使用类似的东西synth; abc -g AND,NAND,OR,NOR,XOR,XNOR将映射到一组与 Verilog 原语等效的基本门 -techmap它本身也不会让你远离 - 但是 Yosys verilog 后端没有使用内置原语的选项,它总是写大门作为他们的表达方式。


推荐阅读