error with REM of numeric_std

Discussion in 'VHDL' started by Loppy, May 20, 2006.

  1. Loppy

    Loppy Guest

    I am triying translate the C code:

    int incrementarmodL(int input,int mod)
    {
    int salida;

    salida = (input+2)%mod;
    return salida;
    }

    to vhdl with REM operator

    the code that I make is:

    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    use IEEE.NUMERIC_STD.ALL;
    --use IEEE.STD_LOGIC_ARITH.ALL;
    --use IEEE.STD_LOGIC_UNSIGNED.ALL;



    entity inc2modL is
    generic ( constant paso: std_logic_vector(7 downto 0):="00000010";
    constant cero: std_logic_vector(7 downto 0):="00000000"
    );

    port ( entrada : in std_logic_vector(7 downto 0);
    modulo : in std_logic_vector(7 downto 0);
    reset : in std_logic;
    salida : inout std_logic_vector(7 downto 0)
    );
    end inc2modL;

    architecture comportamiento of inc2modL is
    signal ent2 : std_logic_vector(7 downto 0);
    signal v1: UNSIGNED(7 downto 0);
    signal v2: UNSIGNED(7 downto 0);
    signal v3: UNSIGNED(7 downto 0);

    begin

    process(entrada,modulo,reset)

    begin

    if reset='1' then
    salida <= cero;
    else
    ent2 <= entrada or paso;

    v1 <= UNSIGNED(ent2);
    v2 <= UNSIGNED(modulo);
    v3 <= v1 REM v2;

    salida <= std_logic_vector(v3);
    end if;

    end process;


    end comportamiento;

    when I synthesize, the reports said:

    ERROR:Xst:769 - C:/Almacen/Proyecto/Proyectos/pfc/inc2modl.vhd line 40:
    Operator <INVALID OPERATOR> must have constant operands or first
    operand must be power of 2


    Anybody Can help me. Thanks
     
    Loppy, May 20, 2006
    #1
    1. Advertising

  2. Loppy

    KJ Guest


    > ERROR:Xst:769 - C:/Almacen/Proyecto/Proyectos/pfc/inc2modl.vhd line 40:
    > Operator <INVALID OPERATOR> must have constant operands or first
    > operand must be power of 2
    >

    I think the error message is pretty clear....'v2' is not constant or a power
    of 2 (i.e. 2, 4, 8, 16).

    From a VHDL language perspective, 'v2' does not need to be a constant or a
    power of 2 but the synthesis tool that is giving you the error requires it
    to be constant or power of 2....which, by the way, is typical of a synthesis
    tool since dividing or getting the remainder when the divisor is an
    arbitrary number results in a huge chunk of logic.

    If you need to synthesize and have an arbitrary number than you need to
    write some code on your own

    KJ
     
    KJ, May 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mohammed  khader
    Replies:
    1
    Views:
    2,298
    Alan Fitch
    Nov 1, 2004
  2. salmanghafoor1

    Use of rem in VHDL

    salmanghafoor1, Aug 2, 2007, in forum: VHDL
    Replies:
    0
    Views:
    1,230
    salmanghafoor1
    Aug 2, 2007
  3. sonny
    Replies:
    2
    Views:
    470
  4. yyuu

    [ANN] rem 0.0.7 released.

    yyuu, Nov 24, 2004, in forum: Ruby
    Replies:
    2
    Views:
    118
  5. Roger Pack

    windows system("@rem") behavior

    Roger Pack, Feb 10, 2011, in forum: Ruby
    Replies:
    1
    Views:
    90
    Roger Pack
    Feb 17, 2011
Loading...

Share This Page