- get the attached files
- study the script create_data_set_2
- run the script create_data_set_2
- Follow the Root Inport Mapper steps as shown in this published example.
how to pass(or link) ' fixed- point values' to the (root inport mapper-connect inputs) in the 'HDL inport block'
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fayaz
el 10 de Jul. de 2023
Comentada: Fayaz
el 11 de Jul. de 2023
THIS IS THE ERROR THTA SHOWS WHEN I LINK THE 'FIXED POINT VALUE' TO INPORT BLOCK, USING THE OTHER SIMULINK BLOCK TYPES WHICH ARE USED PASS THE INPUT FROM WORKSPACE, CANNOT GENERATE HDL CODE. THATS WHY IM USING HDL INPORT BLOCK.
ARE THERE ANY OTHER SOLUTION BLOCK THAT CAN THE FIXED POINT VALUE INORDER TO GENERATE THE HDL CODE
PLEASE GIVE A GUIDANCE
0 comentarios
Respuesta aceptada
Andy Bartlett
el 10 de Jul. de 2023
Editada: Andy Bartlett
el 10 de Jul. de 2023
The problem is that the model is configured such that root inport is getting one data type, but the external data is using a different data type.
There are two solution routes that depend on what you determine is right for your model.
One route is to change the model to have the same data types as the external data.
The other route is to change the external data to use the same data types as the model wants.
Assuming the former is right for your situation, I've attached files that provide an example similar to this published example, but with non-default data types. This example covers the case of simple signals, not-Buses.
The attached script create_data_set_2 creates some typed data
sampleTime = 0.01;
endTime = 10;
numberOfSamples = endTime * 1/sampleTime +1;
timeVector = (0:numberOfSamples) * sampleTime;
% Create data with non-default data types
% single, uint8, fixed-point fixdt(0,8,5)
%
v1 = single( sin(timeVector)*25 );
signal_1 = timeseries(v1, timeVector);
v2 = uint8(randi([0,255],size(timeVector)));
signal_2 = timeseries(v2,timeVector);
fixedExponent = -5;
nt3 = numerictype(0,8,-fixedExponent);
v3 = fi( nt3.Slope*randi([0,255],size(timeVector)), nt3 );
signal_3 = timeseries(v3,timeVector);
The key next task is to set these data types on the model.
The attached utility getOutDataTypeStrForBlockParam helps get the strings needed to set the data types on the model.
% Use a utility to get string needed to
% set the data types on the corresponding inpports.
%
dtstr1 = getOutDataTypeStrForBlockParam(signal_1.Data)
dtstr2 = getOutDataTypeStrForBlockParam(signal_2.Data)
dtstr3 = getOutDataTypeStrForBlockParam(signal_3.Data)
Next, we set the data types on the route inports of the model.
% Set the data types of the input ports
%
% BIG ASSUMPTION
% Name of the timeseries variable is the same
% as the name of the block
%
% If that assumption is not true, then you'll
% need to customize this code to find the right
% block to set the data type on
%
set_param([mdl,'/signal_1'],'OutDataTypeStr',dtstr1)
set_param([mdl,'/signal_2'],'OutDataTypeStr',dtstr2)
set_param([mdl,'/signal_3'],'OutDataTypeStr',dtstr3)
You'll probably need to customize this step for your model.
Note: Setting the data types on your model may cause your model to break due to type incompatibilities inside the model. If that is the case, the simplest approach is to drop in Data Type Conversion blocks after the root inports whose types have changed. Set the output data types of the Conversion blocks to agree with the original data type of the root inports.
After setting the data types on the model to agree with the data types of the external data, you should be able to proceed with Root Inport Mapper.
In summary, to run the attached example,
Cheers
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre HDL Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!