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

AI Thread Summary
A 4-bit ALU is being designed for a microprocessor to perform functions like addition, subtraction, and bit shifting with two 4-bit inputs and a carry-out bit. Participants are seeking guidance on starting the design, particularly in using Quartus software, as they struggle with implementing subtraction and understanding status flags such as Zero, Overflow, and Negative. The discussion emphasizes the need to use only primitive logic gates, avoiding more complex components like shift registers. Users are sharing insights on how to approach the design and troubleshoot issues encountered in their circuits. Overall, the thread highlights the challenges of learning ALU design and the collaborative effort to find solutions.
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...
 
Back
Top