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

Conditional when statement with port map

Altera_Forum
Honored Contributor II
1,755 Views

Hi, 

 

I am trying to write a conditional concurrent port map without success. Here it is. 

 

map_gen: for i in 0 to N-1 generate map_0: entity work.my_tff(arch) port map('1', '1', clk, s_q_out(0), s_en_out(0)) when i=0 else map_g: entity work.my_tff(arch) port map(s_q_out(i-1), s_en_out(i-1), clk, s_q_out(i), s_en_out(i)); end generate;  

 

What´s is wrong? 

 

Regards 

Jaraqui
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
289 Views

 

--- Quote Start ---  

Hi, 

 

I am trying to write a conditional concurrent port map without success. Here it is. 

 

map_gen: for i in 0 to N-1 generate map_0: entity work.my_tff(arch) port map('1', '1', clk, s_q_out(0), s_en_out(0)) when i=0 else map_g: entity work.my_tff(arch) port map(s_q_out(i-1), s_en_out(i-1), clk, s_q_out(i), s_en_out(i)); end generate;  

 

What´s is wrong? 

 

Regards 

Jaraqui 

--- Quote End ---  

 

 

why don't you just port map for case 0 directly then generate for case i in 1 to N-1 

anyway you can't use if like that. each generate is written with its condition being true
0 Kudos
Altera_Forum
Honored Contributor II
289 Views

Just trying to write compact code... only for curiosity.  

 

Looking at the when/else examples of the books, I allways observed that a just single statement is presented. 

What happens if someone is interested to write something like the code bellow? Is it possible? 

 

statement_a_1; statement_a_2; ... when signal = a else statement_b_1; statement_b_2; ... when signal = b else ... statement_z_1; statement_z_2;  

 

Regards 

Jaraqui
0 Kudos
Altera_Forum
Honored Contributor II
289 Views

you code isnt quite right, because it has too many ; in it. I think you mean something like: 

 

a <= b when x = '1' else c when y = '1' else d when z = '1' else e;  

 

Remember to have the final else, otherwise you generate a latch.
0 Kudos
Reply