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

Click For Summary

Discussion Overview

The discussion revolves around the design of a 4-bit arithmetic and logic unit (ALU) for a microprocessor, focusing on its functions, implementation challenges, and the use of specific components like logic gates and flip-flops. Participants seek guidance on how to approach the design, troubleshoot issues, and understand the underlying concepts.

Discussion Character

  • Homework-related
  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant expresses confusion about starting the design of the ALU and requests hints without a full solution.
  • Another participant inquires about the urgency of the assignment and seeks preliminary guidance.
  • Shift registers are mentioned as relevant components, with a participant noting their relationship to flip-flops.
  • It is discussed that shift registers can temporarily store bits and shift them, which is seen as a significant part of the ALU design.
  • A participant reports issues with their subtraction circuit in Quartus and seeks advice on how to proceed with building a full ALU.
  • Flags or status bits for Zero, Overflow, and Negative are mentioned as necessary components, with a participant struggling to find relevant information in lecture notes.
  • One participant suggests that subtraction can be achieved by adding the complement of one operand, indicating the need for an inverter in the adder circuit.
  • Another participant clarifies that only basic logic gates are permitted for the design, excluding the use of flip-flops.
  • A new participant expresses interest in designing a 4-bit ALU and asks for resources to build foundational knowledge on the topic.

Areas of Agreement / Disagreement

Participants generally share a common goal of designing the ALU but express varying levels of understanding and face different challenges. There is no consensus on specific solutions or approaches, and multiple viewpoints on the use of components and design strategies are present.

Contextual Notes

Participants mention limitations in their understanding due to unclear lecture notes and the complexity of using Quartus software for circuit design. There are also references to specific requirements, such as the restriction to primitive logic gates.

Who May Find This Useful

This discussion may be useful for students and individuals interested in digital circuit design, particularly those working on assignments related to ALUs and microprocessor architecture.

Random89
Messages
9
Reaction score
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
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
 
Are you familiar with shift registers?
 
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.
 
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.
 
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.
 
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
 
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?
 
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...
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
4K
Replies
1
Views
4K
  • · Replies 9 ·
Replies
9
Views
6K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
5
Views
8K
  • · Replies 15 ·
Replies
15
Views
4K