FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6462 Discussions

How to read FPGA serial number programmatically?

Altera_Forum
Honored Contributor II
2,207 Views

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

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
1,142 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
1,142 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
1,142 Views

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

0 Kudos
Reply