Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

How to read FPGA serial number programmatically?

Using Nios II, there is a need to read serial number of let's say Cyclone II. Can it be done, and how?

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Only if you add an avalon slave (or custom instruction) to return the value from somewhere.

    Possibly you could set the 'cpuid' register (control register 5) to some useful value.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I used to do this to cook build numbers into the FPGA image so I could read it back if I ever needed to know what's currently operating in the FPGA. If you want something that you manually set once you can make a simple SOPC Builder/Qsys component that hardcodes the readdata line to whatever parameter setting you want. i.e. something like this:

    module serial_number_reader (clk, reset, address, read, readdata);

    input clk;

    input reset;

    input address;

    input read;

    output wire readdata;

    parameter SERIAL_NUMBER = 32'hDEADBEEF;

    assign readdata = SERIAL_NUMBER;

    endmodule

    Then when you instantiate it you type the serial number into it as a parameter and every time you read from the component that value is returned. If you want something more programmatic for a build system you can use an pre-initialized on-chip RAM where your build system spits out a new .hex/.mif file before the hardware is compiled. If you want a true 'serial number' system (where each FPGA/board has it's own serial number programmed at the factory) you'll need something programmable on the board that Nios II can read from with the serial number burned into it.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    There are some chips with unique serial numbers, such as MAXIM's DS2401.