Skip to content

zackteo/16-bit-ALU-mojo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

16-bit Arithmetic Logic Unit (ALU)

2-input 16-bit ALU using the Lucid programming language for the Mojo V3 FPGA (Field-programmable gate array) development board (Spartan 6).

Done by:

  • Zachary Teo
  • Amanda Kosim
  • Wong Wei En Matthew
  • Chow Jia Yi

Functionality

Standard ALU operations

Arithmetic (+, -)

  • Zero, Z
    • indicating all bits of S are logic zero
  • Negative, N
    • indicating the result is a negative
  • Overflow, V
    • indicating the result has exceeded the numeric range of S

Bitwise logical (AND, NAND, OR, NOR, XOR, “A”, “B”)

Bit Shift (SL, SR, SLA, SRA)

Comparison (==, <, <=)

Multiply (/*)

Additional Functionality

  • Automated testing
    • The program uses a Finite State Machine (FSM) to iterate throught a series of test cases for the various operations our ALU is capable of performing. Flow is shown below

./Flow.png

Table of functions

ALUFN [5:4]ALUFN[3:0]Short-formOperation
000000ADDAddition (+)
0001SUBSubtraction (-)
0010MULMultiply (*)
011000ANDA & B
0111NAND~(A & B)
1110ORA or B
0001NOR~(A or B)
0110XORA ^ B
1010“A”(A)
0101“B”(B)
100000SHLShift Left (>>)
0001SHRShift Right (<<)
0011SHRAShift Right Arithmetically (<<<)
110011COMPEQEqual (==)
0101COMPLTLess than (<)
0111COMPLELess than or Equal (<=)

Implementation

The 16-bit is made of the modules below and implemented as its own ALU module, making it hierarchical and modular, for reusability. The ALU module is then implemented in mojo_top.luc

  • Adder module
    • part 1: adding/subtracting input A to/by input B
    • part 2: taking S to evaluate z,v,n
  • Boolean module
    • bitwise AND, NAND, OR, NOR, XOR, “A”, “B” for inputs A and B
  • Compare module
    • uses z,v,n from part 2 of adder to evaluate ==,<,<=
  • Shifter module
    • shift input A by input B (bits) for SHL, SHR, SHRA
  • Multiply module
    • get the lower 16 bits when input A is multiplied by input B