Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

real in vhdl

hi all

i want to ask a question and i don't know if it possible in vhdl or how to make it.

if i have an eqution such as

x= m(a)+a*max(a)+b*sd_d(a)

and the values of a and b is as

a=1

b=1.5

--------

a=1

b=1.75

--------

a=1.5

b=0

---------

and i want to substitue the values of a,b every time and check the x value with comparator

how i make it in vhdl.any idea please

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The values of a and b that you give can be represented using "fractional integer format". Assuming the values of a and b can be signed values, you can use a 4-bit integer in Q1.2 format. This format can represent the following values;

    
    Binary  Q1.2 Value
    ------  ----------
    01.11    1.75
    01.10    1.50
    01.01    1.25
    01.00    1.00
    00.11    0.75
    00.10    0.50
    00.01    0.25
    00.00    0.00
    11.11   -0.25
    11.10   -0.50
    11.01   -0.75
    11.00   -1.00
    10.11   -1.25
    10.10   -1.50
    10.01   -1.75
    10.00   -2.00
    

    You can use these numbers, along with the knowledge that a multiplication of two Q1.2 numbers yields a Q3.4 value (eg., -2.00 x -2.00 = +4.00 = 0100.0000b) and addition results in a Q3.2 number, to determine the bit-growth in your equation. The resulting value of x can either be used directly, or convergent rounded to whatever bit-width you need for your design.

    If none of this makes any sense, read these notes ...

    http://www.ovro.caltech.edu/~dwh/correlator/pdf/esc-104paper_hawkins.pdf

    Cheers,

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you mean ichould convert this constant values first to binary and then to integer to multiply with integer signal

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    you mean i could convert this constant values first to binary and then to integer to multiply with integer signal

    --- Quote End ---

    Yes. There is no "rule" that says your constants must use floating-point. If fixed-point numbers represent the fractional part with the same precision as floating-point, then you will get the same answer. The math is the same.

    Cheers,

    Dave