How to set up a pull up pin to high and low in FPGA?
You don’t actually set the pull-up itself “high or low” — you either let the pull-up win (high) or override it by driving low.
Let’s break it down in FPGA terms.
1. What a “pull-up pin” really is
A pull-up (internal or external resistor to VCC) makes the pin:
-
HIGH by default (when nothing is driving it),
-
but still allows something to pull it LOW (switch, another device, or your FPGA output).
So for a pull-up pin you usually have these modes:
-
Input with pull-up → used for buttons, open-collector signals, etc.
-
Open-drain / open-collector style output with pull-up → used for shared lines (I²C-like).
You control HIGH/LOW by either:
-
Releasing the pin (high-impedance
Z) → pull-up makes it HIGH -
Actively driving
0→ forces it LOW
2. HDL pattern: open-drain pin with pull-up
Say you have an I/O pin io_line with a pull-up (internal or external).
In Verilog:
-
To get LOW on the pin:
drive_low <= 1'b1;→ FPGA drives0. -
To get HIGH on the pin:
drive_low <= 1'b0;→ FPGA drivesZ, pull-up pulls it to 1.
Important: With a pull-up, you normally do not drive 1, you either drive 0 or Z. That’s how open-drain works and avoids bus fights.
3. Input with pull-up (e.g. button to GND)
If the pin is only an input:
-
You configure the pin as input with pull-up in your constraints / tool.
-
In HDL it’s just:
-
Externally:
-
btn→ button → GND -
When button not pressed → pull-up makes
btn = 1 -
When button pressed → GND pulls
btn = 0
-
You don’t “set” it high or low in HDL; you read it and the external circuit decides the level against the pull-up.
4. Where you actually turn on the pull-up
This is vendor/tool specific and not done by assigning 1/0 in HDL.
Xilinx (Vivado) example
In the .xdc constraint file:
Or instantiate the PULLUP primitive (older flows).
Intel / Altera (Quartus) example
Use the Assignment Editor or .qsf:
(Exact name can vary by family, but it’s something like “weak pull-up resistor”.)
Lattice / others
Similar: in the pin constraints or via pin property dialog (“Pull-Up enable”).
5. Quick mental recipe
To use a pull-up pin in an FPGA:
-
Enable pull-up for that pin in the constraints (or add an external resistor).
-
Decide if the pin is:
-
Input → just read it, external circuitry pulls low.
-
Open-drain I/O → use
inoutand drive0/Zin HDL.
-
-
Logic for HIGH/LOW:
-
HIGH = tri-state (Z) → pull-up wins.
-
LOW = drive
0.
-

评论
发表评论