Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MOD operator

1,199 views
Skip to first unread message

Guilherme Corrêa

unread,
Jan 12, 2009, 7:23:50 AM1/12/09
to
Hello,

I'm facing a problem while using the MOD operator in VHDL.

The error is the following:
"Error (10327): VHDL error at deblocking_filter.vhd(627): can't
determine definition of operator ""mod"" -- found 0 possible
definitions"

I'm using the following libraries:
LIBRARY ieee;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
USE IEEE.std_logic_unsigned.all;
USE IEEE.numeric_std.all;

Thanks a lot for any information.
Guilherme Corrêa.

Alan Fitch

unread,
Jan 12, 2009, 8:01:01 AM1/12/09
to
> Guilherme Corręa.

Wow that's a lot of packages...

You definitely don't want numeric_std *and* std_logic_arith as they have
duplicate definitions.

The first step is to remove the packages you don't need. That may fix
the problem.

If that doesn't work, post the offending piece of code,

regards
Alan

--
Alan Fitch
Doulos
http://www.doulos.com

Guilherme Corrêa

unread,
Jan 12, 2009, 8:48:29 AM1/12/09
to
On 12 jan, 13:01, Alan Fitch <alan.fi...@spamtrap.com> wrote:

> Guilherme Corrêa wrote:
> > Hello,
>
> > I'm facing a problem while using the MOD operator in VHDL.
>
> > The error is the following:
> > "Error (10327): VHDL error at deblocking_filter.vhd(627): can't
> > determine definition of operator ""mod"" -- found 0 possible
> > definitions"
>
> > I'm using the following libraries:
> > LIBRARY ieee;
> > USE IEEE.std_logic_1164.all;
> > USE IEEE.std_logic_arith.all;
> > USE IEEE.std_logic_unsigned.all;
> > USE IEEE.numeric_std.all;
>
> > Thanks a lot for any information.
> > Guilherme Corrêa.

>
> Wow that's a lot of packages...
>
> You definitely don't want numeric_std *and* std_logic_arith as they have
> duplicate definitions.
>
> The first step is to remove the packages you don't need. That may fix
> the problem.
>
> If that doesn't work, post the offending piece of code,
>
> regards
> Alan
>
> --
> Alan Fitch
> Douloshttp://www.doulos.com

Firstly I had just these two packages:
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_unsigned.all;

The error was the same ("Error (10327): can't determine definition of
operator ""mod"" -- found 0 possible definitions").

Then I read somewhere that I should use IEEE.std_logic_arith.all also.
I did it and the error was still there ("Error (10327): can't


determine definition of operator ""mod"" -- found 0 possible

definitions").

Guilherme.

Alan Fitch

unread,
Jan 12, 2009, 8:53:22 AM1/12/09
to

In that case can you post the code at line 627, and also tell me the
data types being used with the mod operator?

Guilherme Corrêa

unread,
Jan 12, 2009, 8:57:47 AM1/12/09
to

line 627 is here:
write_line_T1 <= (count_cycle - "000001") MOD "000100";

but I have also tried this:
write_line_T1 <= 15 MOD 2;
and the same error occur.

types:
write_line: IN STD_LOGIC_VECTOR (1 DOWNTO 0);
SIGNAL count_cycle: STD_LOGIC_VECTOR(5 DOWNTO 0);

Thanks again.
Guilherme.

Alan Fitch

unread,
Jan 12, 2009, 9:13:37 AM1/12/09
to

<snip>

> line 627 is here:
> write_line_T1 <= (count_cycle - "000001") MOD "000100";
>
> but I have also tried this:
> write_line_T1 <= 15 MOD 2;
> and the same error occur.
>
> types:
> write_line: IN STD_LOGIC_VECTOR (1 DOWNTO 0);
> SIGNAL count_cycle: STD_LOGIC_VECTOR(5 DOWNTO 0);
>
> Thanks again.
> Guilherme.

OK, as you've discovered there's no mod for std_logic_vector.
One way to do it is to use numeric_std as follows:

use IEEE.Numeric_std.all;

Then change line 627 as follows:

write_line_T1 <= std_logic_vector( (unsigned(count_cycle) -1) mod 4);

(I assume you meant "mod 4" not "mod 2" as you had "000100" in your
original code)

Numeric_std defines unsigned arithmetic operators on combinations of
unsigned / natural and unsigned/unsigned, each operator producing an
unsigned result.

I am assuming you want unsigned arithmetic.

regards
Alan

P.S. If you end up requiring a lot of arithmetic operations, then it
would make sense to declare some of your signals unsigned instead of
std_logic_vector, as that avoids a lot of type conversions. However if
this is the only line that requires arithmetic, there's no problem doing
type conversion as you need it.

Guilherme Corrêa

unread,
Jan 12, 2009, 9:22:12 AM1/12/09
to

It worked! Thanks a lot.

Best regards,
Guilherme Corrêa.

Andy

unread,
Jan 12, 2009, 1:33:55 PM1/12/09
to
On Jan 12, 8:13 am, Alan Fitch <alan.fi...@spamtrap.com> wrote:
> P.S. If you end up requiring a lot of arithmetic operations, then it
> would make sense to declare some of your signals unsigned instead of
> std_logic_vector, as that avoids a lot of type conversions. However if
> this is the only line that requires arithmetic, there's no problem doing
> type conversion as you need it.

Rather than only using unsigned when you need to do arithmetic, I
would think about how the contents of an SLV are interpreted. If they
are interpreted numerically, then use unsigned or signed types as
appropriate. If they are interpreted as a collection of bits, without
a consistent numerical interpretation, then use SLV. For instance, an
address bus would be a good place to use unsigned types. A data bus
might need to be SLV because at different times it may contain signed,
unsigned, or non-numeric quantities. But you can do pretty much
anything with unsigned or signed that you can with SLV.

The only place to be careful about non-SL or non-SLV types is at the
top level entity of your design. The reason is that the post-synthesis
(and/or post-P&R) VHDL will almost certainly use SL & SLV, so using
them in your RTL makes it easier to swap RTL for post-synthesis code
in your testbench.

Andy

theult...@gmail.com

unread,
May 19, 2015, 8:45:34 AM5/19/15
to
Dear Guilherme,

I have been working on implementing a main memory for days now but it keeps showing error: "Error (10327): VHDL error at memory_pkg.vhd(16): can't determine definition of operator ""**"" -- found 0 possible definitions" and this has seriously slow down my coding speed. Can you help me out by telling me the possible causes as well as the possible solution to this error.

I was browsing through the net when I came across the solution provided to the similar problem. I adopted the solution but unfortunately it doesn't unravel the problem.

Best regards,

Adetola Akinwale.

GaborSzakacs

unread,
May 20, 2015, 10:33:55 AM5/20/15
to
Sounds like a library issue. What libraries are you using in the
design? One thing to note is that the error message may also be
misleading. Sometimes "found 0 definitions" really means that
it found multiple definitions (from different libraries) and
has no way to determine which to use.

--
Gabor

Andy

unread,
May 20, 2015, 11:46:24 AM5/20/15
to
You didn't say what types of data you are supplying as operands. "**" may only be defined for integer and real.

Andy

rickman

unread,
May 20, 2015, 12:22:18 PM5/20/15
to
I'm a bit confused. Your subject is about the MOD operator but you list
the exponentiation operator? Can you give us some more info? What are
your data types? Show us how the operator is used.

--

Rick
0 new messages