Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL : error with code

Status
Not open for further replies.

makanaky

Advanced Member level 4
Joined
Feb 1, 2007
Messages
104
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
1,944
Hi can you please tell me what's wrong with this VHDL code as I get these errors :

ERROR:HDLParsers:3312 - "C:/Documents and Settings/ahmed/projectat/components_trial.vhd" Line 42. Undefined symbol 'std_logic'.
ERROR:HDLParsers:1209 - "C:/Documents and Settings/ahmed/projectat/components_trial.vhd" Line 42. std_logic: Undefined symbol (last report in this block)

Code :

Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity xnor_gate is
port (in1 : in std_logic;
      in2 : in std_logic;
		out1 : out std_logic);
end xnor_gate ;

architecture x of xnor_gate is 
begin
out1<=in1 xnor in2;
end x;

entity and_gate is
port (ind1 : in std_logic ;
      ind2 : in std_logic;
		ind3 : in std_logic;
      ind4 : in std_logic;
		out1 : out std_logic);		
end entity;

architecture xx of and_gate is 
begin
out1<=ind1 and ind2 and ind3 and ind4;
end xx;

entity components_trial is
    Port ( a : in  STD_LOGIC_VECTOR (3 downto 0);
           b : in  STD_LOGIC_VECTOR (3 downto 0);
           op : out  STD_LOGIC);
end components_trial;


architecture Behavioral of components_trial is

component xnor_gate is
port (in1 : in std_logic;
      in2 : in std_logic;
		out1 : out std_logic);
end component;

component and_gate is
port (ind1 : in std_logic;
      ind2 : in std_logic;
		ind3 : in std_logic;
      ind4 : in std_logic;
		out1 : out std_logic);		
end component;

signal w,x,y,z : std_logic;

begin

u1:xnor_gate 
port map ( in1=>a(0) ,
           in2=>b(0) ,
			  out1=> w);
			  
u2:xnor_gate 
port map ( in1=>a(1) ,
           in2=>b(1) ,
			  out1=> x);
u3:xnor_gate 
port map ( in1=>a(2) ,
           in2=>b(2) ,
			  out1=> y);
u4:xnor_gate 
port map ( in1=>a(3) ,
           in2=>b(3) ,
			  out1=> z);
u5:and_gate 
port map ( ind1=>w ,
           ind2=>x ,
			  ind3=>y,
           ind4=>z ,

			  out1=> op);
			  
			  



end Behavioral;
 

That's a complete mess.
Why are there so many entities and so many architectures in a single VHD file ?!
Use one entity and one architecture per VHD file.
Then, connect all your entities (now as components) in another top entity.
 
Last edited:
You need to include the following lines before each entity
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

You didn't ask, but you shouldn't be using
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

Instead, use ieee.numeric_std.all;

KJ
 
Although not suggested for design clarity, having multiple entities in a design file is legal VHDL. They are treated the same as separate design files, you need to repeat the library definition for each entity.

P.S.: There's no arithmetic involved in your design. std_logic library is all you need.
 
You need to define the LIBRARY and USE, before each ENTITY instead this one is define in the top of the file.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top