I thought that this code compiled, now it does not?

Discussion in 'VHDL' started by Bob, Aug 8, 2005.

  1. Bob

    Bob Guest

    I thought that this code compiled (old counter thread), now it does
    not?
    Maybe it never did compile but anyway this is the error I now get.
    Have any Ideas?
    I am using Xilinx ISE 6.3

    ERROR:HDLParsers:808 - C:/projects/PM_CPLD/10186201/counter16bit.vhd
    Line 32. + can not have such operands in this context.
    ERROR: XST failed

    Note: Line 32 is cnt:=cnt+1;

    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;

    use IEEE.NUMERIC_STD.ALL;

    entity counter16bit is
    port (
    -- 16-bit synchronous counter,
    CLK: in STD_LOGIC;
    RESET: in STD_LOGIC;
    RESET2: in STD_LOGIC;
    FULL: out STD_LOGIC;
    COUNT: out STD_LOGIC_VECTOR(15 downto 0)
    );
    end counter16bit;

    architecture Behavioral of counter16bit is

    begin
    process (CLK, RESET, RESET2)
    variable cnt:std_logic_vector(15 downto 0);
    variable temp_full:std_logic;

    begin
    if RESET='1' or RESET2='0' then
    COUNT <= (others => '0');
    cnt:= (others => '0'); -- occur instantly.
    FULL <= '0';
    temp_full:= '0'; -- occur instantly.

    elsif CLK='1' and CLK'event and temp_full='0' then -- rising
    edge of clk!
    cnt:=cnt+1; -- occur instantly. THIS IS
    LINE 32!
    COUNT<=cnt;
    temp_full:=cnt(15); -- occur instantly.
    FULL <= temp_full;
    end if;
    end process;

    end Behavioral;
     
    Bob, Aug 8, 2005
    #1
    1. Advertising

  2. Bob wrote:


    > ERROR:HDLParsers:808 - C:/projects/PM_CPLD/10186201/counter16bit.vhd
    > Line 32. + can not have such operands in this context.
    > ERROR: XST failed
    >
    > Note: Line 32 is cnt:=cnt+1;
    >
    > library IEEE;
    > use IEEE.STD_LOGIC_1164.ALL;
    >
    > use IEEE.NUMERIC_STD.ALL;

    ....
    > variable cnt:std_logic_vector(15 downto 0);


    Arithmetics are not defined on std_(u)logic_vectors (for a good reason).

    With IEEE.numeric_std use

    cnt:=std_logic_vector( unsigned(cnt)+1 );

    Or define cnt of type unsigned. (For addition you may also choose signed.)

    Ralf
     
    Ralf Hildebrandt, Aug 8, 2005
    #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.

Share This Page