-2

I'm trying to perform bus invert coding among two binary sequences, say a 8 bit sequence like 00011011 & 10110011.

As per the method to perform invert coding, the hamming distances are first calculated (XOR operation is performed between the two sequences).

XOR Operation for the two sequences gives 10101000.

Hamming distances denotes the number of 1's in the XOR operation result.

Here Hamming distance is 3.

According to the general rule of Bus Invert Coding, the sequence will be inverted (0's as 1's & 1's as 0's), if hamming distance is greater than half the length of the bit sequence. An additional 1 will be added at the beginning of the sequence. If the hamming distance is less than half the length of the bit sequence, the sequence will not be inverted and a 0 is added at the beginning of the sequence.

Ashwin
  • 3
  • 2
  • 5

1 Answers1

1

~ is a bitwise invert (ones complement).
- is numerical invert (twos complement).

~00011011 => 11100100
-00011011 => 11100101 

In verilog ^ is bitwise XOR, for example:

00011011 ^ 10110011 => 10101000

SystemVerilog has $countones() function although it may not be synthesis able by your tools, this part of the question has been asked before one example.

I appreciate while learning the language the reference manual can seem daunting but it is very useful for finding operations and functions:

SystemVerilog IEEE 1800-2012 Standard

Community
  • 1
  • 1
Morgan
  • 19,934
  • 8
  • 58
  • 84