From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Simulink Inport/Outport Datatypes

Solved!
Go to solution

I've been looking for a while and I'm unable to find any documenation regarding what data types I need to be using for the inports, outport, and parameters in my Simulink models.

 

Is there specific data types that are or aren't supported?  How does VeriStand determine how to coerce the data to send it to the model?  Also, I've been under the understanding that VeriStand uses doubles for everything but then I saw a post that said it uses I64's.

 

Any clarification would be much appreciated.

 

VeriStand 2013 SP1 (probably upgrading to 2016 within the next year if that is relevant)

MATLAB 2010b and MATLAB 2012b (currently)

0 Kudos
Message 1 of 3
(3,662 Views)
Solution
Accepted by topic author NathanJD

>> Is there specific data types that are or aren't supported? 

I don't remember there being any limitation on types beyond what is listed in the considerations help document. 

 

Considerations for Integrating Models from The MathWorks, Inc. Simulink® Software (Model Interface T...

 

The big hiccup I remember was mostly with bus configurations and not data types. 

 

iirc, you can choose whatever numeric type you want in Simulink. The model interface framework that VeriStand uses will handle any type and cast it to a double so that it can be consumed by the VeriStand engine. 

 

>> How does VeriStand determine how to coerce the data to send it to the model?

I believe the way it works is that when VeriStand interfaces with the Simulink model, it gets a list and supporting information (pointer to, data type) of the inports, outports, and parameters. So, it can grab the data from the model (because it has the pointer) and it can cast it from its data type (because it knows the type) to a double. If you look at the model interface example template on line 212 it might help make things more clear on how this might work, 

C:\VeriStand\2016\ModelInterface\custom\examples\template.c

double USER_GetValueByDataType(void* ptr, int32_t subindex, int32_t type)
{
	switch (type) 
	{
		case 0: 
		{
			/* double */
			return (double)(((double *)ptr)[subindex]);
		}
		case 1: 
		{
			/* single */
			return (double)(((float *)ptr)[subindex]);
		}
  	}
	
	/* return NaN, ok for vxworks and pharlap */
	uint32_t nan[2] = {0xFFFFFFFF, 0xFFFFFFFF};
	return *(double*)nan;
}

I'm guessing the full implementation of what VeriStand uses is much more complex but I think the idea is the same. 

 

 

>> Also, I've been under the understanding that VeriStand uses doubles for everything but then I saw a post that said it uses I64's.

The VeriStand engine does indeed use all doubles. 

 

Do you happen to remember this post and can you share the link? I'd be curious to see where this is stated and under what context. 

Tim A.
0 Kudos
Message 2 of 3
(3,601 Views)

Thanks for the info.  I didn't even think about it being handled during the compilation but it makes total sense.

 

The post that referred to I64's is here.

0 Kudos
Message 3 of 3
(3,571 Views)