Home    Bloggers    Messages    Webinars    Resources   
Tw  |  Fb  |  In  |  Rss
Max Maxfield

The Basics of FPGA Mathematics

Max Maxfield
Page 1 / 3   >   >>
Adam Taylor
Adam Taylor
8/11/2012 4:55:36 AM
User Rank
Blogger
Re: Fixed point math
I have used the matlab version in the past and Xilinx system generator it is useful for quick proof of concepts but not really for production code. 

You mention a junior engineer do you take on many graduates ? 

50%
50%
JezmoSSL
JezmoSSL
8/11/2012 4:04:45 AM
User Rank
Blogger
Re: Fixed point math
Two interestiing and slightly related things this week, we thought briefly about using mathcad to generate code for some very simple filters like a couple of biquads, using their automagic vhdl builder, mainly because my boss didn't believe machine generated code could be so nasty and then we found out the cost and my boss very quickly went off the idea, you are basically paying the equivelent of a junior engineer's salery for a year to produce code which wouldnt be aceptable if it was produced by a junior engineer.

And the on-line demo which mathcad did for us didnt work which made me laugh.

50%
50%
hamster
hamster
8/9/2012 4:40:15 AM
User Rank
Blogger
Re: Fixed point math
I pondered rfindley's post and your post while out for a run today. It now makes perfect sense! 

In fact so much sense I feel confident that I could now multiply even bigger numbers without reaching for the web browser!

Many thanks to you!

50%
50%
hamster
hamster
8/9/2012 4:39:54 AM
User Rank
Blogger
Re: Fixed point math
I second Max's comment - your post is so clear even I can understand it!

50%
50%
David Ashton
David Ashton
8/8/2012 11:06:06 PM
User Rank
Guru
Re: Fixed point math
@Rfindley - thanks for that...nice to know I'm not toooo stupid!! :-)

50%
50%
rfindley
rfindley
8/8/2012 10:55:48 PM
User Rank
Blogger
Re: Fixed point math
@David, you are correct... it was for illustration only, from a decimal perspective.  Maybe it is clearer this way:

---------
We humans tend to think this way:
  -54 = -50 + -4
Whereas computers think this way:
  -54 = -60 + 6

Technically, a computer would more likely use "-64 + 10", but here I'm sticking with the decimal notation to illustrate the point, which is that the computer starts from a signed MSB base, and adds an always-positive offset.

(....)

---------

50%
50%
KenwickVS
KenwickVS
8/8/2012 7:59:00 PM
User Rank
Blogger
Re: Teaching is not easy
@Paul: "and sometimes an information web is more useful" I agree. The APP Blog moves "fast and furious" and is fun. However, sometimes an idea or technology discussion emerges that needs more time to be developed by those interested in the subject. Unfortunately, the subject closes because it is superceded by the "latest and greatest" blog. We're moving too fast, IMHO (I just learned what that means!)

50%
50%
David Ashton
David Ashton
8/8/2012 7:26:23 PM
User Rank
Guru
Re: Fixed point math
@Rfindley, thanks for that but I have a question:

"Whereas computers think this way:   -54 = -60 + 6"

Being as computers work in powers of 2, shouldn't that be -54 = -64 + 10?

Or am I missing something?  Maybe you were just illustrating your point?

Thanks

 

50%
50%
Paul A. Clayton
Paul A. Clayton
8/8/2012 6:05:20 PM
User Rank
Beginner
Teaching is not easy
Adam Taylor wrote: "it is always difficult to determine what to include and what not to in these articles."

If teaching was easy, anyone could do it well.  Having done a very small amount of informal teaching, I have some appreciation of some of the difficulty.  For educational purposes, the shotgun approach--scattered coverage with limited coherence--tends to be less effective, so you are quite right in constraining what subtopics are covered.

I liked how the article went from concepts to application to implementation.  You just need to work on discerning what I want--note reading my mind will not work because even I do not know what I want--and writing perfect articles targeted to my wants. :-)

By the way, I wonder if APP should set up a hypertext knowledge base (possibly using a wiki).  Sometimes a narrative style of presenting information is appropriate (blogs, articles, books) and sometimes an information web is more useful.

50%
50%
Karl
Karl
8/8/2012 4:36:48 PM
User Rank
Guru
Re: Fixed point math
@hamster:  Here is some c code to multiply 4 x -4, shows for negative numbers times positive requires the left bits to be 1's when the product width is extended.  So propagating the sign works also for both negative will result in a positive product when added.


                int a = -4, b = 4, c = 0, d = 0, al, bl, au, bu, albl, aubl, albu, aubu;
                c = a * b;
                //   c ==  0xfffffff0
                al = a & 0x0001ffff;
                //   al == 0x0001fffc
                au = (int)(a & 0xfffe0000) >> 16;
                //   au == 0xfffffffe
                bl = b & 0x0001ffff;
                //   bl == 0x00000004
                bu = (int)(b & 0xfffe0000) >> 16;
                //   bu == 0x00000000
                albl = al * bl;
                // albl == 0x0007fff0
                aubl = au * bl;
                // aubl == 0xfffffff8
                albu = al * bu;
                // albu == 0x00000000
                aubu = au & bu;
                // aubu == 0x00000000
                d = aubu + (aubl << 16) + (albu << 16) + albl;
                //    d == 0xfffffff0  ..  c == 0xfffffff0

As was already pointed out (rfindley? I think) negative numbers are formed by adding a positive offset to the most negative number which is a 1 followed by however many 0's.  Not obvious when complementing and adding 1 to form 2's complement.

50%
50%
Page 1 / 3   >   >>
More Blogs from Max Maxfield
Would you class these as adages, aphorisms, axioms, dictums, epigrams, maxims, precepts, saws, truisms, or... well, what?
In part 3 of this epic tale we consider how we might use tri-state buffers, leading up to the legendary bi-directional buffer.
Design West 2013 was one of the best conferences and exhibitions Max has attended in terms of interesting presentations and fun events.
This week's live online chat takes place on Thursday, May 16, 2013, at 1:00 p.m. ET.
In part 2 of this epic saga, we consider how we might set about implementing the legendary tri-state output buffer.
flash poll
follow us on twitter
follow Xilinx on twitter
like us on facebook
like Xilinx on facebook
All Programmable Planet     About Us     Contact Us     Help     Register     Twitter     Facebook     RSS