Reference to non-existent field 'inVals'.

1 view (last 30 days)
Guilherme Moitas
Guilherme Moitas on 17 Jun 2016
Commented: Tim McBrayer on 20 Jun 2016
Hi everyone, I'm having a problem with the HDL Code Generation. I'm trying to convert Matlab to VHDL. So I could make the Fixed-Point Conversion but when I try to Run the HDL Code Generation, it gives me this error : Reference to non-existent field 'inVals'. I don't know where is this 'inVals' and i used 'E = lasterror' to identify, however just told me that:
message: ''
identifier: 'emlc:compilationError'
stack: [0x1 struct]
This is my project:
function [pulse] = pwm ()
F2=1;
F1=10;
A=5;
t=0:0.001:1;
x=(2*pi*F1*t);
c=0;
c=A.*(sin(x));%Carrier sawtooth
subplot(3,1,1);
plot(t,c);
xlabel('Time');
ylabel('Amplitude');
title('Carrier sawtooth wave');
grid on;
m=0.75*A.*sin(2*pi*F2*t);%Message amplitude must be less than Sawtooth
subplot(3,1,2);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
grid on;
n=length(c);%Length of carrier sawtooth is stored to ‘n’
pulse=0;
for i=1:n%Comparing Message and Sawtooth amplitudes
if (m(i)>=c(i))
pulse(i)=1;
else
pulse(i)=0;
end
end
subplot(3,1,3);
plot(t,pulse);
xlabel('Time');
ylabel('Amplitude');
title('plot of PWM');
axis([0 1 0 2]);%X-Axis varies from 0 to 1 & Y-Axis from 0 to 2
grid on;
Can someone help me please? Thank for your help already!

Answers (1)

Tim McBrayer
Tim McBrayer on 17 Jun 2016
Your code contains a lot of code unsuitable for code generation; specifically, all the plot related functions are not supported for HDL code generation. You also have no data coming in our out of your function; this implies that you will have no input or output ports .
You need to figure out what of your code is to be converted into HDL and what part is your test bench/stimulus framework. Your code for HDL code generation will in general receive input from and return results to the test bench code. Once you have divided your code up like this, try HDL Coder again, explicitly specifying what function contains your code to convert to HDL and what file is your test bench.
  2 Comments
Guilherme Moitas
Guilherme Moitas on 20 Jun 2016
Hey Tim, could you be more explicit? I'm not a common user of MatLab and I never used a HDL Coder before.
Tim McBrayer
Tim McBrayer on 20 Jun 2016
Your best option is to take advantage of the documentation. It is pretty explicit about the difference between your test bench and your design. There is a lot to learn about preparing MATLAB code for HDL code generation, starting with defining what is the code that you want to be in your hardware design.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!