159.236 Embedded Programming Assignment 1
Due date 22nd August 2022
Design a basic Arithmetic/Logic Unit (ALU) that operates on two 2-bit binary numbers a and b and generates a third 2-bit number s.
The function of the ALU is determined by a 3-bit binary code f:
f2f1f0 | Name | Function |
000 XOR Logical Exclusive OR of a and b | ||
001 | AND | Logical AND of a and b |
010 | ADD | Add a to b (ignore cin) |
011 | ADC | Add a to b and include cin |
100 | SUB | Subtract b from a (ignore cin) |
101 | SBC | Subtract (b + cin) from a |
110 | RSB | Subtract a from b (ignore cin) |
111 | RSC | Subtract (a + cin) from b |
a0 is the least significant bit of a, a1 is the most significant bit. For operations which do not use the carry input, it should be ignored. For operations which do not generate a carry (XOR,AND), the carry output should be zero. If a carry occurs as a result of an addition, or a borrow occurs as a result of a subtraction, then cout should be 1.
Starting with the file alu2022.lgf (available on stream) add your design and test it using the switches labelled: a0, a1, b0, b1, f0, f1, f2 and cin and the lights labelled s0, s1 and cout. Do NOT change or add anything inside the box in alu2022.lgf or use the “test” connection; if you do, you WILL lose marks. You may only use basic gates (AND,OR,NOT,XOR,NOR,NAND) with any number of inputs. You must use the connections from the alu2022.lgf file. To do this, use the 'to' or 'from' devices in the catalogue. These allow you to make connections without drawing wires, simply click to assign a name to a connection and it will be connected to all other 'to' or 'from' devices with the same name. Your connections must be called a0,a1,b0,b1,cin,f0,f1,f2,cout,s0 and s1 so that they will connect to the test circuit. Do not add any switches to your design, you must be able to test your design by changing the switches on the left inside the box. Make sure the blue bars at the bottom of the log screen are not red before you submit your assignment. Check that your f inputs are the correct way round, i.e. f0 is 1 for AND.
This assignment is worth 20% of the final marks
Your assignment will be judged on accuracy and neatness. Submit your alu.lgf file electronically from stream.
Make sure your name and id are displayed in your design.
This is an individual assignment, marks will be deducted if your submission is similar to others. Note that this is not exactly the same assignment as in 2021