FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-01-2007, 06:16 PM
[email protected]
Guest
 
Posts: n/a
Default Count Leading Zero (CLZ) possible by MicroBlaze??

Hi all,

does anyone know if the MicroBlaze Processor of Xilinx has the CLZ
Instruction? I took a look in the datasheet, but didn't find anything
about it.
I would like to count the number of zeros in a 32-bit Register in one
cycle.

If this processor does not support this function, could you maybe
suggest me how to calculate this operation as fast as possible?

Thanks,

Armando

Reply With Quote
  #2 (permalink)  
Old 10-01-2007, 09:55 PM
Gabor
Guest
 
Posts: n/a
Default Re: Count Leading Zero (CLZ) possible by MicroBlaze??

On Oct 1, 4:48 pm, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
> armando...@googlemail.com wrote:
> > I would like to count the number of zeros in a
> > 32-bit Register in one cycle.

>
> It is more common to have an instruction to count ones.
> If so, complement and then count the ones.
>
> > If this processor does not support this function, could you maybe
> > suggest me how to calculate this operation as fast as possible?

>
> There are well known ways to do this in C, though maybe not as
> fast as you would like. One uses a 256 byte lookup table and
> sums over the four bytes of a 32 bit value. Another uses
> the bitwise AND operator and addition to add pairs of bits,
> sums the pairs, quads, octets, etc.
>
> It is not hard to do in FPGA logic as a carry save adder tree.
> If it can't be done in a single cycle at your clock rate it is
> easily pipelined.
>
> -- glen



Unless you really only want to count the leading zeroes, which only
needs a priority encoder...

Reply With Quote
  #3 (permalink)  
Old 10-01-2007, 10:48 PM
glen herrmannsfeldt
Guest
 
Posts: n/a
Default Re: Count Leading Zero (CLZ) possible by MicroBlaze??

[email protected] wrote:

> I would like to count the number of zeros in a
> 32-bit Register in one cycle.


It is more common to have an instruction to count ones.
If so, complement and then count the ones.

> If this processor does not support this function, could you maybe
> suggest me how to calculate this operation as fast as possible?


There are well known ways to do this in C, though maybe not as
fast as you would like. One uses a 256 byte lookup table and
sums over the four bytes of a 32 bit value. Another uses
the bitwise AND operator and addition to add pairs of bits,
sums the pairs, quads, octets, etc.

It is not hard to do in FPGA logic as a carry save adder tree.
If it can't be done in a single cycle at your clock rate it is
easily pipelined.

-- glen

Reply With Quote
  #4 (permalink)  
Old 10-02-2007, 11:07 AM
[email protected]
Guest
 
Posts: n/a
Default Re: Count Leading Zero (CLZ) possible by MicroBlaze??

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


Reply With Quote
  #5 (permalink)  
Old 10-02-2007, 11:33 AM
Göran Bilski
Guest
 
Posts: n/a
Default Re: Count Leading Zero (CLZ) possible by MicroBlaze??

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
>
>

Reply With Quote
  #6 (permalink)  
Old 10-04-2007, 02:08 PM
Anacrom
Guest
 
Posts: n/a
Default Re: Count Leading Zero (CLZ) possible by MicroBlaze??

Hi,

thank you for your tip.

But i don't know how tu use the instruction set. I suppose i should
write some assemble Code, but how and what are the commands??
Is there a datasheet or example on internet?

I am working with EDK 9 and SDK.

Thanks for the help


On 2 Okt., 11:33, Gran Bilski <goran.bil...@xilinx.com> wrote:
> 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 apcmbf 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'.
>
> Gran 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
>
>
>
> <armando...@googlemail.com> wrote in messagenews:[email protected] oglegroups.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- Zitierten Text ausblenden -

>
> - Zitierten Text anzeigen -



Reply With Quote
  #7 (permalink)  
Old 10-04-2007, 02:33 PM
Gran Bilski
Guest
 
Posts: n/a
Default Re: Count Leading Zero (CLZ) possible by MicroBlaze??

Hi,

Here is the link to the MicroBlaze reference guide.
http://www.xilinx.com/ise/embedded/mb_ref_guide.pdf
If you have EDK, you will find the documentations under /doc in your
install.

For how to program MicroBlaze, you will need to read about the software
tools.
But I would suggest doing a tutorial first to get a feeling on how things
are done.

Gran Bilski

"Anacrom" <[email protected]> wrote in message
news:[email protected] ps.com...
Hi,

thank you for your tip.

But i don't know how tu use the instruction set. I suppose i should
write some assemble Code, but how and what are the commands??
Is there a datasheet or example on internet?

I am working with EDK 9 and SDK.

Thanks for the help


On 2 Okt., 11:33, Gran Bilski <goran.bil...@xilinx.com> wrote:
> 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'.
>
> Gran 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
>
>
>
> <armando...@googlemail.com> wrote in
> messagenews:[email protected] oglegroups.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- Zitierten Text ausblenden -

>
> - Zitierten Text anzeigen -




Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is a leading zero detector? [email protected] Verilog 1 07-29-2008 06:18 PM
RTL Hardware design issue: Count Leading Zeros CLZ [email protected] FPGA 9 12-09-2006 01:07 PM
Seven leading PC processors benchmarked on Quartus-II Web Ed place&route Michael S FPGA 1 06-02-2004 06:18 AM
Leading Zero count DaveW Verilog 11 02-27-2004 01:04 AM


All times are GMT +1. The time now is 02:55 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved