Hi,
It's better to add the HW module to FSL instead to the bus.
There is currently no CLZ instruction for MicroBlaze.
You can however do an optimized software implementation by using the pcmbf instruction.
The instruction will compare a register with another register byte-wise and you will get the number of bytes that matches from left to right.
So if you have the value you want to do a CLZ in a register, you can do a pcmbf against register 0 which always is 0.
You will know in which byte the first leading '1' is located and can after that do 8 bit search inside that byte.
It will not be done in one clock cycle but is most likely much faster than do a 32-bit search for the first '1'.
Göran Bilski
From MicroBlaze reference guide:
pcmpbf Pattern Compare Byte Find
Description
The contents of register rA is bytewise compared with the contents in register rB.
• rD is loaded with the position of the first matching byte pair, starting with MSB as position 1, and comparing until LSB as position 4
• If none of the byte pairs match, rD is set to 0
Pseudocode
if rB[0:7] = rA[0:7] then
(rD) ← 1
else
if rB[8:15] = rA[8:15] then
(rD) ← 2
else
if rB[16:23] = rA[16:23] then
(rD) ← 3
else
if rB[24:31] = rA[24:31] then
(rD) ← 4
else
(rD) ← 0
<
[email protected]> wrote in message news:
[email protected] ups.com...
> Hi,
>
> thanks for the answers.
> I know it should not be difficult to implement the module in Hardware
> (or SW).
> But i would like to calculate the operation as quick as possible.
>
> In the case of Hardware, i should attach the module to the processor
> of my system using a bus, and thus with a few more extra cycles.
>
> I just would like to be sure that the Microblaze Prozessor does not
> have such an instruction and know if some of you have already had
> experiences with CLZ in a EDK system.
>
> Thx again
>
>