Author Topic: Please help me, Write a VHDL code  (Read 4417 times)

0 Members and 1 Guest are viewing this topic.

Offline nguyensumTopic starter

  • Newbie
  • !
  • Posts: 3
Please help me, Write a VHDL code
« on: October 18, 2011, 05:46:25 am »
Hi everybody,
Please help me write a VHDL code to compute the following
polynomial equation: y=a5*X^5+a4*X^4+a3*X^3+a2*X^2+a1*X+a0
Simulation Quartus II

Thanks so much!  :)
 

Offline 0xdeadbeef

  • Super Contributor
  • ***
  • Posts: 1576
  • Country: de
Re: Please help me, Write a VHDL code
« Reply #1 on: October 18, 2011, 09:06:21 am »
Multiplication and addition should be directly supported by VHDL (at least for integer types). I guess all you need to do is to replace the "power of" by multiplication. E.g. replace X^3 by X*X*X etc.
Of course it would be clever to use a local signal for this and multiply it by X each timer you need a higher potency.

Then again, calculating a polynomial with integer types doesn't make so much sense honestly. If you need a "real" (floating point) type, this will get much more complicated. If you're using fixed point numbers, a normalizing division is needed for each multiplication.

[Edit]
There is also a package for fixed point calculation named "IEEE.Fixed_Pkg"
In theory, also a package for float calculations exists, namely "IEEE.Float_Pkg", but not every tools supports it and even if so, it creates very large and very slow blocks.

[Edit]
Google shows that while Quartus can't synthesize real multiplications etc., there are so called megafunctions for this:
http://www.altera.com/literature/ug/ug_altfp_mfug.pdf
« Last Edit: October 18, 2011, 12:01:46 pm by 0xdeadbeef »
Trying is the first step towards failure - Homer J. Simpson
 

Offline nguyensumTopic starter

  • Newbie
  • !
  • Posts: 3
Re: Please help me, Write a VHDL code
« Reply #2 on: October 20, 2011, 02:02:49 am »
Thanks you so much!
You share for me document very good.
Can you help me, please!
Write a VHDL code to perform the function of multiplier which the inputs are from Dip Switch and outputs display to 7-segment LED with BCD.
X : dip 1~4 represents value 0~15, display on 2 led seven segment 
Y : dip 5~8 represents value 0~15, display on 2 led seven segment
A=X*Y display on 4 led seven segment

Thanks you so much  :)
 

Offline Zad

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: gb
    • Digital Wizardry, Analogue Alchemy, Software Sorcery
Re: Please help me, Write a VHDL code
« Reply #3 on: October 20, 2011, 02:37:25 am »
You seem to be mistaking EEVBlog for a do-your-homework service.

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Please help me, Write a VHDL code
« Reply #4 on: October 20, 2011, 05:59:04 am »
This topic will now be locked. I contacted the op asking him not to post homework.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf