Info

此问题已关闭。 请重新打开它进行编辑或回答。

Convert Code Containing Global Data to Fixed Point

1 次查看(过去 30 天)
Hi, I'm new to use the fixed point converter and HDL coder. I have a problem when I want to convert one of my model function to fixed point because this function is purely defining a global variable "PM" which contains all the parameters in my model. "PM" is a 1*1 structure global variable. I don't know how to convert this function in the fixed point converter. I checked the document for this issue but the situation is a little bit different. I'm using MATLAB 2014b but the document version might be older than this. Also the global variables in the document are not the same data type as mine. So I still can not solve my problems. Basically, my "PM" function is similar the the following, but there are more items in my real function.
%
function [PM]= Parameters(Test)
global PM
%%Constant
PM.R=8.314;
PM.F=96485;
%%Geometry
PM.L=27.6; % Length cm
PM.W=18.5; % Width cm
PM.d=1.47; % Thickness cm
PM.V=PM.L*PM.W*PM.d; % Volume cm
PM.layers=50; %%%%%%%%%%%%%%%Didn't provide%%%%%%%%%%%%%%%
PM.sandwichArea=Test*PM.L*PM.W*PM.layers;
end
Thanks.

回答(1 个)

Kiran Kintali
Kiran Kintali 2021-5-2
Use Persistent Variables instead of Global Variables when translating MATLAB to HDL Code. See doc and best practices in HDL Coder.
web(fullfile(docroot, 'hdlcoder/ug/persistent-variables-1.html?s_tid=doc_srchtitle'))

产品

Community Treasure Hunt

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

Start Hunting!

Translated by