Skip to main content
deleted 2 characters in body
Source Link
toolic
  • 9.8k
  • 9
  • 27
  • 35

Replicators do not zero extend, they replicate. {7{f[2]}} means {f[2],f[2],f[2],f[2],f[2],f[2],f[2]}

You miss readmisread the message. The RHS is 9 bits but is being assigned 64 bits (the LHS width). a and b are 8 bit values, areand are used as the initial width to be replicated. theThe Replicator value (n+8) is 8. 8*8 is 64, which is now the LHS width value.

To extend leading zeros use { {n{1'b0}}, f[2] }, which in this case will evaluate to {7'b0000000,f[2]}

Most synthesizers will generate the proper logic with assign {cOut,sum} = a + b + f[2];, and this is assuming you want unsigned logic.

Replicators do not zero extend, they replicate. {7{f[2]}} means {f[2],f[2],f[2],f[2],f[2],f[2],f[2]}

You miss read the message. The RHS is 9 bits but is being assigned 64 bits (the LHS width). a and b are 8 bit values, are are used as the initial width to be replicated. the Replicator value (n+8) is 8. 8*8 is 64, which is now the LHS width value.

To extend leading zeros use { {n{1'b0}}, f[2] }, which in this case will evaluate to {7'b0000000,f[2]}

Most synthesizers will generate the proper logic with assign {cOut,sum} = a + b + f[2];, and this is assuming you want unsigned logic.

Replicators do not zero extend, they replicate. {7{f[2]}} means {f[2],f[2],f[2],f[2],f[2],f[2],f[2]}

You misread the message. The RHS is 9 bits but is being assigned 64 bits (the LHS width). a and b are 8 bit values, and are used as the initial width to be replicated. The Replicator value (n+8) is 8. 8*8 is 64, which is now the LHS width value.

To extend leading zeros use { {n{1'b0}}, f[2] }, which in this case will evaluate to {7'b0000000,f[2]}

Most synthesizers will generate the proper logic with assign {cOut,sum} = a + b + f[2];, and this is assuming you want unsigned logic.

Source Link
Greg
  • 4.5k
  • 1
  • 22
  • 32

Replicators do not zero extend, they replicate. {7{f[2]}} means {f[2],f[2],f[2],f[2],f[2],f[2],f[2]}

You miss read the message. The RHS is 9 bits but is being assigned 64 bits (the LHS width). a and b are 8 bit values, are are used as the initial width to be replicated. the Replicator value (n+8) is 8. 8*8 is 64, which is now the LHS width value.

To extend leading zeros use { {n{1'b0}}, f[2] }, which in this case will evaluate to {7'b0000000,f[2]}

Most synthesizers will generate the proper logic with assign {cOut,sum} = a + b + f[2];, and this is assuming you want unsigned logic.