Need help for Error happened during using SIMULINK HDL coder
조회 수: 6 (최근 30일)
이전 댓글 표시
I have next code , and related SIMULINK model , want to convert to VHDL code , using SIMULINK HDL coder , but error happened :
clear clf
I1=1989;I2=1876;I3=407;h=53.66;m1=257.419;m2=154.062;b3=6.86157e-8;n=.0042; a=[0 0 1 0;0 0 0 1;-h*n/I1 0 0 -h/I1;0 -n*h/I2 h/I2 0]; %a =[0 0 1 0;0 0 0 1;-0.0017 0 0 -0.0270;0 -0.0018 0.0286 0]; b=[0;0;m2*b3/I1;m1*b3/I2]; %b = 1.0e-008 *[0;0;0.5315;0.9415]; c=[1.0e-7 1.0e-6 8.0e-4 1.0e-3]; %roots=-4.3741+--89.274i,-1.2517 g=22; % g < 1/4*max eigen tf=43200; [Ad,Bd]=c2d(a,b,g);
% desired output lamda=1.0e-7 ; a4=1.0e-3 ; a3=1.0e-4; a2=1.0e-6 ; xd=0 ; q=50 ; k=10 ; x=[.5;0;0;.007]; t=0; u=0 ; i=1 ;
while t<tf x1=x(1);x2=x(2);x3=x(3);x4=x(4); xx1(i)=x1;xx2(i)=x2; xx3(i)=x3;xx4(i)=x4;uu(i)=u;t1(i)=t; s =a4*x4+a3*x3+a2*x2+lamda*(x1-xd); % switching surface I4 = [1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1]; u =-c*(a+q*I4/abs(c*x)+k*I4)*x -k*s ; x = Ad*x+Bd*u ; i=i+1; t=t+g; end subplot(2,2,1), plot(t1,xx1);grid;title('Roll Response'); subplot(2,2,2), plot(t1,uu);grid; title('U input Response'); subplot(2,2,3), plot(t1,xx4);grid; title('Yaw Response'); subplot(2,2,4), plot(t1,xx3);grid; title('Yaw Rate Response');
best regards
댓글 수: 0
채택된 답변
Tim McBrayer
2013년 5월 9일
If you are starting with MATLAB code and not a Simulink model, I would suggest using HDL Coder to generate VHDL directly from your MATLAB code, as opposed to attempting to convert your MATLAB code to a Simulink model. To learn how to do this, please consult the documentation and demos, which will walk you through the process.
Some things immediately come to mind upon looking at your code, though. You have a section of code that creates plots. This can not be converted to hardware. You will need to separate your code into your design (the part which implements your algorithm) and the test bench (that provides stimulus to the algorithm and displays the results).
댓글 수: 2
Tim McBrayer
2013년 5월 10일
I see. Support for direct MATLAB to VHDL code generation was not added to HDL Coder until R2012a. Using R2008(a or b), you will need to convert your design into Simulink. You will need to figure out what your core computational kernel is and implement it in a MATLAB Function block. You'll need to convert it manually to fixed-point if you want to be able to synthesize it. And, of course, you'll need to determine how to drive your input vectors using Simulink.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 HDL Coder에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!