官方的參考文檔是:https://www.xilinx.com/support/documentation/sw_manuals/xilinx11/cgn_r_coe_file_syntax.htm
Xilinx COE文件用來初始化ROM內容,設置固定系數FIR的系數,還有其他的功能。
COE文件中的數據格式可以是2(Binary),10(Decimal)或者16(Hex)。
下面是一個簡單MIF COE的例子:
memory_initialization_radix=2; memory_initialization_vector= 0, 0, 1, 0, 0, 1, 0, 1;
上面這個COE例子完成的是Memory Initialization,存儲初始化。
下面是一個FIR COE例子:
radix=10; coefdata= 8, 15, 25, 40, 62, 93, 135, 189, 255, 336, 431, 539, 659, 790, 929, 1073, 1220, 1364, 1504, 1634, 1752, 1854, 1936, 1997, 2034, 2047, 2034, 1997, 1936, 1854, 1752, 1634, 1504, 1364, 1220, 1073, 929, 790, 659, 539, 431, 336, 255, 189, 135, 93, 62, 40, 25, 15, 8;
上面這個例子完成的是長度為51的低通FIR的系數定義。(系數量化為有符號12位,FIR Compiler中也設定為12位,實際系數中只有正幅值)
注意:
(1)每一個數據用逗號和換行實現,注意數據輸入行不要加分號!(除了最后一行)否則分號會指定數據錄入的結束。
************************************************************************************************************************************************************************
簡單翻譯一下官方手冊內容。
COE文件的格式如下:
<Radix_Keyword> = Value ; Optional Comment
<Data_Keyword> = Data_Value1, Data_Value2, Data_Value3;
即要求設定:表示格式(Radix)和數據(Data)。關鍵字(Keyword)不分大小寫。(不同ip使用不同的對應COE文件具體格式,可以參閱BRAM,FIR Compiler等的ip手冊)
Radix_Keyword可以是:
| Keyword | Description |
| RADIX | 非存儲模塊的系數、內容設定 |
| MEMORY_INITIALIZATION_RADIX | 用於ROM/RAM等存儲模塊的內容初始化 |
Data_Keyword可以是:
| Keyword | Description |
| COEFDATA | 濾波器系數 |
| MEMORY_INITIALIZATION_VECTOR | 塊狀(Block)存儲和分布式(Distributed)存儲單元的內容(ROM/RAM) |
| PATTERN | Bit Correlator系數 |
| BRANCH_LENGTH_VECTOR | 交織器系數 |
| MEMDATA | 廢棄關鍵詞,已經不使用了 |
注意:1、分號后的代碼都被認為是注釋內容。
2、COEFDATA,MEMORY_INITIALIZATION_VECTOR和MEMDATA必須是COE文件中最后一個Keyword。后續的所有關鍵詞都被編譯器忽略。
如果安裝了ISE環境,則在C:\Xilinx\12.4\ISE_DS\ISE\coregen\data\ 目錄下有許多的COE文件供參考,Bit Correlator、Block Memory、分布式算術FIR等等ip都可以參考這樣的COE格式。
下面是一些COE文件例子:
(1)並行分布式算術FIR(PDA FIR)
; Sample coefficient definition file for a Parallel Distributed ; Arithmetic (PDA) FIR Filter V1.0 with decimal coefficients ; (XC4000E/EX/XL/XV, Spartan/XL) ; ; This .COE file format is only compatible with this v1.0 core. ; ; The only families supported by this core are XC4000E, EX, XL, and XV, ; and Spartan and Spartan-XL. ; ; - 16 taps, symmetric 8 bit decimal coefficients ; - 8 bit signed input (signed data by default) ; - 21 bit output Component_Name=fltr16; Number_Of_Taps=16; Input_Width = 8; Signed_Input_Data = true; Output_Width = 21; Coefficient_Width = 8; Impulse_Response_Symmetry = true; Radix = 10; CoefData=1,-3,7,9,78,80,127,-128;
(2)Bit Correlator
; Sample .COE coefficient file for v2.0 and later versions of ; the Bit Correlator core. ; ; In this core, a COE file is used to specify the value of ; the bit mask when the Pattern Mask option is selected. ; ; Specifications: ; ; - 19 taps, hexadecimal coefficients ; - Serial input data ; ; Please refer to the datasheet for this core for more ; details on using the Mask option. radix = 16; pattern = 3 0 3 1 0 1 1 3 0 2 2 2 3 0 1 1 3 0 3;
