USERCODE Register in Xilinx Spartan 3E

The following setup was used for Basys2 board with an external FTDI-based JTAG adapter. Read the previous posts to get familiar with setup.

Specifying USERCODE

User code register provides bit stream identification and a type of version control. To write a user code into a bit stream in Xilinx ISE, go to "Implementation" -> "Design" and right-click on "Generate Programming File". In the popped up window specify your 32-bit user code in hexadecimal format:

For example, I set it to 0xADEAFBEE. Now generate the *.bit file in Xilinx ISE and analyze its header using bitparse utility, which is a part of xc3sprog:

UserID field tells that its value is embedded into the bit stream and will be written to the USERCODE during configuration.
Now program the FPGA using xc3sprog:

Reading USERCODE in UrJTAG

While your program is running on the FPGA, run UrJTAG:

The USERCODE instruction selects USERCODE register as data register. Shifting 32 bits into the data register will yield our user code.

Reading USERCODE in OpenOCD

While your program is running on the FPGA, start OpenOCD server:

In other terminal, connect as a client:

The user code is successfully retrieved.

2 thoughts on “USERCODE Register in Xilinx Spartan 3E

  1. martin

    Dear Isabekov,

    Thanks for publishing the this post (and your post about reading the DNA). I am able to reproduce both on my Spartan 6, with UrJtag.

    I also want to read the Fuse Control bits, but I do not succeed.
    https://www.xilinx.com/support/documentation/user_guides/ug380.pdf - PAGE 96

    Reading the EAS works fine:
    jtag> register FUSE_KEY 256
    jtag> instruction FUSE_KEY 111011 FUSE_KEY
    jtag> instruction FUSE_KEY
    jtag> shift ir
    jtag> shift dr
    jtag> dr

    But this when I execute the code below, I only receive zeros. The MSB should be at least one.
    jtag> register FUSE_CNTL 32
    jtag> instruction FUSE_KEY 111011 FUSE_KEY
    jtag> instruction FUSE_KEY
    jtag> shift ir
    jtag> shift dr
    jtag> dr
    00000000000000000000000000000000 (0x00000000)

    Can you please give me some hints how to do this?

    Thanks in advance,

    Martin

    Reply
    1. isabekov

      Post author

      Hi Martin,
      It looks like the instruction you want to use is FUSE_CNTL, whose opcode is 6'h34 i.e. (110100). Try this:
      jtag> register FUSE_CNTL 32
      jtag> instruction FUSE_CNTL 110100 FUSE_CNTL
      jtag> instruction FUSE_CNTL
      jtag> shift ir
      jtag> shift dr
      jtag> dr

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *