3

I need to make sign extension from a 4-bit number to a 32-bit number. I try to repeat the MSB 28 times like this:

assign x={28'b{a[3]},a[3:0]};

But, I get an error:

Syntax error near "{"

x is defined as :wire [31:0] x ;

a is defined as : input [3:0]a;

Is this concatenation wrong?

toolic
  • 57,801
  • 17
  • 75
  • 117
sepeee
  • 47
  • 1
  • 6

1 Answers1

7

You need to get rid of the 'b and add another pair of {}:

assign x = { {28{a[3]}}, a};

Refer to IEEE Std 1800-2012, section 11.4.12.1 "Replication operator".

Greg
  • 18,111
  • 5
  • 46
  • 68
toolic
  • 57,801
  • 17
  • 75
  • 117