set_property PULLDOWN true [get_ports <ports>]

Vivado下拉电阻约束设置

       set_property PULLDOWN true [get_ports <ports>] Xilinx Vivado工具中的Tcl约束命令

一、命令解析

set_property PULLDOWN true [get_ports <port_name>]
  • set_property: Vivado的属性设置命令

  • PULLDOWN true: 启用下拉电阻属性

  • get_ports: 获取指定端口

  • <port_name>: 目标端口名称

二、使用场景

1. 在XDC约束文件中使用

# 约束文件: design_constraints.xdc

# 为单个端口设置下拉
set_property PULLDOWN true [get_ports config_pin]

# 为多个端口设置下拉
set_property PULLDOWN true [get_ports {pin1 pin2 pin3}]

# 为总线设置下拉
set_property PULLDOWN true [get_ports {data_bus[0] data_bus[1] data_bus[2]}]

2. 在Vivado Tcl控制台中使用

# 交互式设置下拉电阻
set_property PULLDOWN true [get_ports btn_reset]
set_property PULLDOWN true [get_ports dip_switch[3]]

三、完整设计示例

1. Verilog代码

module fpga_design(
    input wire clk,
    input wire config_pin,    // 配置引脚,需要下拉
    input wire btn_reset,     // 按钮输入,需要下拉
    input wire [1:0] dip_sw,  // 拨码开关,需要下拉
    output reg [3:0] leds
);
    
    // 设计逻辑
    always @(posedge clk) begin
        if (btn_reset) 
            leds <= 4'b0000;
        else 
            leds <= {config_pin, dip_sw};
    end
    
endmodule

2. 对应的XDC约束文件

# 时钟约束
create_clock -period 10.000 -name clk [get_ports clk]

# 下拉电阻约束
set_property PULLDOWN true [get_ports config_pin]
set_property PULLDOWN true [get_ports btn_reset]
set_property PULLDOWN true [get_ports {dip_sw[0] dip_sw[1]}]

# I/O标准约束
set_property IOSTANDARD LVCMOS33 [get_ports {clk config_pin btn_reset dip_sw[*]}]

四、相关约束命令

1. 上拉电阻

set_property PULLUP true [get_ports i2c_sda]

2. 驱动强度

set_property DRIVE 12 [get_ports output_pin]  # 12mA驱动强度

3. 施密特触发器

set_property SCHMITT_TRIGGER true [get_ports input_pin]

五、实际应用场景

1. 按钮和开关输入

# 防止按钮未按下时悬空
set_property PULLDOWN true [get_ports {btn_up btn_down btn_left btn_right}]

2. 配置引脚

# 配置引脚默认下拉
set_property PULLDOWN true [get_ports boot_sel]
set_property PULLDOWN true [get_ports mode_config]

3. 通信接口

# SPI片选信号下拉
set_property PULLDOWN true [get_ports spi_cs_n]

六、注意事项

  1. 工具特定: 这是Vivado工具约束,不是Verilog标准

  2. 物理实现: 实际在FPGA中配置物理下拉电阻

  3. 优先级: 约束会覆盖Verilog代码中的PULLDOWN原语

  4. 验证: 在Implementation后的IO Ports报告中查看实际配置

七、其他FPGA工具的类似功能

1. Intel Quartus

# Quartus Assignment File (.qsf)
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to config_pin
# 或者使用下拉
set_instance_assignment -name ENABLE_INPUT_PULL_DOWN ON -to btn_reset

2. Lattice Diamond

# Preference Constraints File (.pcf)
PULLDOWN "config_pin";

这些约束命令都是在综合/实现阶段告诉FPGA工具如何在物理上配置IO引脚的特性。

vivado 2018.3 中的工程,芯片选择是选择xc7a100tfgg484-2L芯片,按照下面我给你的要求,先给出我实验步骤,从新建文件开始,下面已经给出引脚约束,切记不要修改我的引脚约束,数管码数字要求初始值显示为00000000,TOP.v要适应我的应交约束,若要修改引脚,切记只能修改TOP中的代码,我的开发板上sw[31:0]是这样排布的: (一共两排)上面一排:31——16,下面一排:15——0, 我的swb是从swb1开始的有swb1——swb8 给出我项目结构及相应模块代码: 实现一个具有基本ALU模块、寄存器堆模块和存储器模块的简单计算机。 !!!!!要求:要求ALU为32位的,具有8个基本功能,功能表如下;寄存器堆模块是一个32×32位的三端口寄存器堆,其中有2个读端口,1个写端口,寄存器访问地址5为,寄存器为32位,其功能表如下;存储器使用Memory IP核生成,为256×8位的单端口的物理存储器,按字节编址(地址线8位),按字(32位)访问,小端存储模式,按字访问时,须边界对齐,存储器功能如下。 ALU功能表 ALU_OP[3:0] ALU功能 操作说明 0000 and 逻辑与操作 0001 or 逻辑或操作 0010 xor 逻辑异或操作 0011 nor 逻辑或非操作 0100 add 算术加操作 0101 sub 算术减操作 0110 slt 若A<B,则输出1,否则输出0 0111 sll B逻辑左移A所指定的位数 1000~1111   扩展保留 ALU通过4根控制线ALU_OP[3:0]来选择16种运算功能,具体功能如上所示,其中算术运算用补码实现,即输入输出均为补码(只进行整数运算)。 寄存器功能表 端口 地址输入 数据输入 数据输出 Write_Reg 操作 A端口 R_Addr_A —— R_Data_A x 读A口数据 B端口 R_Addr_B —— R_Data_B x 读B口数据 W端口 W_Addr W_Data —— 1 写入数据 存储器功能表 Mem_Write Mem_Read 地址输入 数据输入 数据输出 操作 0 1 Mem_Addr M_R_Data 读操作 1 0 Mem_Addr M_W_Data —— 写操作 0 0 —— —— —— 无操作 要求先编写以上三个基本模块,再编写一个顶层模块,完成Ri θ(addr)→Rj(寄存器和存储器到寄存器)的操作。 引脚约束: # 寮?鍚瘮鐗规祦鍘嬬缉锛屼紭鍖? .bit 鏂囦欢澶у皬 set_property BITSTREAM.GENERAL.COMPRESS TRUE [current_design] # Switch锛屽紑鍏? set_property PULLDOWN true [get_ports sw] set_property IOSTANDARD LVCMOS18 [get_ports sw] set_property PACKAGE_PIN T3 [get_ports {sw[31]}] set_property PACKAGE_PIN U3 [get_ports {sw[30]}] set_property PACKAGE_PIN T4 [get_ports {sw[29]}] set_property PACKAGE_PIN V3 [get_ports {sw[28]}] set_property PACKAGE_PIN V4 [get_ports {sw[27]}] set_property PACKAGE_PIN W4 [get_ports {sw[26]}] set_property PACKAGE_PIN Y4 [get_ports {sw[25]}] set_property PACKAGE_PIN Y6 [get_ports {sw[24]}] set_property PACKAGE_PIN W7 [get_ports {sw[23]}] set_property PACKAGE_PIN Y8 [get_ports {sw[22]}] set_property PACKAGE_PIN Y7 [get_ports {sw[21]}] set_property PACKAGE_PIN T1 [get_ports {sw[20]}] set_property PACKAGE_PIN U1 [get_ports {sw[19]}] set_property PACKAGE_PIN U2 [get_ports {sw[18]}] set_property PACKAGE_PIN W1 [get_ports {sw[17]}] set_property PACKAGE_PIN W2 [get_ports {sw[16]}] set_property PACKAGE_PIN Y1 [get_ports {sw[15]}] set_property PACKAGE_PIN AA1 [get_ports {sw[14]}] set_property PACKAGE_PIN V2 [get_ports {sw[13]}] set_property PACKAGE_PIN Y2 [get_ports {sw[12]}] set_property PACKAGE_PIN AB1 [get_ports {sw[11]}] set_property PACKAGE_PIN AB2 [get_ports {sw[10]}] set_property PACKAGE_PIN AB3 [get_ports {sw[9]}] set_property PACKAGE_PIN AB5 [get_ports {sw[8]}] set_property PACKAGE_PIN AA6 [get_ports {sw[7]}] set_property PACKAGE_PIN R2 [get_ports {sw[6]}] set_property PACKAGE_PIN R3 [get_ports {sw[5]}] set_property PACKAGE_PIN T6 [get_ports {sw[4]}] set_property PACKAGE_PIN R6 [get_ports {sw[3]}] set_property PACKAGE_PIN U7 [get_ports {sw[2]}] set_property PACKAGE_PIN AB7 [get_ports {sw[1]}] set_property PACKAGE_PIN AB8 [get_ports {sw[0]}] # Switch Button锛屾寜閽? set_property IOSTANDARD LVCMOS18 [get_ports swb] set_property PACKAGE_PIN R4 [get_ports {swb[1]}] set_property PACKAGE_PIN AA4 [get_ports {swb[2]}] set_property PACKAGE_PIN AB6 [get_ports {swb[3]}] set_property PACKAGE_PIN T5 [get_ports {swb[4]}] set_property PACKAGE_PIN V8 [get_ports {swb[5]}] set_property PACKAGE_PIN AA8 [get_ports {swb[6]}] # LED set_property IOSTANDARD LVCMOS18 [get_ports led] set_property PACKAGE_PIN R1 [get_ports {led[31]}] set_property PACKAGE_PIN P2 [get_ports {led[30]}] set_property PACKAGE_PIN P1 [get_ports {led[29]}] set_property PACKAGE_PIN N2 [get_ports {led[28]}] set_property PACKAGE_PIN M1 [get_ports {led[27]}] set_property PACKAGE_PIN M2 [get_ports {led[26]}] set_property PACKAGE_PIN L1 [get_ports {led[25]}] set_property PACKAGE_PIN J2 [get_ports {led[24]}] set_property PACKAGE_PIN G1 [get_ports {led[23]}] set_property PACKAGE_PIN E1 [get_ports {led[22]}] set_property PACKAGE_PIN D2 [get_ports {led[21]}] set_property PACKAGE_PIN A1 [get_ports {led[20]}] set_property PACKAGE_PIN L3 [get_ports {led[19]}] set_property PACKAGE_PIN G3 [get_ports {led[18]}] set_property PACKAGE_PIN K4 [get_ports {led[17]}] set_property PACKAGE_PIN G4 [get_ports {led[16]}] set_property PACKAGE_PIN K1 [get_ports {led[15]}] set_property PACKAGE_PIN J1 [get_ports {led[14]}] set_property PACKAGE_PIN H2 [get_ports {led[13]}] set_property PACKAGE_PIN G2 [get_ports {led[12]}] set_property PACKAGE_PIN F1 [get_ports {led[11]}] set_property PACKAGE_PIN E2 [get_ports {led[10]}] set_property PACKAGE_PIN D1 [get_ports {led[9]}] set_property PACKAGE_PIN B1 [get_ports {led[8]}] set_property PACKAGE_PIN B2 [get_ports {led[7]}] set_property PACKAGE_PIN N3 [get_ports {led[6]}] set_property PACKAGE_PIN M3 [get_ports {led[5]}] set_property PACKAGE_PIN K3 [get_ports {led[4]}] set_property PACKAGE_PIN H3 [get_ports {led[3]}] set_property PACKAGE_PIN N4 [get_ports {led[2]}] set_property PACKAGE_PIN L4 [get_ports {led[1]}] set_property PACKAGE_PIN J4 [get_ports {led[0]}] # 鏁扮爜绠$浉鍏? set_property IOSTANDARD LVCMOS18 [get_ports seg] set_property PACKAGE_PIN H19 [get_ports {seg[7]}] set_property PACKAGE_PIN G20 [get_ports {seg[6]}] set_property PACKAGE_PIN J22 [get_ports {seg[5]}] set_property PACKAGE_PIN K22 [get_ports {seg[4]}] set_property PACKAGE_PIN K21 [get_ports {seg[3]}] set_property PACKAGE_PIN H20 [get_ports {seg[2]}] set_property PACKAGE_PIN H22 [get_ports {seg[1]}] set_property PACKAGE_PIN J21 [get_ports {seg[0]}] set_property IOSTANDARD LVCMOS18 [get_ports which] set_property PACKAGE_PIN N22 [get_ports {which[0]}] set_property PACKAGE_PIN M21 [get_ports {which[1]}] set_property PACKAGE_PIN M22 [get_ports {which[2]}] set_property -dict {IOSTANDARD LVCMOS18 PACKAGE_PIN L21} [get_ports enable] set_property -dict {IOSTANDARD LVCMOS18 PACKAGE_PIN H4} [get_ports clk] # [Place 30-574] Poor placement for routing between an IO pin and BUFG.If this # sub optimal condition is acceptable for this design, you may use the # CLOCK_DEDICATED_ROUTE constraint in the .xdc file to demote this message to a # WARNING. However, the use of this override is highly discouraged. set_property CLOCK_DEDICATED_ROUTE FALSE [get_nets clk_IBUF] set_property CLOCK_DEDICATED_ROUTE FALSE [get_nets swb_IBUF[1]]
10-30
[DRC NSTD-1] Unspecified I/O Standard: 2 out of 60 logical ports use I/O standard (IOSTANDARD) value 'DEFAULT', instead of a user assigned specific value. This may cause I/O contention or incompatibility with the board power or connectivity affecting performance, signal integrity or in extreme cases cause damage to the device or the components to which it is connected. To correct this violation, specify all I/O standards. This design will fail to generate a bitstream unless all logical ports have a user specified I/O standard value defined. To allow bitstream creation with unspecified I/O standard values (not recommended), use this command: set_property SEVERITY {Warning} [get_drc_checks NSTD-1]. NOTE: When using the Vivado Runs infrastructure (e.g. launch_runs Tcl command), add this command to a .tcl file and add that file as a pre-hook for write_bitstream step for the implementation run. Problem ports: clk_25m_n, and clk_25m_p. 约束文件如下 ################################################################################ ## 时钟和复位 ################################################################################ ################################################################################ ## 时钟约束 (外部晶振 + Clock Wizard) ################################################################################ # 1. 外部晶振输入约束 (25MHz) ################################################################################ ## 时钟约束 (外部差分晶振) ################################################################################ # 差分时钟约束 set_property PACKAGE_PIN N21 [get_ports clk_25m_p] set_property PACKAGE_PIN N22 [get_ports clk_25m_n] # 添加N端约束 set_property IOSTANDARD LVDS33 [get_ports clk_25m_p] # 使用LVDS标准 set_property IOSTANDARD LVDS33 [get_ports clk_25m_n] # 使用LVDS标准 set_property DIFF_TERM TRUE [get_ports clk_25m_p] # 启用差分终端 set_property DIFF_TERM TRUE [get_ports clk_25m_n] # 启用差分终端 # 创建差分时钟约束 create_clock -period 40.000 -name clk_25m -waveform {0.000 20.000} [get_ports clk_25m_p] # 复位信号保持不变 set_property PACKAGE_PIN L25 [get_ports rst_n] set_property IOSTANDARD LVCMOS33 [get_ports rst_n] set_property PULLUP true [get_ports rst_n] #connect_debug_port dbg_hub/clk [get_nets clk_25m_p] ################################################################################ ## JTAG 接口 ################################################################################ set_property PACKAGE_PIN AB25 [get_ports jtag_tck] set_property IOSTANDARD LVCMOS33 [get_ports jtag_tck] set_property PACKAGE_PIN AA25 [get_ports jtag_tms] set_property IOSTANDARD LVCMOS33 [get_ports jtag_tms] set_property PACKAGE_PIN Y26 [get_ports jtag_tdi] set_property IOSTANDARD LVCMOS33 [get_ports jtag_tdi] set_property PACKAGE_PIN K26 [get_ports jtag_tdo] set_property IOSTANDARD LVCMOS33 [get_ports jtag_tdo] ################################################################################ ## Tester 接口 ################################################################################ # 测试模式输出 (Bank 14) - 双重约束确保覆盖 set_property IOSTANDARD LVCMOS33 [get_ports {test_pattern[*]}] foreach pin [get_ports {test_pattern[*]}] { set_property IOSTANDARD LVCMOS33 $pin } set_property PACKAGE_PIN F15 [get_ports {test_pattern[0]}] set_property PACKAGE_PIN G19 [get_ports {test_pattern[1]}] set_property PACKAGE_PIN F20 [get_ports {test_pattern[2]}] set_property PACKAGE_PIN H16 [get_ports {test_pattern[3]}] set_property PACKAGE_PIN G16 [get_ports {test_pattern[4]}] set_property PACKAGE_PIN C17 [get_ports {test_pattern[5]}] set_property PACKAGE_PIN B17 [get_ports {test_pattern[6]}] set_property PACKAGE_PIN E16 [get_ports {test_pattern[7]}] set_property PACKAGE_PIN D16 [get_ports {test_pattern[8]}] set_property PACKAGE_PIN A17 [get_ports {test_pattern[9]}] set_property PACKAGE_PIN A18 [get_ports {test_pattern[10]}] set_property PACKAGE_PIN B19 [get_ports {test_pattern[11]}] set_property PACKAGE_PIN A19 [get_ports {test_pattern[12]}] set_property PACKAGE_PIN E17 [get_ports {test_pattern[13]}] set_property PACKAGE_PIN E18 [get_ports {test_pattern[14]}] set_property PACKAGE_PIN D18 [get_ports {test_pattern[15]}] set_property DRIVE 8 [get_ports {test_pattern[15:0]}] # 测试状态输入 (Bank 16) - 双重约束确保覆盖 set_property IOSTANDARD LVCMOS33 [get_ports {test_status[*]}] foreach pin [get_ports {test_status[*]}] { set_property IOSTANDARD LVCMOS33 $pin } set_property PACKAGE_PIN H17 [get_ports {test_status[0]}] set_property PACKAGE_PIN H14 [get_ports {test_status[1]}] set_property PACKAGE_PIN H15 [get_ports {test_status[2]}] set_property PACKAGE_PIN G17 [get_ports {test_status[3]}] set_property PACKAGE_PIN F17 [get_ports {test_status[4]}] set_property PACKAGE_PIN F18 [get_ports {test_status[5]}] set_property PACKAGE_PIN F19 [get_ports {test_status[6]}] set_property PACKAGE_PIN G15 [get_ports {test_status[7]}] set_property PULLDOWN true [get_ports {test_status[7:0]}] # 双向探测总线 (Bank 15) - 双重约束确保覆盖 set_property IOSTANDARD LVCMOS33 [get_ports {probe_bus[*]}] foreach pin [get_ports {probe_bus[*]}] { set_property IOSTANDARD LVCMOS33 $pin } set_property PACKAGE_PIN K18 [get_ports {probe_bus[0]}] set_property PACKAGE_PIN K15 [get_ports {probe_bus[1]}] set_property PACKAGE_PIN J16 [get_ports {probe_bus[2]}] set_property PACKAGE_PIN J14 [get_ports {probe_bus[3]}] set_property PACKAGE_PIN J15 [get_ports {probe_bus[4]}] set_property PACKAGE_PIN K16 [get_ports {probe_bus[5]}] set_property PACKAGE_PIN K17 [get_ports {probe_bus[6]}] set_property PACKAGE_PIN M14 [get_ports {probe_bus[7]}] set_property PACKAGE_PIN L14 [get_ports {probe_bus[8]}] set_property PACKAGE_PIN M15 [get_ports {probe_bus[9]}] set_property PACKAGE_PIN M16 [get_ports {probe_bus[10]}] set_property PACKAGE_PIN M17 [get_ports {probe_bus[11]}] set_property PACKAGE_PIN J19 [get_ports {probe_bus[12]}] set_property PACKAGE_PIN H19 [get_ports {probe_bus[13]}] set_property PACKAGE_PIN L17 [get_ports {probe_bus[14]}] set_property PACKAGE_PIN L18 [get_ports {probe_bus[15]}] set_property PACKAGE_PIN K20 [get_ports {probe_bus[16]}] set_property PACKAGE_PIN J20 [get_ports {probe_bus[17]}] set_property PACKAGE_PIN J18 [get_ports {probe_bus[18]}] set_property PACKAGE_PIN H18 [get_ports {probe_bus[19]}] set_property PACKAGE_PIN G20 [get_ports {probe_bus[20]}] set_property PACKAGE_PIN G21 [get_ports {probe_bus[21]}] set_property PACKAGE_PIN K21 [get_ports {probe_bus[22]}] set_property PACKAGE_PIN J21 [get_ports {probe_bus[23]}] set_property PACKAGE_PIN H21 [get_ports {probe_bus[24]}] set_property PACKAGE_PIN H22 [get_ports {probe_bus[25]}] set_property PACKAGE_PIN J23 [get_ports {probe_bus[26]}] set_property PACKAGE_PIN H23 [get_ports {probe_bus[27]}] set_property PACKAGE_PIN G22 [get_ports {probe_bus[28]}] set_property PACKAGE_PIN F22 [get_ports {probe_bus[29]}] set_property PACKAGE_PIN J24 [get_ports {probe_bus[30]}] set_property PACKAGE_PIN H24 [get_ports {probe_bus[31]}] set_property DRIVE 12 [get_ports {probe_bus[31:0]}] ################################################################################ ## 配置约束 ################################################################################ set_property CFGBVS VCCO [current_design] set_property CONFIG_VOLTAGE 3.3 [current_design] set_property BITSTREAM.CONFIG.CONFIGRATE 33 [current_design] set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
08-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值