2

How can I add a switchable pullup to a Tri-State pin?

There are the "Tri-State" and the "Pull-Up" blocks in icestudio. I want to combine them into a "Tri-State with Pull-Up" block that has another input that allows to enable or disable the pull-up (if the tri-state is in input mode of course).

Just using a signal ('pu') instead of a constant like shown here:

  SB_IO #(
      .PIN_TYPE(6'b1010_01),
      .PULLUP(pu)
  ) io_pin (
      .PACKAGE_PIN(pin),
      .OUTPUT_ENABLE(oe),
      .D_OUT_0(din),
      .D_IN_0(dout)
  );

results in a non-constant value error and does not synthezise.

It should synthezise and by that provide another input 'pu' that allows to set the state of the pull-up (1=enabled/on or 0=disabled/off).

If this behaviour is not possible, is there another way (work-a-round) to get switchable pullups?

2 Answers2

2

Found the answer here: https://discourse.tinyfpga.com/t/internal-pullup-in-bx/800/12

The general answer is; NO, it can't be added. There are a few dedicated pins on some FPGAs (e.g. 2 pins on the UltraPlus) that have dynamic pullup control. The SB_IO_I3C primitive supports it, confer e.g. https://github.com/cliffordwolf/icestorm/blob/master/icefuzz/tests/sb_io_i3c.v Besides these pins the general IO block on all other pins has no input for pullup control.

0

Pull-up of a pin is determined by a bit in the configuration bit-stream, and is not dynamically controllable. In Verilog all parameters to an instantiation must be constants. 'pu' must thus evaluate to a constant (1'b0 or 1'b1).

As far as I can see, you will need to do add the switchable pull-up external to your iCE40 family FPGA, using two pins:

pu -----|>---+
             |
1'b1 -------|>---[pin]-----+
                           |
oe -----|>---+            |R| 4.7k resistor or other value
             |             |
dout -------|>-+-[pin] ----+
               |
din --------<|-+
Baard
  • 809
  • 10
  • 26
  • 1
    When asking for a work-a-round I was actually considering Verilog or VHDL constructs. The concept you mention is quite intressting - thanks for the hint. I will take a mental note and have think about how to implement it in my case... ;) (I try to build an arduino equivalent on the Alhambra II board using icestudio) – Ursin Solèr Jun 12 '19 at 20:07
  • 1
    With a small change your work-a-round also allows for selecting between pullup and pulldown. – Ursin Solèr Jun 12 '19 at 20:09