Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16593 Discussions

std_logic to std_logic_vector in port map

Altera_Forum
Honored Contributor II
2,945 Views

I am newbie in VHDL design and reading literature did not help ... 

 

I created entity to sync signal(s) to clk. I would like to have it generic and use it for both single signals (n=1) and vectors (n>1). The entity is declared as: 

 

entity sync2 is generic ( n : positive := 2 -- width ); port ( -- inputs d : in std_logic_vector (n-1 downto 0); clk : in std_logic; -- clock reset : in std_logic; -- asynchronous reset -- outputs q : out std_logic_vector (n - 1 downto 0) ); end entity sync2; 

 

It works perfectly for vectors but I do not know, how to connect std_logic signal to the input vector, which is in this case std_logic_vector(0 downto 0); 

 

Or is it possible to overload the declaration so the d is std_logic? 

 

signal sig1 : std_logic; signal sig2 : std_logic; ------------------------------------------------------------------------------- -- Instantiation of entity ------------------------------------------------------------------------------- sync : entity work.sync2 generic map ( n => 1 ) port map ( d => sig1, q => sig2, reset => reset, clk => clk );
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
1,639 Views

Hi, 

 

If n is say 2 and you want just put a std logic signal into d you have to do something like 

 

d => '0' & sig1, 

 

which fills up the other spaces with zero. 

 

If n = 3 it'll be 

 

d => "00" & sig1, 

 

notice the double quotation marks this time. 

 

& is used for concatination in VHDL. 

 

Cheers
0 Kudos
Altera_Forum
Honored Contributor II
1,639 Views

Yes, but what if n = 1. How do I code it? In meantime i found i can use following syntax: 

 

sync : entity work.sync2 generic map ( n => 2 ) port map ( d(0) => sig1, q(0) => sig2, reset => reset, clk => clk );
0 Kudos
Reply