ALU Design Adder

Thread Starter

rui gomes

Joined Dec 3, 2018
13
I have to make an ALU that add 2 4bit numbers represented in 2's complement.
Does somebody know how can i make this?
 

sc0tch

Joined Nov 6, 2018
64
Is this a homework assignment?

Edit:
A starting point would be to simply look at how adding in binary works.
0+1=1
1+0=1
0+0=0
1+1=0 Carry a 1

This can be expressed as q=xor(ab) and c=and(ab)

This is called a half adder circuit. A full adder needs to also accept a carry input as well.
 
Last edited:

Thread Starter

rui gomes

Joined Dec 3, 2018
13
I'm not having trouble adding two binary 4 bit number instead I don't know how to make the adding with 2's complements numbers.
 

sc0tch

Joined Nov 6, 2018
64
I'm not having trouble adding two binary 4 bit number instead I don't know how to make the adding with 2's complements numbers.

2s complement is simply a way of expressing a signed integer and is used because addition and subtraction can be done using the same circuit when the numbers are expressed as a 2s complement integer.

However, seeing as this appears to be a homework assignment we aren't going to solve the issue for you as it is against the forum rules, and would be a disservice toward education. If a part of your requirement is to convert into 2s complement from standard binary integer notation then any positive number will remain the same while negative numbers should be inverted and have 1 added to them. IE.... -2 or negative of 010 will be 1110.

This is because 2 would be 0010 then we invert to 1101. Finally we add 1 to get 1110.

This also works in inverse to go back to its complement if you invert 1110 you get 0001 then add 1 to get 0010 again.

If you have any other questions please post some proof that you have attempted to solve the assignment and what exactly you are having problems with.
 

Thread Starter

rui gomes

Joined Dec 3, 2018
13
Thanks for the help. I finnaly made the 16 operations of the ALU but now i have to make a selector that activates one operation at a time.

Is there any component that does such thing?
 

absf

Joined Dec 29, 2010
1,968
There is "1 out of 16 selector or decoder" 74HC154. Datasheet attached.

The logic diagram is on page 3 of the datasheet if you want to construct your own out of discrete gates.
 

Attachments

Thread Starter

rui gomes

Joined Dec 3, 2018
13
Yes you're right. I almost finish the ALU. I'm having trouble just to make the selector because there are 16 operations with 8bit input and they do not have enables that I can turn off to choose one at a time.
 

sc0tch

Joined Nov 6, 2018
64
Yes you're right. I almost finish the ALU. I'm having trouble just to make the selector because there are 16 operations with 8bit input and they do not have enables that I can turn off to choose one at a time.
Please post your schematic so we can help guide you on an appropriate selector and or multiplexer and to show your work as this is school homework.
 

dl324

Joined Mar 30, 2015
16,945
The problem statement was to add two 4 bit 2's complement numbers. Why do you have unnecessary arithmetic blocks placed?

Is the sum also supposed to be in 2's complement format?
 
Top