EmbDev.net

Forum: FPGA, VHDL & Verilog VHDL no function declarations for operator "/" Error


von Raghavendra B. (raghavendra_b98)


Rate this post
useful
not useful
Hi all,
In my package declared below and performing rational division 
operation,once i ran on GHDL VHDL simulator gave an error "no function 
declarations for operator "/""

 variable w,x : integer;
 variable num : real;
 begin
  w := numerator(a);
  x := denominator(a);
  num :=(a(numer))/(a(denom));

Thanks in advance
Regards
Raghavendra

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
I cannot understand your code...
For real operations: did you include the  ieee.math_real.all?

von Raghavendra B. (raghavendra_b98)


Attached files:

Rate this post
useful
not useful
Thanks .i attached my source code.actually its package ...

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
> i attached my source code.
Thats not the complete code. At least the libraries are missing...

And this seems to be wrong:
1
  type rational is array (natural range numer to denom) of integer; -- range -16384 to 16383;
Usually the range of an integer is -2^31 to 2^31-1

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
1
  constant numer : INTEGER := 0; -- numerator
2
  constant denom : INTEGER := 1; -- denominator
3
  type rational is array (natural range numer to denom) of integer;
Why do you not use a record?
That would be the ideal solution for your fractional number:
1
  type Rational is record
2
     numer : integer;
3
     denom : integer;
4
  end record Rational ;
5
6
  -- use it that way:
7
  signal a,b: work.ratpack_extras_rational_real.Rational;
8
9
  a.numer <= 123;
10
  a.denom <= 12;
11
12
  b <= a;

von Raghavendra B. (raghavendra_b98)


Rate this post
useful
not useful
> Thats not the complete code.
 actually its a complete package.

i will try whatever you suggested,whats the problem in my code.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
> no function declarations for operator "/"
There is no definition for a integer division resulting in a float 
value. Try this
   num := real(a(numer))/real(a(denom));

von Raghavendra B. (raghavendra_b98)


Rate this post
useful
not useful
Thanks Lothar Miller..

>    num := real(a(numer))/real(a(denom));

above statment working fine.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.