EmbDev.net

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


Author: Raghavendra B. (raghavendra_b98)
Posted on:

Rate this post
0 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

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

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

Author: Raghavendra B. (raghavendra_b98)
Posted on:
Attached files:

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

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 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:
  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

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
  constant numer : INTEGER := 0; -- numerator
  constant denom : INTEGER := 1; -- denominator
  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:
  type Rational is record
     numer : integer;
     denom : integer;
  end record Rational ;

  -- use it that way:
  signal a,b: work.ratpack_extras_rational_real.Rational;

  a.numer <= 123;
  a.denom <= 12;

  b <= a;

Author: Raghavendra B. (raghavendra_b98)
Posted on:

Rate this post
0 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.

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 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));

Author: Raghavendra B. (raghavendra_b98)
Posted on:

Rate this post
0 useful
not useful
Thanks Lothar Miller..

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

above statment working fine.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.