generate HDl code by hdl coder

4 ビュー (過去 30 日間)
BabuLal
BabuLal 2011 年 4 月 6 日
How Can I implement the below given matlab code in simulink hdl coder. any Idea please?
Here is my sample code:-
[FileName,PathName,FilterIndex] = uigetfile('*.xls');
File = strcat(PathName,FileName);
[status,sheets,format] = xlsfinfo(File);
testvectordata = xlsread(File,sheets{1,1});
for i = 1:16
weight(1,i) = 0.9999;
weight(2,i) = 0.9999;
weight(3,i) = 0.9999;
weight(4,i) = 0.9999;
end
for n=1:size(testvectordata,1)-1
input(n,1) = testvectordata(n,1);
input(n,2) = testvectordata(n,2);
end
Input_a = input(:,1);
Input_b = input(:,2);
Input_a = Input_a';
Input_a_c = 1 - Input_a;
Input_b = Input_b';
Input_b_c = 1 - Input_b;
for i = 1:size(Input_a') % Number of samples
%%input sample to the BLOCK
%=====================================================================
in_data = [Input_a(1,i);Input_a_c(1,i);Input_b(1,i);Input_b_c(1,i)];
for j = 1:16 % 16 parallel nodes and each node has 4 weights
match(:,j) = min(in_data,weight(:,j));
MatchVector_Sum = sum(match(:,j));
Weight_Sum = sum(weight(:,j));
if ((MatchVector_Sum/2) >= vigilance )
Test(j) = MatchVector_Sum/(0.1 + Weight_Sum);
else
Test(j) = 0;
end
end
[TJ,Index] = max(Test);
id = Index(1);
weight(:,id) = match(:,id); % Update weight
Category = [Category;id];
%==============================================================
end

採用された回答

Walter Roberson
Walter Roberson 2011 年 4 月 6 日
uigetfile() and xlsread() would be difficult to translate into HDL.
Have you checked the Embedded Matlab documentation as to what is permitted in functions to be translated into HDL ?
  3 件のコメント
Walter Roberson
Walter Roberson 2011 年 4 月 6 日
I don't see anything _obvious_ that could not be converted. Have you read the Embedded Matlab documentation and tried using emlmex http://www.mathworks.com/help/toolbox/eml/ref/emlmex.html to be sure that your code is able to be converted to HDL ?
Are you looking for a guide to converting Embedded MATLAB functions to HDL, or are you looking for information on how to form the embedded equivalent of something specific that the embedded system is not able to translate?
BabuLal
BabuLal 2011 年 4 月 7 日
Thanks for reply.
in the above code I have to implement 16 parallel nodes in each node initially weights were assigned to 0.9999 and after that it will changes according to the code. and one more thing is that i have implemented the divide function in two steps 1. the value of 1/(0.1 + Weight_Sum) stored in a lookup table 2. multiply it with MatchVector_Sum. This is how I implemented. Or if you dont mind please can you convert it to VHDL with 12 bits precision. here inputs are also normalized to 1.
Please...
Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCode Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by