vivado如何生成一个模块的带原语的网表

本文介绍了如何使用Vivado工具中的write_verilog命令生成带原语的网表文件,包括不同模式的选择,以及如何控制输出内容如包含仿真模型、保留VCC/GND等。同时,文章还提到在综合属性中设置IOBUFFER和flatten_hierarchy的注意事项。

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

vivado如何生成一个模块的带原语的网表


前言

有时候我们想生成一个网表文件,但vivado默认是会生成一个dcp的文件,加密性时非常好的,但又过于黑盒子了,而通过原理图按钮只能看到原理图图形,如果将原理图生成全部是原语的文本呢

使用write_verilog命令

在tcl输入框中使用write_verilog命令

输出网表使用以下指令 :
write_verilog -help 查看write_verilog如何使用

write_verilog E:/test5.v 这样就是输出当前设计的网表了

write_verilog


Description:
Export the current netlist in Verilog format


Syntax:
write_verilog  [-cell <arg>] [-mode <arg>] [-lib] [-port_diff_buffers]
               [-write_all_overrides] [-keep_vcc_gnd] [-rename_top <arg>]
               [-sdf_anno <arg>] [-sdf_file <arg>] [-force]
               [-include_xilinx_libs] [-logic_function_stripped] [-quiet]
               [-verbose] <file>


Returns:
the name of the output file or directory


Usage:
  Name                        Description
  ---------------------------------------
  [-cell]                     Root of the design to write, e.g.
                              des.subblk.cpu
                              Default: whole design
  [-mode]                     Values: design, pin_planning, synth_stub, sta,
                              funcsim, timesim
                              Default: design
  [-lib]                      Write each library into a separate file
  [-port_diff_buffers]        Output differential buffers when writing in
                              -port mode
  [-write_all_overrides]      Write parameter overrides on Xilinx primitives
                              even if the override value is the same as the
                              default value
  [-keep_vcc_gnd]             Don't replace VCC/GND instances by literal
                              constants on load terminals.  For simulation
                              modes only.
  [-rename_top]               Replace top module name with custom name e.g.
                              netlist
                              Default: new top module name
  [-sdf_anno]                 Specify if sdf_annotate system task statement
                              is generated
  [-sdf_file]                 Full path to sdf file location
                              Default: <file>.sdf
  [-force]                    Overwrite existing file
  [-include_xilinx_libs]      Include simulation models directly in netlist
                              instead of linking to library
  [-logic_function_stripped]  Convert INIT strings on LUTs & RAMBs to fixed
                              values.  Resulting netlist will not behave
                              correctly.
  [-quiet]                    Ignore command errors
  [-verbose]                  Suspend message limits during command execution
  <file>                      Which file to write


Categories:
FileIO, Simulation


Description:


  Write a Verilog netlist of the current design or from a specific cell of
  the design to the specified file or directory. The output is a IEEE
  1364-2001 compliant Verilog HDL file that contains netlist information
  obtained from the input design files.


  You can output a complete netlist of the design or specific cell, or output
  a port list for the design, or a Verilog netlist for simulation or static
  timing analysis.


Arguments:


  -cell <arg> - (Optional) Write the Verilog netlist from a specified cell or
  block level of the design hierarchy. The output Verilog file or files will
  only include information contained within the specified cell or module.


  -mode <arg> - (Optional) The mode to use when writing the Verilog file. By
  default, the Verilog netlist is written for the whole design. Valid mode
  values are:


   *  design - Output a Verilog netlist for the whole design. This acts as a
      snapshot of the design, including all post placement, implementation,
      and routing information in the netlist.


   *  pin_planning - Output only the I/O ports for the top-level of the design.


   *  synth_stub - Output the ports from the top-level of the design for use
      as a synthesis stub.


   *  sta - Output a Verilog netlist to be used for static timing analysis
      (STA).


   *  funcsim - Output a Verilog netlist to be used for functional
      simulation. The output netlist is not suitable for synthesis.


   *  timesim - Output a Verilog netlist to be used for timing simulation.
      The output netlist is not suitable for synthesis.


  -lib - (Optional) Create a separate Verilog file for each library used by
  the design.


  Note: The -library option can only be used for simulation. Vivado synthesis
  will treat all Verilog files as being in the default work library.


  -port_diff_buffers - (Optional) Add the differential pair buffers and
  internal wires associated with those buffers into the output ports list.
  This argument is only valid when -mode pin_planning or -mode synth_stub is
  specified.


  -write_all_overrides [ true | false ] - (Optional) Write parameter
  overrides, in the design to the Verilog output even if the value of the
  parameter is the same as the defined primitive default value. If the option
  is false then parameter values which are equivalent to the primitive
  defaults are not output to the Verilog file. Setting this option to true
  will not change the result but makes the output Verilog more verbose.


  -keep_vcc_gnd - (Optional) By default, when writing a nelist for
  simulation, or from an IP integrator block design, the Vivado Design Suite
  replaces VCC and GND primitives, and the nets they drive, with literal
  constants on each of the loads on the net. The -keep_vcc_gnd option
  disables this default behavior and preserves the VCC or GND primitives.


  -rename_top <arg> - (Optional) Rename the top module in the output as
  specified. This option only works with -mode funcsim or -mode timesim to
  allow the Verilog netlist to plug into top-level simulation test benches.


  -sdf_anno [ true | false ] - (Optional) Add the $sdf_annotate statement to
  the Verilog netlist. Valid values are true (or 1) and false (or 0). This
  option only works with -mode timesim, and is set to false by default.


  -sdf_file <arg> - (Optional) The path and filename of the SDF file to use
  when writing the $sdf_annotate statement into the output Verilog file. When
  not specified, the SDF file is assumed to have the same name and path as
  the Verilog output specified by <file>, with a file extension of .sdf. The
  SDF file must be separately written to the specified file path and name
  using the write_sdf command.


  -force - (Optional) Overwrite the Verilog files if they already exists.


  -include_xilinx_libs - (Optional) Write the simulation models directly in
  the output netlist file rather than pointing to the libraries by reference.


  -logic_function_stripped - (Optional) Hides the INIT values for LUTs & RAMs
  by converting them to fixed values in order to create a netlist for debug
  purposes that will not behave properly in simulation or synthesis.


  -quiet - (Optional) Execute the command quietly, returning no messages from
  the command. The command also returns TCL_OK regardless of any errors
  encountered during execution.


  Note: Any errors encountered on the command-line, while launching the
  command, will be returned. Only errors occurring inside the command will be
  trapped.


  -verbose - (Optional) Temporarily override any message limits and return
  all messages from this command.


  Note: Message limits can be defined with the set_msg_config command.


  <file> - (Required) The path and filename of the Verilog file to write. The
  path is optional, but if one is not provided the Verilog file will be
  written to the current working directory, or the directory from which the
  Vivado tool was launched.


Examples:


  The following example writes a Verilog simulation netlist file for the
  whole design to the specified file and path:


    write_verilog C:/Data/my_verilog.v
    


  In the following example, because the -mode timesim and -sdf_anno options
  are specified, the $sdf_annotate statement will be added to the Verilog
  netlist. However, since the -sdf_file option is not specified, the SDF file
  is assumed to have the same name as the Verilog output file, with an .sdf
  file extension:


    write_verilog C:/Data/my_verilog.net -mode timesim -sdf_anno true
    


  Note: The SDF filename written to the $sdf_annotate statement will be
  my_verilog.sdf.


  In the following example, the functional simulation mode is specified, the
  option to keep VCC and GND primitives in the output simulation netlist is
  enabled, and the output file is specified:


    write_verilog -mode funcsim -keep_vcc_gnd out.v
    


See Also:


   *  write_sdf
   *  write_vhdl

为了在网表中不要出现IO BUFFER,在综合属性中,需要设置一下。
其次如果不想被人看到模块层次,则将-flatten_hierarchy设置为full

一个加法器

module test(
input [7:0]a_i,
input [7:0]b_i,
output [7:0]sum_o
);

assign sum_o = a_i + b_i;
endmodule

在这里插入图片描述

可得到如下网表,与上述加法器代码是等效的

module test5 (
  input [7:0]a_i,
  input [7:0]b_i,
  output [7:0]sum_o
);


wire [7:0]a_xor_b;
wire [3:0]sum_co;


  CARRY4 u0_CARRY4 (.CI(1'b0     ),.CO(sum_co[3:0]),.CYINIT(1'b0),.DI(a_i[3:0]),.O(sum_o[3:0]),.S(a_xor_b[3:0]));
  CARRY4 u1_CARRY4 (.CI(sum_co[3]),.CO(           ),.CYINIT(1'b0),.DI(a_i[7:4]),.O(sum_o[7:4]),.S(a_xor_b[7:4]));
  LUT2 #(.INIT(4'h6)) u0_LUT2 (.I0(a_i[0]),.I1(b_i[0]),.O(a_xor_b[0] ));
  LUT2 #(.INIT(4'h6)) u1_LUT2 (.I0(a_i[1]),.I1(b_i[1]),.O(a_xor_b[1] ));
  LUT2 #(.INIT(4'h6)) u2_LUT2 (.I0(a_i[2]),.I1(b_i[2]),.O(a_xor_b[2] ));
  LUT2 #(.INIT(4'h6)) u3_LUT2 (.I0(a_i[3]),.I1(b_i[3]),.O(a_xor_b[3] ));
  LUT2 #(.INIT(4'h6)) u4_LUT2 (.I0(a_i[4]),.I1(b_i[4]),.O(a_xor_b[4] ));
  LUT2 #(.INIT(4'h6)) u5_LUT2 (.I0(a_i[5]),.I1(b_i[5]),.O(a_xor_b[5] ));
  LUT2 #(.INIT(4'h6)) u6_LUT2 (.I0(a_i[6]),.I1(b_i[6]),.O(a_xor_b[6] ));
  LUT2 #(.INIT(4'h6)) u7_LUT2 (.I0(a_i[7]),.I1(b_i[7]),.O(a_xor_b[7] ));
  
endmodule
<think>好的,我现在需要帮助用户解决在Vivado中修改CORE生成器内部使用的底层原语的问题。用户提到想找到方法或教程来自定义或修改这些底层原语实例。首先,我需要回顾一下Vivado中关于IP核和CORE Generator的相关知识。 首先,Vivado的IP核通常是通过IP Integrator或CORE Generator创建的,它们封装了底层原语,比如Block RAM、DSP slices等。用户想要修改这些底层原语,可能需要涉及到IP核的定制或者手动实例化原语。 根据引用[2]中的内容,Block Memory Generator的使用文档pg058提到,IP核的参数设置会影响底层原语的选择。比如,内存类型可以选择分布式RAM或Block RAM。这可能是一个切入点,用户可以通过调整IP核的参数来间接选择底层原语。因此,在Vivado中定制IP核时,某些选项可能允许选择不同的原语类型,比如在Block Memory Generator中选择使用LUTRAM还是BRAM。 接下来,引用[3]提到了使用Embedded FIFO Generator时设置FIFO Read Latency的值。这说明不同的参数配置会影响底层实现,可能涉及到不同的原语或配置方式。因此,用户可能需要通过调整IP核的参数来影响原语的选择,而不是直接修改原语实例。 但用户的问题更倾向于直接修改或替换底层原语实例。这时候可能需要考虑手动实例化原语。例如,在HDL代码中直接使用原语,而不是依赖IP核的自动生成。引用[4]中的示例代码展示了如何实例化一个FIFO模块,可能用户需要类似的底层原语实例化,但需要替换成自己需要的原语。 然而,直接修改CORE Generator生成的IP核的底层原语可能不可行,因为这些IP核通常是预编译或加密的。因此,用户可能需要通过生成输出产品(OOC)的方式,将IP核生成为可编辑的HDL代码,从而修改其中的原语实例。具体步骤可能包括在IP核设置中启用“Out of Context”综合,然后生成并编辑生成的HDL文件。 另外,引用[1]中提到约束差分时钟对的方法,可能涉及到原语的约束,但这里可能关联性不大。不过,用户可能需要了解如何对原语进行时序约束,这也是修改原语后的必要步骤。 总结可能的解决步骤: 1. 在IP核定制过程中选择所需的原语类型,例如在Block Memory Generator中选择分布式或Block RAM。 2. 生成IP核的Out of Context输出产品,获取可编辑的HDL代码,手动修改其中的原语实例。 3. 直接手动实例化所需原语,代替使用IP核生成。 4. 使用Xilinx提供的原语模板,在代码中直接例化,并通过参数配置来满足需求。 需要验证这些步骤的正确性,特别是关于OOC生成后的修改是否可行。例如,是否允许用户修改生成的HDL中的原语实例,或者是否有版本兼容性问题。此外,用户需要注意不同系列器件的原语可能不同,需要参考相应的文档。 可能的问题:用户可能不清楚如何生成可编辑的IP核代码,或者遇到生成后的代码被加密无法修改的情况。因此,需要确认哪些IP核允许生成可编辑的代码,例如某些旧版IP或Xilinx参数化模块(XPM)可能更灵活。引用[3]提到以XPM方式使用RAM或FIFO,可能XPM提供了更多的可配置性,用户可以考虑使用XPM宏来替代CORE Generator的IP,从而更容易修改底层原语。 因此,可能的解决方案包括: - 使用XPM宏代替传统的IP核,因为XPM允许更直接的代码修改。 - 在IP核设置中尽可能调整参数以选择不同的原语类型。 - 手动实例化原语并自行连接逻辑,绕过IP核的自动生成。 需要将这些步骤详细列出,并确保每个步骤有相应的文档或引用支持,例如引用Xilinx文档pg058或用户指南中的相关部分。同时,提醒用户在修改原语时需注意设计约束和时序分析,确保修改后的设计满足性能要求。</think>在Vivado中自定义或修改CORE Generator生成的IP核底层原语实例,需通过以下步骤实现: ### 1. **通过IP参数间接选择原语类型** - **在IP定制界面调整参数**: 大多数IP核(如Block Memory Generator或FIFO Generator)提供参数选项以选择底层硬件资源类型。例如: - 在Block Memory Generator中选择内存类型为分布式RAM(基于LUT)或块RAM(BRAM)[^2]; - 在FIFO Generator中设置读写延迟或同步/异步模式以匹配原语特性[^3]。 - **示例操作**: 在IP配置向导中,通过`Memory Type`或`Primitives Output`等选项直接关联底层原语。 ### 2. **生成可编辑的IP核源码** - **启用"Out of Context (OOC)"模式**: 在IP核属性中勾选`Generate Output Products`,选择`Out of Context`生成独立的HDL文件。此操作会生成未加密的RTL代码,允许直接修改原语实例[^2]。 - **修改生成的代码**: 打开生成的`.v`/`.vhd`文件,定位到原语实例化部分(如`RAMB36E1`或`FDCE`),替换为所需原语(如`LUT6`或`DSP48E1`)。 ### 3. **手动实例化原语** - **直接调用Xilinx原语模板**: 在HDL代码中手动编写原语实例,例如: ```verilog // Block RAM原语实例化示例 RAMB36E1 #( .DOA_REG(1) ) ram_inst ( .DOADO(data_out), .ADDRARDADDR(address), .CLKARDCLK(clk), .ENARDEN(enable) ); ``` - **Xilinx原语库参考**: 需查阅器件手册(如UltraScale Architecture Libraries Guide)获取原语名称与参数列。 ### 4. **使用Xilinx参数化宏(XPM)** - **替代传统IP核**: XPM库(如`xpm_memory`或`xpm_fifo`)提供可配置的RTL模板,支持直接修改原语类型。例如: ```verilog xpm_memory_sdpram #( .MEMORY_SIZE(1024), .MEMORY_PRIMITIVE("block") // 可改为"distributed"或"ultra" ) u_ram (...); ``` 通过参数`MEMORY_PRIMITIVE`可灵活切换原语类型。 ### 注意事项 - **时序与资源约束**:修改原语后需重新添加时序约束(如`set_property CLOCK_DEDICATED_ROUTE FALSE`[^1])以匹配新原语的特性。 - **仿真验证**:修改后的设计需通过行为级仿真(如Testbench[^4])和时序仿真确保功能正确。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FPGA十年老鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值