Hi Heystek,

Assuming your BRAM is set for 32-bit wide, you probably want to be writing
the values with 31 bits below the binary point -- i.e. normalized to the
range [-1, 1)  (aka simulink FIx32_31). In this case the packed values
would be:

struct.pack('>i', int(floating_point_sine_value * 2**31))

Though, be careful, because +1.0 isn't included in this number
representation (the maximum is 1 - 2**-31) , so you might want to include
some saturation logic (or scale up by a value less than 2**31).

For what it's worth, you can pack an entire numpy array with:
floating_point_numpy_array.astype('>i').tobytes()
, which saves looping and appending to a binary string.

Does that help?

Cheers
Jack

On Mon, 22 Nov 2021 at 18:10, Heystek Grobler <[email protected]>
wrote:

> Hey Jack
>
> I am also well thank you. We are starting to go back to the observatory
> (HartRAO) again.
>
> Here is  a snippets of the python code that I am using as well as my
> simulink design:
>
> The first nipped is where I create the sine wave:
>
> The second snipped is where I plot the sine wave:
>
>
> The third snipped is where I pack the sine wave array:
>
>
> The fourth snipped is where I write the packed data to the BRAM:
>
>
> Snipped 5 is where I want to use the sine wave and cosine wave:
>
>
> But to check that it is working, I have created the simple design in
> snipped 6:
>
>
> I have also attached my simulink design and python script.
>
> Thank you for the help!
>
> Heystek
>
>
> On 22 Nov 2021, at 18:55, Jack Hickish <[email protected]> wrote:
>
> Hi Heystek,
>
> All good here (in London), Thanks. Hope things are going ok with you too!
>
> I've taken this back on list for the benefit of others. Do you have:
>
> a) a snippet of some python code which you're using at the moment
> b) A Simulink snippet of the BRAM you're trying to write to, indicating
> how the bram is configured and how its data are being used?
>
> Cheers
> Jack
>
> On Mon, 22 Nov 2021 at 16:52, Heystek Grobler <[email protected]>
> wrote:
>
>> Hey Jack
>>
>> How are you? It has been a while since we last spoke.
>>
>> I am really struggling to pack data into binary format for my design. I
>> was wondering if you have time if you can please help me with it. I have no
>> clue if what i am doing is correct and there is no one around me with the
>> knowledge to help me.
>>
>> All that I want to do is too pack a sine wave that I already generated,
>> and write it to a BRAM.
>>
>> I hope to hear from you soon!
>>
>> Heystek
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/lists.berkeley.edu/d/msgid/casper/CAG1GKSnPOK4HZPDQXd04fZ9nSg%2Bg64KaHb4DyzDa855DuOCcaw%40mail.gmail.com.

Reply via email to