Forum Discussion
ASaar2
New Contributor
6 years agoWhile this is an old thread, Google led me here while I was looking for a way to read the USERCODE from an Intel FPGA. Unfortunately the TCL code above doesn't work in newer Quartus (I have 17.1 at the moment) but that was easily fixed. The builtin help of quartus_stp gives an example on how to read the ID code of an FPGA and adapting from the above code I ended up with this script which prints out the IDCODE and USERCODE:
# List all available programming hardware, and select the USB-Blaster.
# (Note: this example assumes only one USB-Blaster is connected.)
puts "Programming Hardware:"
foreach hardware_name [get_hardware_names] {
puts $hardware_name
if { [string match "USB-Blaster*" $hardware_name] } {
set usbblaster_name $hardware_name
}
}
puts "\nSelect JTAG chain connected to $usbblaster_name.\n";
# List all devices on the chain, and select the first device on the chain.
puts "\nDevices on the JTAG chain:"
foreach device_name [get_device_names -hardware_name $usbblaster_name] {
puts $device_name
if { [string match "@1*" $device_name] } {
set test_device $device_name
}
}
puts "\nSelect device: $test_device.\n";
# Open device
open_device -hardware_name $usbblaster_name -device_name $test_device
# Retrieve device id code.
# IDCODE instruction value is 6; The ID code is 32 bits long.
# IR and DR shift should be locked together to ensure that other applications
# will not change the instruction register before the id code value is shifted
# out while the instruction register is still holding the IDCODE instruction.
device_lock -timeout 10000
device_ir_shift -ir_value 6 -no_captured_ir_value
puts "IDCODE: 0x[device_dr_shift -length 32 -value_in_hex]"
device_unlock
# Anssi adapted for reading USERCODE as well
device_lock -timeout 10000
device_ir_shift -ir_value 7 -no_captured_ir_value
puts "USERCODE: 0x[device_dr_shift -length 32 -value_in_hex]"
device_unlock
# Close device
close_deviceSave the script to a file, for example idcode_usercode.tcl and run the script with quartus_stp -t idcode_usercode.tcl