当前位置:网站首页>[FPGA]: MATLAB generates COE files
[FPGA]: MATLAB generates COE files
2022-07-28 13:10:00 【Summer is cool and autumn falls】
List of articles
One .coe Description of the document
COE A document is a kind of ASCII text file , The file header defines the data base (Radix), When you can 2、10 or 16. The data is given in the form of vectors , Each vector ends with a semicolon .Vivado Can parse COE File format , And in Generate IP When the kernel is exported, the related MIF Format file , For behavior level simulation .
It is best to COE The file is placed in the IP Under the same directory ( I.e XCI The files are in the same directory ), It's working Core Cotainer pack IP Nuclear time will also COE Package files to XCIX In file . When replacing COE When you file , The old must be deleted COE file , Otherwise, it will be transferred to the comprehensive process of the project ; We need to pay attention to , If you just delete the file on the disk , Instead of removing in the project , Will cause a report error.
COE The general syntax format of the file is as follows :
Keyword =Value ; notes
<Radix_Keyword> =Value ; notes
<Data_Keyword> =Data_Value1, Data_Value2, Data_Value3;
COE Syntax is not case sensitive for keywords ; A semicolon is followed by a comment . The following are the keywords related to defining the cardinality of data values :
RADIX: For non storage types IP Cardinality definition of core ( such as FIR filter );
MEMORY_INITIALIZATION_RADIX: Define the cardinality of the memory initialization value .
The following are the keywords related to data values :
COEFDATA: Define the coefficients of the filter ;
MEMORY_INITIALIZATION_VECTOR: Define the data of block memory and distributed memory ;
PATTERN: For bit correlator (Bit Correlator)COE file ;
BRANCH_LENGTH_VECTOR: be used for Interleaver COE file .
COE The keyword defined at the end of the file must be COEFDATA or MEMORY_INITIALIZATION_VECTOR, Later keyword definitions will be ignored . Here are a few COE Sample file .
(1).Block Memory COE File
; This .COE file specifies the contents for a block memory of depth=16, and width=4.
memory_initialization_radix=2;
memory_initialization_vector=
1111,
1111,
1111,
1111,
1111,
0000,
0101,
0011,
0000,
1111,
1111,
1111,
1111,
1111,
1111,
1111;
(2).FIR COE File
; Example of a Distributed Arithmetic (DA) FIR Filter .COE file
; with hex coefficients, 8 symmetrical taps, and 12-bit coefficients.
Radix = 16;
CoefData= 346, EDA, 0D6, F91, F91, 0D6, EDA, 346;
Two . coe Example of file generation
Depth is 4096, The seat width is 8
1. Sine cosine
%% sin-cos wave data write in coe file
clear all ;
clc ;
N = 4096 ;
y = zeros(N , 1) ;
for i = 1:1:N
x = i ;
%y(i,1) = ceil( 127*sin(x*2*pi/N) ) + 127 ;
y(i,1) = ceil( 127*cos(x*2*pi/N) ) + 127 ;
end
plot(y);
hold on;
fid = fopen('cos_4096.coe','wt');
%- standard format
fprintf( fid, 'MEMORY_INITIALIZATION_RADIX = 10;\n');
fprintf( fid, 'MEMORY_INITIALIZATION_VECTOR =\n');
%- write data in coe file
for i = 1:1:N
fprintf(fid,'%d,\n',y(i,1));
end
fclose(fid);
2. Triangle wave
%% triangle wave data write in coe file
clear all ;
clc ;
N = 4096 ;
y = zeros(N , 1) ;
for i = 1:1:N
if(i < 2049)
y(i,1) = fix( (i/8) - 1 ) ;
else
y(i,1) = fix( ((4096 - i )/8) ) ;
end
end
plot(y);
hold on;
fid = fopen('triangle_4096.coe','wt');
%- standard format
fprintf( fid, 'MEMORY_INITIALIZATION_RADIX = 10;\n');
fprintf( fid, 'MEMORY_INITIALIZATION_VECTOR =\n');
%- write data in coe file
for i = 1:1:N
fprintf(fid,'%d,\n',y(i,1));
end
fclose(fid);
3. Rectangular wave
%% rectangle wave data write in coe file
clear all ;
clc ;
N = 4096 ;
y = zeros(N , 1) ;
for i = 1:1:N
if(i < 2049)
y(i,1) = 255 ;
else
y(i,1) = 0 ;
end
end
plot(y);
hold on;
fid = fopen('rectangle_4096.coe','wt');
%- standard format
fprintf( fid, 'MEMORY_INITIALIZATION_RADIX = 10;\n');
fprintf( fid, 'MEMORY_INITIALIZATION_VECTOR =\n');
%- write data in coe file
for i = 1:1:N
fprintf(fid,'%d,\n',y(i,1));
end
fclose(fid);
3、 ... and . Reference material
边栏推荐
- What if the right button of win11 start menu doesn't respond
- 机器学习实战-神经网络-21
- .NET的求复杂类型集合的差集、交集、并集
- 【嵌入式C基础】第6篇:超详细的常用的输入输出函数讲解
- Connected Block & food chain - (summary of parallel search set)
- Application and download of dart 3D radiative transfer model
- Machine learning practice - logistic regression-19
- 机器学习实战-逻辑回归-19
- Introduction to border border attribute
- Merge sort
猜你喜欢
随机推荐
Machine learning Basics - decision tree-12
Chinese translation of pointnet:deep learning on point sets for 3D classification and segmentation
What is C generic, generic cache, generic constraint
[graduation design] heart rate detection system based on single chip microcomputer - STM32 embedded Internet of things
What if the win11 folder cannot be opened
2020-12-07
机器学习基础-支持向量机 SVM-17
Fundamentals of machine learning - principal component analysis pca-16
Quick read in
黑猫带你学UFS协议第2篇:UFS相关名词释义
Black cat takes you to learn EMMC protocol chapter 27: what is EMMC's dynamic capacity?
Comments are not allowed in JSON
[graduation design teaching] ultrasonic ranging system based on single chip microcomputer - Internet of things embedded stm32
.NET的求复杂类型集合的差集、交集、并集
企业数字化本质
Low code: reduce technical capability requirements and improve software development efficiency
Jetpack Compose 完全脱离 View 系统了吗?
Sliding Window
Machine learning practice - neural network-21
Connected Block & food chain - (summary of parallel search set)









