Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Convert Code Containing Global Data to Fixed Point

3 ビュー (過去 30 日間)
Yinyin Zhao
Yinyin Zhao 2015 年 4 月 1 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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