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.

Papabravo

Joined Feb 24, 2006
20,618
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.
it's the same circuit

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?

KeepItSimpleStupid

Joined Mar 4, 2014
5,088
Look at data selectors/multiplexer IC's or priority encoders.

Data selectors are also a neat way of implementing functions (single output) of multiple variables (inputs). You can make comparators out of them too.

There used to be an IC that did the 4 bit ALU thing: http://lbk.fe.uni-lj.si/pdfs/PV-IC-datasheet/HCF40181.pdf

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

• 1.3 MB Views: 0

dl324

Joined Mar 30, 2015
16,174
You haven't answered the question from the first reply. Is this homework?

Thread Starter

rui gomes

Joined Dec 3, 2018
13
Yes it is

dl324

Joined Mar 30, 2015
16,174
Yes it is
For homework, you need to show your best effort so we can try to guide you to a solution. If we did your homework for you, that would be considered cheating.

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.

Thread Starter

rui gomes

Joined Dec 3, 2018
13
I haven't done the outputs of the hierarchical blocks yet but I've done all the inputs

dl324

Joined Mar 30, 2015
16,174
Thread Starter

rui gomes

Joined Dec 3, 2018
13
The text are all in Portuguese and inside the boxes just have IO from 1 to 8

dl324

Joined Mar 30, 2015
16,174
The text are all in Portuguese and inside the boxes just have IO from 1 to 8
If you use standard symbols, we might be able to work around the language barrier. Otherwise, this is an English language site.

Thread Starter

rui gomes

Joined Dec 3, 2018
13

dl324

Joined Mar 30, 2015
16,174
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?

Thread Starter

rui gomes

Joined Dec 3, 2018
13
The adder was just one of the 16 operations from below.

Yes it is supposed to be in 2's complement format.