Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

Signed integer and 2 complement

Altera_Forum
Honored Contributor II
3,857 Views

Hi. I am confusing with the signed integer and 2 complement in verilog. 

 

1. if i declare b is [3:0] signed reg , what would be the bit representation if b is -3? 1011? or.... 

 

2. Previously we use the 2 complement to represent negative number and now the existance of signed number in verilog, is it indicatng that we are not going to use 2 complement? Pls clarify on it. 

 

e.g signed A - signed B  

or 2'complent A - 2'complement B  

 

Which one is true or both? 

 

Thanks
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
2,768 Views

-3 would be 1101 if you have MSB first 1101 LSB least 

4'b1101 in verilog expression 

 

signed registers were introduced with verilog 2001, so before that there were no signed registers. also with verilog 2001 the signed shift operators >>> and <<< were introduced, as << and >> were pure verilog 

 

so both is possible, depending on the language
0 Kudos
Altera_Forum
Honored Contributor II
2,768 Views

- 3 -> 1101  

 

signed == two's complement in Verilog and VHDL. 

 

Sign + magnitude representation (-3 -> 1011) is used only in floating point arithmetic. Fixed point arithmetic uses two's complement representation. Two's complement circuits are quite cheaper than sign magnitude circuits.
0 Kudos
Reply