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