how can i show figure in my m-file?

1 次查看(过去 30 天)
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 个评论
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