0
reg [3:0]a;
reg in;

a <= {a[2:0],in}; //1- Using Concatenate 
                       Operator

a <= a<<1; //2- Using Shift operator

What is the difference between 1 & 2 in terms of:

a) Speed of operation.

b) Hardware Implementation in synthesis.

Which one is preferred generally?

Archeologist
  • 169
  • 1
  • 11

2 Answers2

1

the << shift operators shifts bits left by the specified number. It will shift 0 in the least significant bit:

a: 0011 << 1 --> 0110
                    ^ -- shifted in bit

the concat operator from your example concatenates some bits from a and the in value:

a: 0011
in: 1
{a[2:0], in} --> 0111

however, the following does the same as the shift by one:

{a[2:0], 1'b0} --> 0110
Serge
  • 11,616
  • 3
  • 18
  • 28
0

Assuming that you replace in with 1'b0 to make the two examples behave identically, these will synthesize to the exact same hardware implementation with any modern synthesis tool. I would be surprised if there is a simulation performance difference, but it's in any case not something I would worry about. I would suggest to use the syntax you find to be most readable.

pc3e
  • 1,299
  • 11
  • 18