Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

A Matlab Program to generate Xilinx .coe File.

Status
Not open for further replies.

radar08

Newbie level 6
Joined
Nov 18, 2008
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,349
xilinx coe file

In fact, to generate Xilinx coe file is to transform decade to binary of hex data. Matlab is very helpful. When using Xilinx IP Core to generate RAM with initialization file or ROM with .coe file, the top two line is:
MEMORY_INITIALIZATION_RADIX=2;
MEMORY_INITIALIZATION_VECTOR=;
// The radix here can 16 or 10 but if 10 the data must be unsigned data.
If using FIR Compiler, we should generate FIR coefficients file. The format is:
radix=coefficient_radix;
coefdata=
a(0),
a(1),
a(2),
….
a(N-1);
//here the coefficient_radix is 2,10,16. if 10, the coefficient can be either signed or unsigned data.
这里给出一个有符号十进制转换为二进制的例子,生成.coe文件
The below is a matlab function to transform signed decade data to binary data.
%=================================================
function []=fddec2bin(data, width)
% Author: yuelengyueming.
% It aims to transfer decade data to binary data and stores in a file.
% data: decade data.
% width: binary bit width.
% Improvement: define the file name.
if length(dec2bin(max(abs(data))))>width
error('The second parameter is not bigger enough.');
end;
L=length(data);
fd=fopen('data.coe','w');
for k=1:L
if data(k)>=0
temp=dec2bin(data(k),width);
else
temp=dec2bin(2^width-abs(data(k)),width);
end;
fprintf(fd,'%s,\n',temp);
end;
fclose(fd);
%=================================================
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top