Khushi Posted August 16, 2018 Report Share Posted August 16, 2018 Hi , I am looking at endianness conversion functions in 1666-2011.pdf @492. I have couple of related questions 1. What is the template parameter DATAWORD signifies in these functions. Why it is needed when we pass the socket size explicitly 2. There are following functions for to_hostendian_ inline void tlm_to_hostendian_generic(tlm_generic_payload *, unsigned int ); inline void tlm_to_hostendian_word(tlm_generic_payload *, unsigned int); inline void tlm_to_hostendian_aligned(tlm_generic_payload *, unsigned int); inline void tlm_to_hostendian_single(tlm_generic_payload *, unsigned int); Which function we should use ? What is the meaning of _generic, _word, _aligned and _single in these functions Same for _from_hostendian functions. Thanks in advance for your kind help -- Khushi Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted August 16, 2018 Report Share Posted August 16, 2018 Hi Khushi, the best is to look up the definition in the IEEE 1666-2011 standard, section 14.20(.3). The different conversion functions have different constraints associated with them, allowing for more performant implementations for the _word, _aligned, and _single specializations. The _generic one covers arbitrary cases. The DATAWORD template parameter allows for optimizations as well (and endianness is always specific to the notion of a word). Hope that helps, Philipp Quote Link to comment Share on other sites More sharing options...
Khushi Posted August 16, 2018 Author Report Share Posted August 16, 2018 Thanks Philip Can you tell me for a scenario when payload data length is 16 bytes the n what value of DATAWORD I should use when using _generic endianness conversion function. For my specific case, I do not have the byte enable constraints. Can I use my function to convert the payload data from BE to LE on bus width boundary before calling b_transport and use the opposite one when b_transport call returns. For example, If I have the following data (16 bytes) char *data = "ABCDEFGHIJKLMNOP", then my function convert it to "DCBAHGFELKJIPONM" for a socket of 32bit. Can we do it ? Thanks Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted August 17, 2018 Report Share Posted August 17, 2018 The full data length is independent of the word length. The rules for DATAWORD are defined by the standard as follows (see 14.20.3): Quote e) The template argument to a hostendian function should be a type representing the internal initiator data word for the endianness conversion. The expression sizeof(DATAWORD) is used to determine the width of the data word in bytes, and the assignment operator of type DATAWORD is used during copying. sizeof(DATAWORD) shall be a power of 2. From your example below, you seem to be using four byte word, so "unsigned" (or uint32_t) could be a used as a DATAWORD parameter. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.