16-bit 2-input ALU using the Lucid programming language on the Mojo v3 FPGA development board (Spartan 6).
- Addtion/Subtraction
- Boolean (AND, OR, XOR)
- Shift Left/Right (with optional sign extension)
- Comparison (equal, less than, or both)
- Multiplication and Division
- Auto Testing
- Ability to check for overflow for the Adder module: if an error is detected, it will be displayed
- Ability to do
C1*INPUT_1 OP C2*INPUT_2
, whereC1
andC2
are constants, andOP
is the operation on the two operandsINPUT_1
andINPUT_2
.
The ALU/Mojo will have a series of four primary states
State | io_dip[2][7:6] |
Purpose/Function |
---|---|---|
1 | [0][1] |
Press io_button[1] -> store io_dip[1:0] into input_1 |
2 | [1][0] |
Press io_button[1] -> store io_dip[1:0] into input_2 |
3 | [1][1] |
Display result from ALU on io_led , depending on io_dip[2][5,0] as ALUFN |
4 | [0][0] |
Automated testing state (running test cases) |
io_button[1]
is the center button on the 5-button pad on the Mojo v3 IO Shieldio_dip[2][7:6]
are the two leftmost dip switches on the Mojo v3 IO Shield
dff1.d = dff1.q + input1
For every button press, if you press more than one time, you increment a constant C1
or C2
(see "Additional Functionality" above)
In the always loop:
Alu.input1 = dff1.q
Alu.input2 = dff2.q
dffAlu.d = dffAlu.q + Alu.output
This module uses a Finite State Machine (FSM) to iterate through a series of test cases for the variations operations the ALU should be capable of performing, testing some postive, negative, mixed and boundary cases.
case_add -> case_sub -> case_mult -> case_etc
if fail -> error_case
After 16 test cases pass -> pass_case; display GOOD
In diagram form:
- Hong Peng Fei
- Khong Jia Wei
- Faith See
- Timothy Liu