Designing a 4-bit ALU: Functions & Solutions for a Microprocessor

In summary, the ALU has the following functions: add, subtract, shift-left, shift-right, and transfer.
  • #1
Random89
9
0

Homework Statement


A 4-bit arithmetic and logic unit (ALU) is to be designed for a 4-bit microprocessor.
The ALU has two 4-bit wide inputs, labelled ii and i2 and a 4-bit output labelled
out. In addition there is a carry-out bit. Design the ALU so that it implements the
following functions:
• add: out = i1 + i2
• subtract: out = i1 − i2
• shift-left: out = i1 shifted-left by 1-bit
• shift-right: out = i1 shifted-right by 1-bit
• transfer: out = i1


Homework Equations





The Attempt at a Solution


This was a question from a uni Tutorial sheet (not assessed, but relevant to assignments later on) which I got really stuck on. I have no idea how to even start it. Has anyone got any hints for how to get started so I can at least have an idea what I am dealing with as the lecture notes aren't great and the course texts make as much sense as if they were in Spanish. I understand logic gates, truth tables and that lot it is just fitting that into this question is doing me in.
Any help would be great (but please don't just post the solution, I want to work this out).
 
Physics news on Phys.org
  • #2
Has anyone got any idea? This is getting urgent now as the Assignment will be posted some time this week and I want to know what to do before it is posted.
Thanks
 
  • #3
Are you familiar with shift registers?
 
  • #4
I am familiar with Flip-flops and after looking up shift registers it seems to lead on as they are made from a series of flip-flops.
 
  • #5
Yea, a shift register is composed of a series of flip flops. Two primary functions of a shift register is to temporarily store a word, in your case it would be 4 bits, the second function is to shift the bits. More complex shift registers can shift the bits to the left or right.

This is basically half of your ALU.
 
  • #6
Ah okay, I get the idea. I have searched through the lecture notes and found something that might be the same idea. Now to learn how to use it in Quantus. Thanks for the help, going to spend about 7 hours in a lab tomorrow getting it working.
 
  • #7
Sorry to do this but I have got stuck again.
Firstly for some reason my Subtraction circuit is bringing up errors (I am using Quartus) for no reason (picture below).
Secondly I have built the circuit but I have no idea where to go from here, how to turn it into what is below into a full ALU. Anyone got any good tutorials for Quartus on how to do this? (first time using Quartus for me).
Lastly I need to use flags (or Status Bits) for Zero, Overflow and Negative. Can anyone understand this as I couldn't find it in the lecture notes?

Thanks for all the help so far. Everything I have so far is below, I have it in Quartus file type as well if anyone wants to have a closer look (let me know).

Oh and also we are only meant to use primative Logic gates, that is why I didn't use a Shift Register.
Adding:
halfadder.jpg

Transfer:
Transfer.jpg

Subtraction (doesn't work):
Sub.jpg

Right Shift (1 place):
Rshift.jpg

Left Shift (1 place):
Lshift.jpg

Full ALU:
ALU.jpg
 
  • #8
Subtracting works by adding a complement of one operand to another. That means you need to put an inverter at one of the inputs of the adder.

As far as shifting bits, are you allowed to use flip-flop?
 
  • #9
Nope, only basic logic gates like AND, OR, NOT, XOR etc.
 
  • #10
Hello...i have some question to ask...i am interested in designing a 4 bits ALU that can perform calculations.Is there any info that can help to built up some knowledge abt ALU? Thanks...
 

Related to Designing a 4-bit ALU: Functions & Solutions for a Microprocessor

1. What is an ALU?

An ALU, or Arithmetic Logic Unit, is a digital circuit that performs mathematical and logical operations on data. It is an essential component of a computer's central processing unit (CPU) and is responsible for performing calculations and making decisions based on input data.

2. Why is it important to design a 4 bit ALU?

A 4 bit ALU is important because it can perform operations on 4 bits of data, which is the basic unit of information in a computer. This allows for faster processing and more efficient use of resources compared to a larger bit ALU. Additionally, many simple computer systems only require a 4 bit ALU, making it a cost-effective and practical choice for certain applications.

3. What operations can a 4 bit ALU perform?

A 4 bit ALU can perform basic arithmetic operations such as addition, subtraction, and comparison (greater than or less than). It can also perform logical operations such as AND, OR, and NOT. Some 4 bit ALUs may also have the capability to perform more complex operations such as shifting and rotating bits.

4. How is a 4 bit ALU designed?

A 4 bit ALU is typically designed using digital logic gates, such as AND, OR, and XOR gates, along with other components such as multiplexers and registers. The design process involves breaking down the desired operations into smaller logical steps and then implementing those steps using the appropriate logic gates and components. The overall goal is to create a circuit that can accurately and efficiently perform the required operations on 4 bits of data.

5. What are some considerations when designing a 4 bit ALU?

There are several considerations when designing a 4 bit ALU, such as the speed and efficiency of the circuit, the number of operations it can perform, and the complexity of the design. Another important consideration is the use of testbenches and simulations to ensure the ALU functions properly and meets all design requirements. Additionally, the selection of appropriate components and the overall cost of the design should also be considered.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Introductory Physics Homework Help
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top