Mathematical Operations in VHDL

M

MtnSurf8

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
 
E

Egbert Molenkamp

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top