0

I am trying to generate a 512bit pattern where the word 0xdeadbeef keeps rotating (shifted left by one) across the 512bits, each time I want to right the data to memory.

Baiscally, 0xffffffff.......deadbeefffffffff (512 bits total). Keep shifting the deadbeef part by one and after each time write the whole pattern to memory.

Is bitset the correct container in this case? I was able to use all the needed operations (<< ^ ...etc) but I can't find a way to translate the 512bit data into 64bit long long variables to write to memory.

3
  • Do you have memory/CPu constraints? what is the frequency this is supposed to be called.
    – OznOg
    Mar 14, 2020 at 7:35
  • You can just create an array of 64bits and hold them as a pointer Mar 14, 2020 at 7:36
  • No CPU constraints. It will be called until it fills some 16MB. Noam, I am not following. Hold what as a pointer?
    – SFbay007
    Mar 14, 2020 at 7:58

1 Answer 1

0

Bitset is not really a container, it's a representation class. Iternally it may represented by array or list of bool. Only way to export its content to array is to do it manually. It's arguably more effective to do aforementioned shifting without bitset, provided that all you need is the actual offset, which gives you address of pattern, rest of bits would be defaulted to 1.

Question is, how endianness should be handled in your application: does positiob of pattern represent lsb-msb sequence within each word, or it should be byte-wise aligned.

2
  • Well, the reason I am using bitset is to manipulate bits and shift patterns across double words limits (64bits). Other wise I have to figure the bits that got shifted into the next 64bit and manage that. Bitset takes care of that.
    – SFbay007
    Mar 14, 2020 at 9:03
  • @SFbay007 to convert it, you'd have to examine each bit in bitset and set to 1 or 0 in array. Now think of it: you have 128 words out of which 127 or 126 are all same. Only n/64-th and (n/64 + 1 )%128 (if n%64 > 32) words are different. Mar 15, 2020 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.