Mathematical Operations in VHDL

Discussion in 'VHDL' started by MtnSurf8, Apr 25, 2004.

  1. MtnSurf8

    MtnSurf8 Guest

    Hey there, I'm new to VHDL and was wondering how to use mathematical
    operators. I want to be able to multiply and divide large numbers and
    real numbers (2^20 and Pi for example). I keep getting errors and
    incompatability. Thanks
    MtnSurf8, Apr 25, 2004
    #1
    1. Advertising

  2. Use the package nath_real (not synthesisable).
    Here an example

    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.math_real.all;
    entity math is
    end math;

    architecture demo of math is
    signal s, c, is_this_one : real := 0.0;
    begin
    stimuli:process
    constant delta : real := 10.0E-4;
    variable x : real := 0.0;
    begin
    x:=0.0;
    while x < 4.0*MATH_PI loop
    s <= sin(x);
    c <= cos(x);
    wait for 1 ns;
    x:=x+delta;
    end loop;
    report "finished";
    wait;
    end process;

    is_this_one <= s**2 + c**2;
    end demo;

    Egbert Molenkamp

    "MtnSurf8" <> schreef in bericht
    news:...
    > Hey there, I'm new to VHDL and was wondering how to use mathematical
    > operators. I want to be able to multiply and divide large numbers and
    > real numbers (2^20 and Pi for example). I keep getting errors and
    > incompatability. Thanks
    >
    Egbert Molenkamp, Apr 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jesus M. Salvo Jr.
    Replies:
    2
    Views:
    4,038
    robert
    Feb 11, 2006
  2. Replies:
    11
    Views:
    793
  3. Amal
    Replies:
    1
    Views:
    1,740
    vipinlal
    Mar 4, 2010
  4. Romeo Kienzler
    Replies:
    0
    Views:
    503
    Romeo Kienzler
    Jul 30, 2009
  5. Replies:
    3
    Views:
    750
    Terry Reedy
    Apr 1, 2011
Loading...

Share This Page