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.

error perfix of indexed name.......

Status
Not open for further replies.

boyzzun

Junior Member level 1
Joined
Mar 16, 2012
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,531
hi guys,i have learned abuot VHDL on modelsim and i have o problem when i learn adder 4 bit
PHP:
--------------4-bit adder-----------
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.std_logic_arith.ALL;
use ieee.std_logic_unsigned.ALL;
-----------------------------------
entity adder4 is
port ( A :  in std_logic;
       B :  in std_logic;
	   CI : in std_logic;
	   SUM : out std_logic;
	   CO : out std_logic
	   );
end adder4;
---------------------------------------
architecture structure of adder4 is
signal C : std_logic_vector(2 downto 0);
component full_adder 
  port ( 
      A    :  in std_logic;
	  B    :  in std_logic;
	  Cin  :  in std_logic;
	  S    :  out std_logic;
	  Cout :  out std_logic
      );
  end component;
  for u0: full_adder use entity work.full_adder(dataflow);
  for u1: full_adder use entity work.full_adder(dataflow);
  for u2: full_adder use entity work.full_adder(dataflow);
  for u3: full_adder use entity work.full_adder(dataflow);
begin
 u0: component full_adder 
        port map ( A => A(0), B => B(0), Cin => CI, 
	            S =>Sum(0), Cout => C(0));
 u1 : component full_adder 
        port map ( A => A(1), B => B(1), Cin => C(0), 
	             S =>Sum(1), Cout => C(1));
 u2 : component full_adder 
        port map ( A => A(2), B => B(2), Cin => C(1), 
	             S =>Sum(2), Cout => C(2));
u3 : component full_adder 
        port map ( A => A(3), B => B(3), Cin => C(2), 
	             S =>Sum(3), Cout => CO);
end structure ;
--------------------------------------------------------------------------
full_adder
PHP:
-----------full_adder---------
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.std_logic_arith.ALL;
use ieee.std_logic_unsigned.ALL;
-----------------------------------
entity full_adder is
port ( A :  in std_logic;
       B :  in std_logic;
	   Cin : in std_logic;
	   S : out std_logic;
	   Cout : out std_logic
	   );
end full_adder;
--------- -----------------------------
architecture dataflow of full_adder is
begin
    S   <= A xor B xor Cin ;
	Cout <= (A and B ) or (Cin and (A or B));
end dataflow;
well i don'nt know error from adder4bit,can you help me
 

you're accessing A(0) when you instantiate the full adders, but A is only a single bit - it is not an array type.

---------- Post added at 10:24 ---------- Previous post was at 10:23 ----------

You seem to be doing this for all top level inputs (ie. they're not arrays, but you are treating them like they are)
 

well,i have just learned abuot VHDL,in my teacher book and his examples ,code similar mine,so i have to fix where in my code,thanks

---------- Post added at 01:54 ---------- Previous post was at 01:53 ----------

you're accessing A(0) when you instantiate the full adders, but A is only a single bit - it is not an array type.

---------- Post added at 10:24 ---------- Previous post was at 10:23 ----------

You seem to be doing this for all top level inputs (ie. they're not arrays, but you are treating them like they are)
well,i have just learned abuot VHDL,in my teacher book and his examples ,code similar mine,so i have to fix where in my code,thanks
 

well,i have just learned abuot VHDL,in my teacher book and his examples ,code similar mine,so i have to fix where in my code,thanks

---------- Post added at 01:54 ---------- Previous post was at 01:53 ----------


well,i have just learned abuot VHDL,in my teacher book and his examples ,code similar mine,so i have to fix where in my code,thanks

Code:
[LEFT][TABLE="class: vhdl syntaxHighlighter expand"]
[TR]
[TD="colspan: 2"]Code VHDL - [[COLOR=#226c22]expand[/COLOR]][/TD]
[/TR]
[TR="class: li1"]
[TD]
12345678[/TD]
[TD]
[COLOR=#000080][B]entity[/B][/COLOR] adder4 [COLOR=#000080][B]is[/B][/COLOR] [COLOR=#000080][B]port[/B][/COLOR] [COLOR=#000066]([/COLOR] A [COLOR=#000066]:[/COLOR]  [COLOR=#000080][B]in[/B][/COLOR] [COLOR=#0000ff]std_logic[/COLOR][COLOR=#ff0000]_vector(3 [B]downto[/B] 0)[/COLOR][COLOR=#000066];[/COLOR]        B [COLOR=#000066]:[/COLOR]  [COLOR=#000080][B]in[/B][/COLOR] [COLOR=#0000ff]std_logic[COLOR=#ff0000]_vector(3 [B]downto[/B] 0)[/COLOR][/COLOR][COLOR=#000066];[/COLOR]        CI [COLOR=#000066]:[/COLOR] [COLOR=#000080][B]in[/B][/COLOR] [COLOR=#0000ff]std_logic[/COLOR][COLOR=#000066];[/COLOR]        SUM [COLOR=#000066]:[/COLOR] [COLOR=#000080][B]out[/B][/COLOR] [COLOR=#0000ff]std_logic[COLOR=#ff0000]_vector(3 [B]downto[/B] 0)[/COLOR][/COLOR][COLOR=#000066];[/COLOR]        CO [COLOR=#000066]:[/COLOR] [COLOR=#000080][B]out[/B][/COLOR] [COLOR=#0000ff]std_logic[/COLOR]        [COLOR=#000066])[/COLOR][COLOR=#000066];[/COLOR] [COLOR=#000080][B]end[/B][/COLOR] adder4[COLOR=#000066];[/COLOR][/TD]
[/TR]
[/TABLE]
[/LEFT]

Kevin Jennings
 

    V

    Points: 2
    Helpful Answer Positive Rating
Code:
[LEFT][TABLE="class: vhdl syntaxHighlighter expand"]
[TR]
[TD="colspan: 2"]Code VHDL - [[COLOR=#226c22]expand[/COLOR]][/TD]
[/TR]
[TR="class: li1"]
[TD]
12345678[/TD]
[TD]
[COLOR=#000080][B]entity[/B][/COLOR] adder4 [COLOR=#000080][B]is[/B][/COLOR] [COLOR=#000080][B]port[/B][/COLOR] [COLOR=#000066]([/COLOR] A [COLOR=#000066]:[/COLOR]  [COLOR=#000080][B]in[/B][/COLOR] [COLOR=#0000ff]std_logic[/COLOR][COLOR=#ff0000]_vector(3 [B]downto[/B] 0)[/COLOR][COLOR=#000066];[/COLOR]        B [COLOR=#000066]:[/COLOR]  [COLOR=#000080][B]in[/B][/COLOR] [COLOR=#0000ff]std_logic[COLOR=#ff0000]_vector(3 [B]downto[/B] 0)[/COLOR][/COLOR][COLOR=#000066];[/COLOR]        CI [COLOR=#000066]:[/COLOR] [COLOR=#000080][B]in[/B][/COLOR] [COLOR=#0000ff]std_logic[/COLOR][COLOR=#000066];[/COLOR]        SUM [COLOR=#000066]:[/COLOR] [COLOR=#000080][B]out[/B][/COLOR] [COLOR=#0000ff]std_logic[COLOR=#ff0000]_vector(3 [B]downto[/B] 0)[/COLOR][/COLOR][COLOR=#000066];[/COLOR]        CO [COLOR=#000066]:[/COLOR] [COLOR=#000080][B]out[/B][/COLOR] [COLOR=#0000ff]std_logic[/COLOR]        [COLOR=#000066])[/COLOR][COLOR=#000066];[/COLOR] [COLOR=#000080][B]end[/B][/COLOR] adder4[COLOR=#000066];[/COLOR][/TD]
[/TR]
[/TABLE]
[/LEFT]

Kevin Jennings
OMG im so stupid,thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top