FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > VHDL

VHDL comp.lang.vhdl newsgroup / Usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-12-2009, 12:23 PM
Guilherme Corrêa
Guest
 
Posts: n/a
Default MOD operator

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.
Reply With Quote
  #2 (permalink)  
Old 01-12-2009, 01:01 PM
Alan Fitch
Guest
 
Posts: n/a
Default Re: MOD operator

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
Doulos
http://www.doulos.com
Reply With Quote
  #3 (permalink)  
Old 01-12-2009, 01:48 PM
Guilherme Corrêa
Guest
 
Posts: n/a
Default Re: MOD operator

On 12 jan, 13:01, Alan Fitch <[email protected]> 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.
Reply With Quote
  #4 (permalink)  
Old 01-12-2009, 01:53 PM
Alan Fitch
Guest
 
Posts: n/a
Default Re: MOD operator

Guilherme Corrêa wrote:
> On 12 jan, 13:01, Alan Fitch <[email protected]> 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.


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

regards
Alan

--
Alan Fitch
Doulos
http://www.doulos.com
Reply With Quote
  #5 (permalink)  
Old 01-12-2009, 01:57 PM
Guilherme Corrêa
Guest
 
Posts: n/a
Default Re: MOD operator

On 12 jan, 13:53, Alan Fitch <[email protected]> wrote:
> Guilherme Corrêa wrote:
> > On 12 jan, 13:01, Alan Fitch <[email protected]> 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.

>
> In that case can you post the code at line 627, and also tell me the
> data types being used with the mod operator?
>
> regards
> Alan
>
> --
> Alan Fitch
> Douloshttp://www.doulos.com


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.
Reply With Quote
  #6 (permalink)  
Old 01-12-2009, 02:13 PM
Alan Fitch
Guest
 
Posts: n/a
Default Re: MOD operator



<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.

--
Alan Fitch
Doulos
http://www.doulos.com
Reply With Quote
  #7 (permalink)  
Old 01-12-2009, 02:22 PM
Guilherme Corrêa
Guest
 
Posts: n/a
Default Re: MOD operator

On 12 jan, 14:13, Alan Fitch <[email protected]> wrote:
> <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.
>
> --
> Alan Fitch
> Douloshttp://www.doulos.com


It worked! Thanks a lot.

Best regards,
Guilherme Corrêa.
Reply With Quote
  #8 (permalink)  
Old 01-12-2009, 06:33 PM
Andy
Guest
 
Posts: n/a
Default Re: MOD operator

On Jan 12, 8:13*am, Alan Fitch <[email protected]> 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
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
shift operator raghu Verilog 5 07-11-2006 04:52 PM
synthesizable MOD operator Basel Naamna VHDL 2 05-14-2004 04:35 PM
MOD operator synthesis Basel Naamna VHDL 2 05-10-2004 10:51 PM
Shift operator Andreas VHDL 0 05-04-2004 04:50 PM
New operator creation Grigorios Angelis VHDL 6 03-02-2004 12:47 AM


All times are GMT +1. The time now is 12:12 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved