Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Vhdl codes for 8-bit ring counter

Hi,

I have VHDL codes for an 8-bit ring counter but when i try to compile it there are always errors (8 errors). I even tried editing some lines (lines 2 and 3) and compiled again and the errors reduced to 4 but the surprising thing is the corrections i made altered the conventional mode of entering the code. Although the errors were reduced to 4, I don't quite understand why that was possible.Please find below the first code and the edited code. I would really appreciate help on this.

first code

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.NUMERIC_STD.ALL;

entity ring_counter is

port (

DAT_O : out unsigned(7 downto 0);

RST_I : in std_logic;

CLK_I : in std_logic

);

end ring_counter;

architecture Behavioral of ring_counter is

signal temp : unsigned(7 downto 0):=(others => '0');

begin

DAT_O <= temp;

process(CLK_I)

begin

if( rising_edge(CLK_I) ) then

if (RST_I = '1') then

temp <= (0=> '1', others => '0');

else

temp(1) <= temp(0);

temp(2) <= temp(1);

temp(3) <= temp(2);

temp(4) <= temp(3);

temp(5) <= temp(4);

temp(6) <= temp(5);

temp(7) <= temp(6);

temp(0) <= temp(7);

end if;

end if;

end process;

end Behavioral;

edited code

library IEEE;

use IEEE.ALL;

use IEEE.ALL;

entity ring_counter is

port (

DAT_O : out unsigned(7 downto 0);

RST_I : in std_logic;

CLK_I : in std_logic

);

end ring_counter;

architecture Behavioral of ring_counter is

signal temp : unsigned(7 downto 0):=(others => '0');

begin

DAT_O <= temp;

process(CLK_I)

begin

if( rising_edge(CLK_I) ) then

if (RST_I = '1') then

temp <= (0=> '1', others => '0');

else

temp(1) <= temp(0);

temp(2) <= temp(1);

temp(3) <= temp(2);

temp(4) <= temp(3);

temp(5) <= temp(4);

temp(6) <= temp(5);

temp(7) <= temp(6);

temp(0) <= temp(7);

end if;

end if;

end process;

end Behavioral;

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The second one is missing library imports and can't compile. I however don't see errors with the first one.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Of course it would help if you said what error messages you got. By the way having fewer error messages doesn't mean there is fewer errors in the code, especially when you mess with something as global as library imports.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for your help so far.

    The thing is the (edited codes) codes without the library imports compiled and had fewer errors but this then brings to mind a reply to this thread that stated ewer errors doesn't mean there are fewer errors with the code.

    Please find below the errors, I hope this helps.

    Error (10481): VHDL Use Clause error at ringcounter2.vhd(2): design library "IEEE" does not contain primary unit "STD_LOGIC_1164"

    Error (10800): VHDL error at ringcounter2.vhd(2): selected name in use clause is not an expanded name

    Error (10481): VHDL Use Clause error at ringcounter2.vhd(3): design library "IEEE" does not contain primary unit "NUMERIC_STD"

    Error (10800): VHDL error at ringcounter2.vhd(3): selected name in use clause is not an expanded name

    Error (10481): VHDL Use Clause error at ringcounter2.vhd(4): design library "std" does not contain primary unit "standard"

    Error (10800): VHDL error at ringcounter2.vhd(4): selected name in use clause is not an expanded name

    Error: Quartus II Analysis & Synthesis was unsuccessful. 6 errors, 0 warnings

    Error: Quartus II Full Compilation was unsuccessful. 8 errors, 0 warnings
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Error (10481): VHDL Use Clause error at ringcounter2.vhd(2): design library "IEEE" does not contain primary unit "STD_LOGIC_1164"

    --- Quote End ---

    Either your Quartus installation or some global design settings are messed up. Nothing that can be seen in the code.