VHDL no function declarations for operator "/" Error

OP #2594496
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
Moderator (Company: Titel) #2594543
> 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
Moderator (Company: Titel) #2594581
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;
Moderator (Company: Titel) #2594780
> 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));

Reply

A question of your own? This thread is over 14 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.