code += 'PULLMODE=' + pullmode;
to:
if (pullmode == 'UP'|| pullmode == 'DOWN'){
code += 'PULLMODE=' + pullmode;
}
So in the end, if pinout.json (board constraints) has a pullmode set to UP or DOWN, then the FPGA pin will be set to
So in the end, if in pinout.json (board constrains) we have a pullmode set to UP or DOWN then the fpga pin is set to that mode !
And in the opposite case (NONE or anything-else), then the pullmode can be set inside our icestudio blocks with verilog)
if you want to try, i
am joining:
- the testecp5pullup .ice file
- and the compile.js ( for this one you have to replace in the name .txt by .js) (shitty "google group" limitation on the up-loadable files types)
@ Fernando: If you see a problem with this, just let me know. If not, I can submit a pull request for that little change!
I also
want
to pull-request the addition of the pull-up blocks to the IceIo collection.
@ Fernando: Which solution do you prefer, a) or b)?
With a), we have a clear view of the use of primitives directly inside icestudio. It’s good for playing with the code.
With b), the primitives are hidden in yosys, but when yosys is updated, the blocks are also automatically updated!
Two side remarks:
@juan @Carlos: In the last yosys versions (not the one we have now in icestudio), the cellio.vh file includes the line:
module IBPU ((* iopad_external_pin *) input I, output O); (* PULLMODE="UP" *) TRELLIS_IO #(.DIR("INPUT")) _TECHMAP_REPLACE_ (.B(I), .O(O)); endmodule
As you can see, there is a new attribute (* iopad_external_pin *) before an input port!
Actually, in icestudio, we cannot add those kinds of attributes for ports (if needed someday). Because in Verilog, those attributes need to be inserted just before the port names!
And to get that, we will need:
1- to modify the parsing of the data entered in the "input/output ports" dialog box of our code block. To make it accept attributes (eg: like
(* iopad_external_pin *) )
2- ensure that this new information is correctly added
to the main.v file
(
means checking code += in compile.js , around line 110)
I can try to have a look at that implementation , what do you think ?!
@ Fernando: A little comment about “The Universal Pull-Up” (valid for ICE40 and ECP5) Verilog code you used in your last version of Megadrive project:
// Universal Pull up
assign o = (i===1'bz) ? 1'b1 : i;
As I understand it, this doesn’t really set a pull-up resistor at the input!
It tries to test if the input is Hi-Z (unless I am wrong; I think this test is not possible with FPGAs as it’s a bit too complicated to implement in the electronics of the chip for every pin).
If I understand correctly, that “bz” should mainly be used for setting the outputs to high-z !
Sorry for that long, dirty post ;-)
Have a nice week guys!