Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

concatenate memory locations in c++

Status
Not open for further replies.

syedshan

Advanced Member level 1
Joined
Feb 27, 2012
Messages
463
Helped
27
Reputation
54
Reaction score
26
Trophy points
1,308
Location
Jeonju, South Korea
Activity points
5,134
hi all

I need to concatenate memory locations where data is in 'short' format, while I need to concatenate them to 64-bit (i.e. long formate) such that adjacent 16-bit data concatenate, i.e. if data is

c6, 23, 12, F2 => (then it becomes) c62312F2

please see the image below...

I have tried few things but couldnot succeed

I will be thankful

IMG_5819.JPG

Bests,
Shan
 

Just declare the memory as union of short and long long array, or use pointer type cast.
 

Thank you for your response.

Your method is also effective. But I also find one more methods, i.e. bit shifting and then doing or like one use to do in micro controller programming, here we are doing it for microprocessor and computer memory...

so it is something like this as code below...But the thing is I cannot get 64-bit even when I use long long or __int64

Code:
...
__int64 long_temp = 0xfffffffffffffff;
signed short int *sh_pbuff;
...
...
sh_pbuff = (short int *)malloc(sizeof(short int)*12);

for (int g = 0; g < 12; g ++)
	*(sh_pbuff + g) = g*10 ;
....
...

long_temp = (*(sh_pbuff + k + g) << 47) | (*(sh_pbuff + k + g) << 31) | (*(sh_pbuff + k + g) << 15) | (*(sh_pbuff + k + g) << 0);

...


//but the thing is I am using visual studio 2010 for comiling and it is taking long_temp as 32 bit variable instaead of 64 bit..(this is evident with the results... I have)

any idea..Doing so even if I use Union example I will face this same problem since I cannotutlize 64-bit data type

Note that it is only a test code
 

Your latest post seems to confuse the problem. The initial post is talking about a 64-bit data bus. This suggests a 64-bit processor and a compiler supporting it, e.g. by a 64-bit data type, isn't it?

It might be that you didn't explain the real problem, respectively I didn't understand it, but accessing a memory in 16 and 64-bit entities alternatively hasn't much to do with concatenation, I think.
 

no no

it does not matter if the processor is 64 bit or 32 bit...
The DSP board I am using is PCIe based, hence no matter for 64 bit, it is 4 lane PCI-e and the data that I send in 64-bit format, (it seems) the API provided by the developers will transform it into first 64-bit, later they have a module which I have used that will give me output in 64-bit form...Hence actually naively speaking, this thing, i.e. data from C++ up untill I receive it after that module, is transparent to FPGA developers ( of course technically not)

Hope this helps to understand...I have been trying to resolve for more than 1 day now...I dont want my design in FPGA since that will take too much time then.

but accessing a memory in 16 and 64-bit entities alternatively hasn't much to do with concatenation, I think.

please see the image that I have shown you...
 

Unfortunately I don't understand the problem at all. It seems like a basic programming thing.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top