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

Curly braces

Altera_Forum
Honored Contributor II
2,138 Views

Hi, 

 

I was looking through a program and found the following code  

{a2, a1} <= {a1, b}; 

 

I am not sure whether the program that I'm going through is written in Verilog or System Verilog. I know the curly braces are used for concatenation operation in verilog, but then I don't quite follow what kind of concatenation is being done here. Also since I'm not sure whether the given snippet is in verilog or system verilog, I'm left confused with the code. Also does curly braces denote another operation in system verilog..? 

 

Thanks in advance :)
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
1,222 Views

 

--- Quote Start ---  

Hi, 

 

I was looking through a program and found the following code  

{a2, a1} <= {a1, b}; 

 

I am not sure whether the program that I'm going through is written in Verilog or System Verilog. I know the curly braces are used for concatenation operation in verilog, but then I don't quite follow what kind of concatenation is being done here. Also since I'm not sure whether the given snippet is in verilog or system verilog, I'm left confused with the code. Also does curly braces denote another operation in system verilog..? 

 

Thanks in advance :) 

--- Quote End ---  

 

 

It could be a shift operation: 

a2 < a1; 

a1 <= b;
0 Kudos
Altera_Forum
Honored Contributor II
1,221 Views

 

--- Quote Start ---  

It could be a shift operation: 

a2 < a1; 

a1 <= b; 

--- Quote End ---  

 

 

Thank you for the answer. Yes it is a shift. What I really wanted to know was why concatenation is being done on the right hand side. I figured that both on the LHS and RHS the given two registers are concatenated together (on each side) and then mapped bit by bit.
0 Kudos
Altera_Forum
Honored Contributor II
1,222 Views

If a1, a2, b are all the same bit width, then: 

 

{a2, a1} <= {a1, b}; 

 

is the same as writing: 

 

a2 <= a1; 

a1 <= b; 

 

or even: 

 

a1 <= b; 

a2 <= a1; 

 

the result will be the same given the non-blocking assignment usage. The curly brace version is just a syntactical shorthand. 

 

However, if the bit widths of a1, a2, and b are not all the same, then other operations could be taking place. So the real answer is 'it depends'.
0 Kudos
Reply