1 2#------------------------------------------------------------------------------ 3# $File: xilinx,v 1.9 2021/04/26 15:56:00 christos Exp $ 4# This is Aaron's attempt at a MAGIC file for Xilinx .bit files. 5# Xilinx-Magic@RevRagnarok.com 6# Got the info from FPGA-FAQ 0026 7# 8# Rewritten to use pstring/H instead of hardcoded lengths by O. Freyermuth, 9# fixes at least reading of bitfiles from Spartan 2, 3, 6. 10# http://www.fpga-faq.com/FAQ_Pages/0026_Tell_me_about_bit_files.htm 11# 12# First there is the sync header and its length 130 beshort 0x0009 14>2 belong =0x0ff00ff0 15>>&0 belong =0x0ff00ff0 16>>>&0 byte =0x00 17>>>&1 beshort =0x0001 18>>>&3 string a Xilinx BIT data 19# Next is a Pascal-style string with the NCD name. We want to capture that. 20>>>>&0 pstring/H x - from %s 21# And then 'b' 22>>>>>&1 string b 23# Then the model / part number: 24>>>>>>&0 pstring/H x - for %s 25# Then 'c' 26>>>>>>>&1 string c 27# Then the build-date 28>>>>>>>>&0 pstring/H x - built %s 29# Then 'd' 30>>>>>>>>>&1 string d 31# Then the build-time 32>>>>>>>>>>&0 pstring/H x \b(%s) 33# Then 'e' 34>>>>>>>>>>>&1 string e 35# And length of data 36>>>>>>>>>>>>&0 belong x - data length %#x 37 38# Raw bitstream files 390 long 0xffffffff 40>&0 belong 0xaa995566 Xilinx RAW bitstream (.BIN) 41