how can i show figure in my m-file?

조회 수: 1 (최근 30일)
shide agani
shide agani 2013년 2월 28일
Hi Im going to execute these codes in matlab in order tc generate hdl code
:function [iport,tnext] = ADD_TESTER (oport, tnow, portinfo)
persistent ud; %Create a struct to store persistent user data
tnext = []; %initialize tnext to null
iport = struct(); %initialize iport to null
if(nargin ==3) %First call has 3 arguments
ud.call_count = 0; %Initialize call counter
tnext = tnow+100e-9;%Next invocation after 100 ns
iport.a = '0';
iport.b = '0';
iport.cin = '0';
else
ud.call_count = ud.call_count + 1;
if ud.call_count < 8 %run for 8 cycles
tnext = tnow+100e-9; %Next invocation after 100 ns
bin = dec2bin(ud.call_count,3);%Convert counter to binary string
iport.a = bin(1); %Assign bits of bin to 3 inputs
iport.b = bin(2);
iport.cin = bin(3);
else
disp('Over'); %If 8 cycles are over, don’t invoke with tnext
end
end
AND THE ERROR IS:Error in ADD_TESTER (line 15)
ud.call_count = ud.call_count + 1;
>> ADD_TESTER
15 ud.call_count = ud.call_count + 1;
K>>
PLZ HELP ME THANK YOU SO MUCH!
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 2월 28일
What error message is given?
shide agani
shide agani 2013년 3월 1일
Error in ADD_TESTER (line 15)
ud.call_count = ud.call_count + 1;
>> ADD_TESTER
15 ud.call_count = ud.call_count + 1;
K>>

댓글을 달려면 로그인하십시오.

채택된 답변

Tim McBrayer
Tim McBrayer 2013년 2월 28일
The MATLAB HDL Coder demos are an excellent way to learn how to generate HDL code from MATLAB. They are probably the best place to start to get the answers to your questions.
I'm not sure what you are trying to model here. For HDL Coder to generate code from MATLAB, you need a design and a testbench. You do not need to model time. You cannot use MATLAB functions like 'disp' that have no hardware equivalent.
I suggest you determine what hardware you wish to build and write a MATLAB function that implements that function. If you wish to build a counter, build a function that increments its output value each time it is called. Then, implement a testbench that exercises the model by calling it in a loop, providing any inputs that are necessary. Once this simulates correctly, then you can try the code in HDL Coder.

추가 답변 (0개)

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by