ALU Design Adder

sc0tch

Joined Nov 6, 2018
64
In many cases you can use the same gates for many operations.

For example A-B is the same as A + the complement of B.

A=B is If A+ complement of B =0
A not equal B is the above inverted.

A>B is A+ compliment of B is positive and not 0.

A<B is A + compliment if B is negative and not 0

Equal to or greater than/less than is positive/negative or 0

Not sure what the actual assignment is, but I'm sure the teacher would like to see some thought put into efficiency, but we don't have much information as far as the assignment goes, or what year you are into your program.
 

sc0tch

Joined Nov 6, 2018
64
For A-B and A+B I use 74LS283 and for A>B and A<B I use 74LS85

I just started 3 months ago
What are the actual requirements of the assignment. And it's been a while since ive used these ICs but im pretty sure for the 74LS283 you will need to get the compliment of B in order to do A-B as it is just an adder. Also is your inputs in 2s compliment, or are they 4 bit signed or unsigned integers?

As far as the 74LS85 you will just use a MUX to select which output you require to be selected for your output. But please post the actual assignment as it states in your course work(preferably in english) so we can actually know what they want to see. As the original question was just about an adder, then you started throwing additional requirements in. Be alot easier if we knew exactly what is expected. Also please post any schematics you have so we can see youve attempted to solve the problem and where exactly your stuck.

Thanks
 

Thread Starter

rui gomes

Joined Dec 3, 2018
13
The assignement says.

The objective is to make an ALU that does arithmetic, logic and comparison operations between 2 numbers with 4bit each. The operations must be selected by OPSEL. The numbers are intengers represented in 2's complement. The output is 8 bit and must be represented in 2's complement aswell. The result of comparison operations is given by the less significant output number. The other numbers must be displaying 0. If the operation is false every number must be 0 if not the last number must be 1. The main objective of the assignment is to make a functional system with the less ports possible. The number of bits of OPSEL is choose by the student and each number must select a different operation. It's not allowed to use components that have ALU's and multipliers. However you can use adders, comparisons, encoders, decoders, multiplexers and demultiplexers.Sem Título5.jpg
 

sc0tch

Joined Nov 6, 2018
64
And what is your schematic thus far? your last schematic really had no work shown on it, sorry but we can't do the work for you we need to see you are putting effort into the assignment and getting the learning objectives here. I am interested in seeing your logic gate schematic for the inputs, how you plan to pre-process these inputs(when necessary convert to the input to it's inverse complement).

How you plan to organize the logic gates for multiplication? how do you plan to handle carry-out from your full adder(IE dosn't fit in a 4 bit signed integer)? We are all willing to help, but we need to see more than a square drawn for each operation.
 
Am I reading the assignment right.

4 bit 2's complement in: [-6 (1111) to 7 (0111)]

Then the output may need to be sign extended to get -1 of 1111 1111 which is 8-bit 2's complement.

The numbers are intengers represented in 2's complement. The output is 8 bit and must be represented in 2's complement aswell.
i think it would have been better to say:

The inputs are integers represented in 4-bit 2's complement. The output is 8 bit 2-complement.

And and or would hopefully give you a 8 bit result with 0000 as the high bits.

XOR is a weird operation with 4 bit signed numbers in and 8 bit out. You usually expect the bit length to be the same. I doesn't fit the mold well.
I'd be tempted to sign extend negative numbers.

Think of -1 XOR -1 when both are 4 bit and both are 8 bit 2's complement.
 

sc0tch

Joined Nov 6, 2018
64
Am I reading the assignment right.

4 bit 2's complement in: [-6 (1111) to 7 (0111)]

Then the output may need to be sign extended to get -1 of 1111 1111 which is 8-bit 2's complement.



i think it would have been better to say:

The inputs are integers represented in 4-bit 2's complement. The output is 8 bit 2-complement.

And and or would hopefully give you a 8 bit result with 0000 as the high bits.

XOR is a weird operation with 4 bit signed numbers in and 8 bit out. You usually expect the bit length to be the same. I doesn't fit the mold well.
I'd be tempted to sign extend negative numbers.

Think of -1 XOR -1 when both are 4 bit and both are 8 bit 2's complement.
That kinda has me confused as well, don't see why any first year EE course would be doing asymetric operations like that with 4 in 8 out. Be easier to just handle 8 in 8 out. I suppose personally I'd just take the positive complement and append some 0s in the 4 most significant bits before performing the xor but would certainly be more complex for a negative number without first converting then appending the bits. I'm hoping just lost in translation from Portuguese to English.
 

WBahn

Joined Mar 31, 2012
32,834
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.
Make a table of some of the possible inputs and outputs for both unsigned and two's complement representations and see if you notice anything interesting.
 

WBahn

Joined Mar 31, 2012
32,834
That kinda has me confused as well, don't see why any first year EE course would be doing asymetric operations like that with 4 in 8 out. Be easier to just handle 8 in 8 out. I suppose personally I'd just take the positive complement and append some 0s in the 4 most significant bits before performing the xor but would certainly be more complex for a negative number without first converting then appending the bits. I'm hoping just lost in translation from Portuguese to English.
One of the operations is multiplication, so it would make some sense to have 4-bit in and 8-bit out (though not the norm).
 

sc0tch

Joined Nov 6, 2018
64
One of the operations is multiplication, so it would make some sense to have 4-bit in and 8-bit out (though not the norm).
That is certainly understandable, for multiplication just doesn't seem so reasonable for an assignment in the first semester of an EE program without much explicit instruction as it doesn't seem by the questions asked here the material has been thoroughly covered or understood, but I could certainly be wrong! Then again my first assignment I remember of building an ALU we weren't allowed to use any ICs but And, Nand, Or, Nor, and Xor gates, so I suppose different strokes for different schools
 
Be easier to just handle 8 in 8 out.
e.g. 8 in sign extended to the 4-bit range, I think would make more sense.

e.g. Take 4 bits sigh extend it, take the next and sign extend it, then you have 8 bit numbers with something that makes sense.

I wonder if this is one of those

"Your not supposed t know that yet" answers.

It can seriously get a problem marked wrong if critical "later learned" info isn't taught. I told tech he was wrong and he agreed, but then both answers became correct ones. I hadn't learned what I knew in his class.

Can you measure the resistance of paper? Right answer is probably no. I could do it anytime with a system I set up at work. It varies with RH.

Does a single wire held in your hand generate electricity? The answer is yes. The "RIGHT ANSWER" is usually no. It's annoying when you have to deal with wires that wiggle and generate electricity.
 

sc0tch

Joined Nov 6, 2018
64
e.g. 8 in sign extended to the 4-bit range, I think would make more sense.

e.g. Take 4 bits sigh extend it, take the next and sign extend it, then you have 8 bit numbers with something that makes sense.

I wonder if this is one of those

"Your not supposed t know that yet" answers.

It can seriously get a problem marked wrong if critical "later learned" info isn't taught. I told tech he was wrong and he agreed, but then both answers became correct ones. I hadn't learned what I knew in his class.

Can you measure the resistance of paper? Right answer is probably no. I could do it anytime with a system I set up at work. It varies with RH.

Does a single wire held in your hand generate electricity? The answer is yes. The "RIGHT ANSWER" is usually no. It's annoying when you have to deal with wires that wiggle and generate electricity.
Touche,

I ran into this in my software engineering program of using functions not yet taught as I already knew C before taking the course and flunked the assignment even though the solution was better than the "correct" answer.

Guess that kinda makes helping on hohomework a bit more difficult as a perfect solution could still be the wrong answer. Some philosophical styff there
 
But it was WAY MORE FUN to get thrown out of class with the following:

"If you have anything better to do, don't bother coming to class. You have an "A".

I got an incomplete, that was rectified. I set up transcript to transfer on completion
and I had to wait for the next graduating class.
 

dl324

Joined Mar 30, 2015
18,326
The OP started out by asking for help on the wrong thing.

If you're implementing an adder, you'd probably do it with adders. If you're implementing an ALU, you'd probably implement add/subtract differently.
 

sc0tch

Joined Nov 6, 2018
64
The OP started out by asking for help on the wrong thing.

If you're implementing an adder, you'd probably do it with adders. If you're implementing an ALU, you'd probably implement add/subtract differently.
But since it's in twos compliment add and subtract are the same operation, just adding the inverse of b
 
Top