# How to implement two compliment circuits using sequential circuit?

Status
Not open for further replies.

#### MSRA

##### Full Member level 2
How to impliment 2's compliment circuit using sequential circuit...?

#### dineshbabumm

2's compliment

A simple logic wil be to implement it directly as we do in straight forward hand calculations..

First complement every bit using an inverter and feed it to shift registers(if you want 4 bit,then use 4 shift registers..).. Now they wil be storing the 1's complement in them.. Feed it to an adder with the 1's complement as one input and 1 as another input.. The adder result wil be your 2's complement!

#### MSRA

##### Full Member level 2
2's compliment

is it the whole sequential procedur.....?

#### A.Anand Srinivasan

Re: 2's compliment

ya that is the required sequential circuit... 2's compliment is just 1's compliment plus 1....

#### dineshbabumm

Re: 2's compliment

MSRA said:
is it the whole sequential procedur.....?

Yes it is the whole sequential procedure..

#### cydi

##### Full Member level 3
2's compliment

If you are talking about an ADC output, then the matter is different. If you want to find the rep for any number, for seq circuits, the way to go is compliment all and add one...

#### Kral

Re: 2's compliment

MSRA,
One way:
Shift the original number LSB first. The bits are unaltered until the bit after the first "1" is encountered. All subsequent bits are complemented.
Regards,
Kral

2's compliment

#### alam.tauqueer

##### Full Member level 2
2's compliment

1). Start shifting from LSB bits unaltered until the first "1" is encountered.
2).All subsequent bits are complemented.

#### suru

##### Full Member level 3
2's compliment

through VHDL coding also can be done.
simple code.

signal x;std_logic;
begin
x<= not y;
x<=X+'1';

#### rakesh_vnit

##### Member level 3
Re: 2's compliment

as it is a sequential input...u cant take 1's complement n then add 1...

1. start from LSB go left until u encounter 1, leave all the inputs as it is...
2. complement all the bits after the first one...

it will give u 2's complement...while workin sequentially...

#### roahan_ramesh

##### Newbie level 5
Re: 2's compliment

One way to do it is the following :

1. Using an X-OR gate (it is a controlled inverter) pass logic 1 into one pin and the data (say pin B) in the other if you want to invert the data. If you pass logic 0 then no inversion occurs.
2. Then using an adder circuit using add 1 to the output from the X-OR gates and apply 0 to the other input (say pin A)
3. This way you will have an adder/subtractor circuit.

Status
Not open for further replies.