+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Member level 4
    Points: 1,414, Level: 8

    Join Date
    Dec 2011
    Posts
    77
    Helped
    0 / 0
    Points
    1,414
    Level
    8

    Using a component in loop

    I want to instantiate (port map) a component within a process but it seems that it is not allowed. Simply, the component
    gets two integers and sends two outputs and I want to feed array elements to that.

    Code:
    for i in 0 to 7 loop
    	u1: myComponent port map( a(i), a(i+1), a(i), a(i+1));
    end loop;

    How to fix that?

    •   Alt10th June 2017, 10:34

      advertising

        
       

  2. #2
    Advanced Member level 5
    Points: 34,589, Level: 45
    Achievements:
    7 years registered

    Join Date
    Jun 2010
    Posts
    6,338
    Helped
    1848 / 1848
    Points
    34,589
    Level
    45

    Re: Using a component in loop

    Instantiate the component outside of a process.
    Instatiating a component in a process makes no sense, as that would be like adding a removing chips from a circuit board while it is running.



    •   Alt10th June 2017, 12:45

      advertising

        
       

  3. #3
    Member level 4
    Points: 1,414, Level: 8

    Join Date
    Dec 2011
    Posts
    77
    Helped
    0 / 0
    Points
    1,414
    Level
    8

    Re: Using a component in loop

    So how can I pass (map) array elements to the component?



    •   Alt10th June 2017, 14:55

      advertising

        
       

  4. #4
    Super Moderator
    Points: 234,858, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    40,581
    Helped
    12407 / 12407
    Points
    234,858
    Level
    100

    Re: Using a component in loop

    You can instantiate the component in a generate loop.



  5. #5
    Member level 4
    Points: 1,414, Level: 8

    Join Date
    Dec 2011
    Posts
    77
    Helped
    0 / 0
    Points
    1,414
    Level
    8

    Re: Using a component in loop

    I wrote

    Code:
    architecture behav of switch is
    	component cross port( x, y: in integer range 0 to 31;
    		 				s, b: out integer range 0 to 31); 
    	end component;												
    	signal tmp1, tmp2: int_array;
    begin	 	 					 
    	tmp1 <= ip;
    	gen_var:
    	for i in 0 to 6 generate
    		u1: cross port map( tmp1(i), tmp1(i+1), tmp2(i), tmp2(i+1) );
    	end generate gen_var;
    	ot <= tmp2;
    end;
    I have to say that int_array is an array of integer which is defined as

    Code:
    type int_array is array (0 to 7) of integer range 0 to 31;
    But I get this error Signal "s" has multiple sources but is not resolved. How can I fix that?



  6. #6
    Super Moderator
    Points: 234,858, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    40,581
    Helped
    12407 / 12407
    Points
    234,858
    Level
    100

    Re: Using a component in loop

    The error is expectable because the elements of tmp2 are connected to both outputs s and b. Don't know if it's a typo or an error of reasoning.

    Better to use named association for ports to avoid confusion.



    •   Alt11th June 2017, 13:52

      advertising

        
       

  7. #7
    Member level 4
    Points: 1,414, Level: 8

    Join Date
    Dec 2011
    Posts
    77
    Helped
    0 / 0
    Points
    1,414
    Level
    8

    Re: Using a component in loop

    OK I think I can fix that. I will come back.

    Code:
                    +-------+
         tmp1(0) ---|       |---- tmp2(0)
         tmp1(1) ---|       |---- tmp2(1)
            ...
         tmp1(7) ---|       |---- tmp2(7)
                    +-------+



--[[ ]]--