# Arithmetic and Logic Calculator

Discussion in 'Homework Help' started by JekasG, Sep 21, 2014.

1. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
Build an arithmetic and logic calculator that has:
1) Four input bits of data, stored in a single-bit register (D-type latch)
2) One carry-in bit, stored in a register (D-type latch)
3) Six instruction bits, each stored in a register (D-type latch).
a. The first and second bits of the instruction (B1 and B2) specify the
operation to be performed.
- 00 is a NOR operation
- 01 is a AND operation
- 10 is an NAND operation
- 11 is an ADD operation
b. The third and fourth bits of the instruction (B3 and B4) specify one
input data register which will be used in your calculation.
- Register 0 is addressed as 00
- Register 1 is addressed as 01
- Register 2 is addressed as 10
- Register 3 is addressed as 11.
c. The fifth and sixth bits of the instruction (B5 and B6) specify the
second input data register which will be used in your calculation.
- Register 0 is addressed as 00
- Register 1 is addressed as 01
- Register 2 is addressed as 10
- Register 3 is addressed as 11.
4) Each operator will perform a calculation on the input data from the registers
identified by bits B3, B4, B5 and B6.
5) ADD operations will also use the carry-in register.
6) If you perform a logical operation (NOR, AND or NAND), the output should
be stored in an output register (D-type latch).
7) If you perform an ADD, you should store the trailing bit in the output register,
and the leading bit in a carry-out register (D-type latch).

I have problems understand this problem i have to solve.
So i am to make a four single-bit register, but i don't know what i have to do for it.
I also have to make a six instruction bit, each stored in a register.
So how does B3 + B4 and B5 + B6 relate to the input bits ?
How am i supposed to make this curcuit

2. ### MrChips Moderator

Oct 2, 2009
12,635
3,454
I have moved your thread from The Project Forum to Homework Help.

The instructions seem very clear to me.
What exactly do you not understand?

Last edited: Sep 21, 2014
3. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
What do i do with the four inputs ?

How doesn't the four input relate to the six instruction bits ?

How do i perform the calculation ?

Can you please provide a outline as how i would have to approach this problem ?

4. ### MrChips Moderator

Oct 2, 2009
12,635
3,454
What you are asked to design is a classic ALU, Arithmetic-Logic Unit. The four inputs are your data bits. These go to the inputs of the ALU.
The four inputs have nothing to do with the 6-bit instruction.
Four of the six bits only select which inputs are routed to the calculation engine.

That is for you to design. I cannot do your homework for you.

Again, you have to show us your ideas first otherwise you're not learning to think for yourself.

Begin by asking and stating what is the big picture?
Then see if you can find the functions in the big picture.
What functional blocks would be required to make up the picture?
For the moment, ignore parts, gates, ICs, components etc.
This is called "Top-Down Design".

Last edited: Sep 21, 2014
5. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
Yes of course .
So this is what i have thought for the assignment.

Does the four inputs represent as a binary number system ?
8 4 2 1
1 0 1 1
But if i think this way , how does it relate to the six instruction bit ?

I also thought of having the four input bits to be exactly as B3 B4 B5 B5.
This is compulsory because it of the registers value.
But i don't see the point of doing this because since both the input and B3 B4 B5 B6 are needed.

I just don't get why the four input bit is required.
Is what determines what is added B3 B4 B5 B6 ?
Or is it by the four inputs ?
But how ?

6. ### MrChips Moderator

Oct 2, 2009
12,635
3,454
B3 B4 B5 B6 are not your data bits.
They select where the data bits are coming from. They specify the container. You don't know what is in the container.
Go by the specifications given in your instructions.

Here is the rationale for such a design. You will create a computer instruction that looks something like this:

You do not know what values are held in registers R1 and R2.

The instruction is not

Last edited: Sep 21, 2014
7. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
I don't get what you mean by ,

" They select where the data bits are coming from. "

Can you be more specific ? I really don't get the question .
I don't understand what its trying to ask. So i can't see an opening to approach the question.

Oct 2, 2009
12,635
3,454

9. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
If you have an input of
1 0 1 1
How is B2 B4 B5 B6 defined ?
Or do i just put a random value
Maybe Register 1 for B3 and B4 and Register 0 for B5 and B6
So what does this mean ?
Do i have a perform an add value of each of the input value ?
So would i mean , 1 + 0 + 1 + 1 = 3 ?
In this case how can i show it in the output result with a carry ? And is the output in binary ?
I only know there are two outputs so the output is 1 and carry is 2. So end result would be 3 with both output and carry as 1.
But if this is the way to solve the question.
I haven't used B3 B4 B5 B6.

Sorry. I just so clueless.
Is the question this hard to understand ?

10. ### MrChips Moderator

Oct 2, 2009
12,635
3,454
The question is not that difficult.
You cannot see the forest but the leaves.
You fall into the trap of attempting to use a bottom-up approach.
Draw a block diagram like I asked you.

One does not ADD 1 and 2, because you know the answer is 3.

You are going to ADD the contents of two registers. Ignore the contents of the registers.

Data and results are always in binary. As an example only,
the sum of 10 and 11 is
01 with carry = 1.

I present this only as an example but don't focus on this.

Get the big picture first.

11. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
So what you are saying , the four inputs contains two numbers.
If the input is 0010 then the two numbers are 00 and 10 , right ?
And so in this case, it would be 00 + 10 and the output would be 10 without a carry.
Is this what you mean ?
But this still doesn't make sense.

Sorry i really don't understand the big picture. No one explain it to me in detail.

Apr 5, 2008
15,802
2,388
13. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
Hi Bertus ,

Ive looked through the other ALU Adders , they are just the simple ones which have two inputs , an output and a carry output.
But in my situation its different. I have six instruction bit , four input bits, carry in , carry out, and an output.
I don't even know what B1 and B2 is operated on. Is it the four input bit or B3 B4 B5 B5 ?
No matter which either one is used the other will be left out unused. Well at least, to my knowledge i think its unused.

Apr 5, 2008
15,802
2,388
Hello,

The B1 and B2 are for selecting the operation to perform.
The B3 abd B4 are for selecting the first register where one value is stored.
The B5 and B6 are for selecting the second register where the other value is stored.

Bertus

15. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
And after storing the value of B3 B4 B5 B6 what do you do with it ?

16. ### MrChips Moderator

Oct 2, 2009
12,635
3,454
You don't store the values of B3 B4 B5 B6. You don't do anything with them.
These are not values. They are like your house number. They are addresses. It says so in post #1.

Your assignment is a straight forward one and is fully explained in the instructions given to you.

You are not going to get any more help from me until you show a functional block diagram.

17. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,501
512
You have 2 registers.

Register 1 is Data register, this register is 4 bits long: D4, D3, D2, D1.

Register 2 is Control register, it is 6 bits long: B6, B5, B4, B3, B2, B1.

Data register contains data that you want to manipulate.

Control register tells you two things:
1) What operation to perform.
- 00 is a NOR operation
- 01 is a AND operation
- 10 is an NAND operation
- 11 is an ADD operation
2) Which cells of Data register to use as inputs to the operation.

Example.
I want decimal 9 to be my data. What is decimal 9 in binary, it is 1001. What is my Data register going to contain?
D4 is 1
D3 is 0
D2 is 0
D1 is 1
So
D4D3D2D1
1001
Now. What do I want to do with the data stored in my Data register? I want to AND two bits. What is the code/address for AND? The code for AND is binary 10 in cells B2 and B1, so B2 will contain 1, B1 will contain 0. What does control register looks like so far?
B6B5B4B3B2B1
xxxx10
Which cells of Data register do I want to AND? I want to AND cells D1 and D2. What is the code/address for cell D1? The code/address for cell D1 is binary 00. Where do I store this code/address? I store it in cells B4 and B3 of Control register. What does my Control register look like now?
B6B5B4B3B2B1
xx0010
What is code/address for cell D2? It is binary 01. I store this code/address in cells B6 and B5. What does my Control register looks like now?
B6B5B4B3B2B1
010010
So
Data register: 1001
Control register: 010010
Together they tell us: Take 1 from Data register D1 AND it to 0 from Data register D2.

18. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
Hi shteii01 ,

Thanks for you example that you gave me.
But i have some question.

From what i can see, what you did is enter values in the four inputs.
Inputs :
D4D3D2D1
1001
And from B3B4B5B6 you determined from which D4D3D2D1 to perform the B2B1 operator on.
So in this case, you made B3B4 to Register 0 which is 00.
And you made B5B6 to Register 1 which is 01.

So what you're trying to say is depending on which Register.
The register will select which input is used.
So in this case Register 0 and Register 1 perform AND operator , which means.

0 & 1 and the result would be 0

If in another case.
Input:
D4D3D2D1
1011
B2B1
B4B3
Register 2 - 10
B6B5
Register 3 - 11
Result
0 + 1 = 1
No carry.

Is this what you're to get at ?
But when will i be using the carry ? Is what im saying is right ?

19. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,501
512
What I am getting at is that you, the user, decide what goes into Data Register (4 bits) and what goes into Control Register (6 bits).

The instructor put some constraints on you. Like your data will always be 4 bits, no matter what you want, no matter what you need, your data ALWAYS will be 4 bits. Your other constraint is the control, you have two bits to select the operation, two bits to select first input, two bits to select second input, and you can only select one bit for each input, that is IT.

20. ### JekasG Thread Starter New Member

Sep 21, 2014
10
0
But how do you make it to work ?
Is what i wrote earlier a working example ?
Like , is that what the question is asking for it to do ?