PDA

View Full Version : [moved] how to create C style bit structure


worldcup
01-13-2008, 07:42 AM
I have a C style bit structure like the following

struct {
elementA : 2
elementB : 20
elementC : 7
elementD : 3
}

How can I define this structure in PPL?

Thanks

Heinz
01-13-2008, 10:31 AM
I am not sure, whether I understood your question properly, but in PPL you could define a structure like this:

struct(StructureName$,"elementA",2,"elementB",20," elementC",7,"elementD",3);

And then you could access the strucutre elements like this:

StructureName.elementA$="A";

Is this what you meant?

kornalius
01-13-2008, 04:25 PM
PPL doesn't support bit size types. The smallest you can declare is 1 byte wide.

You can do bit manipulation just like you would in C with some functions.

worldcup
01-14-2008, 12:45 AM
PPL doesn't support bit size types. The smallest you can declare is 1 byte wide.



oh. That is pity.

I need bit structure because it can help me to assign a value to a portion of memory unit easily.

kornalius
01-14-2008, 12:49 AM
You can use bit manipulation functions like: shr, shl, asr, asl, & and |.

a$ = 0x00000001 & 0x00000010;

It is not as easy but it does work.