cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ Creator & Designer

Anonymous
Not applicable

Over on the PSoC Sensei Blog, Brad has started posting about my implementation of an Integer Square Root Calculator using datapaths. Here is the component.

   

 

   

A quick overview:

   

8, 16, 24 & 32 bits.

   

In 32-bit mode, takes a 32-bit input and calculates a 16-bit square root in at most 114 clock cycles. Smaller widths are even faster.

   

CPU-mode for easy firmware interaction, DMA-mode for HW-controlled, CPU-free operation.

   

 

   

Even if you have no use for a hardware-based square-root calculator, I think this is another good example of just how flexible and powerful the PSoC datapaths are.

0 Likes
8 Replies
Anonymous
Not applicable
0 Likes
Anonymous
Not applicable

Hopefully the third time's the charm getting the upload to work.

0 Likes
Bob_Marlowe
Expert II

Is it restrricted to PSoC3 or did I miss something when I tried to compile it for a PSoC5?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 You are correct. This component makes use of "FIFO Dynamic Control" in the datapaths (section 11.3.4 of the Component Author Guide), which is only available on PSoC 3 and PSoC 5LP.

0 Likes
Bob_Marlowe
Expert II

So I have to speed up the replacement of my old PSoC5 Kits and modules to PSoC5 LP!

   

 

   

Thanx

   

Bob

0 Likes
JamesD_81
Employee

 Bob,

   

Contact Axel Krepil in the Germany Cypress sales office...tell him I sent you and he'll help you in accelerating your upgrade of moving to PSoC 5LP with our PSoC 5LP Development Kit.  When we were at Embedded World I should have helped you then :).

   

Best regards!

   

Jim 

0 Likes
HeLi_263931
Honored Contributor II

There is now a followup available which shows how to formulate the algorithm so it can be matched to what the data paths does (including showing how the algorithm works on the data path). Great stuff!

0 Likes
odissey1
Honored Contributor II

Thank you for making square root component, real gem!

   


While using API _ComputeIsqrtAsync() I noticed that calculation results get corrupted if function called again before the previous calculation is finished. To prevent this issue I use binary flag to indicate that component in the idle mode and ready to accept new data:

   

CYBIT flag_Isqrt_1_Idle = !0; // semaphore flag

   


....

   

// start asyncronous calculation->
if (flag_Isqrt_1_Idle!= 0) {
                    flag_Isqrt_1_Idle = 0;
                    Isqrt_1_ComputeIsqrtAsync(val);
                } 

   

...

   

// get result of calculation->
if (Isqrt_1_AsyncComplete() != 0)           // Isqrt_1 calculation is complete
        {
            uint16 root = Isqrt_1_ReadIsqrtAsync();
            flag_Isqrt_1_Idle = !0; // component goes into idle state
        }

   


Please add the Idle flag to the API to prevent data corruption in asyncronous calculation mode.

0 Likes