Operation | Operation code |
---|---|
The addition (ADD) | 0000 |
The subtraction (SUB) | 0001 |
Inclement (INC) | 0010 |
Decrement (DEC) | 0011 |
Bitwise logical OR (OR) | 0100 |
Bitwise logical exclusive OR (EOR) | 0101 |
Bitwise logical AND (AND) | 0110 |
Bitwise logical NOT (NOT) | 0111 |
Logical left shift (LSL) | 1000 |
Arithmetic left shift (ASL) | 1001 |
Logical right shift (LSR) | 1010 |
Arithmetic right shift (ASR) | 1011 |
Anticlockwise-rotation (ROL) | 1100 |
Clockwise-rotation (ROR) | 1101 |
Pass through (PAS) | 1110 |
Byte SWAP (SWP) | 1111 |
The control code for ALU is described by "`define"by. By this definition, it is possible to refer a operation label instead of 0 and 1 bit pattern in the source code.
'define IADD 4'b0000 'define ISUB 4'b0001 'define IINC 4'b0010 'define IDEC 4'b0011 'define IOR 4'b0100 'define IEOR 4'b0101 'define IAND 4'b0110 'define INOT 4'b0111 'define ILSL 4'b1000 'define IASL 4'b1001 'define ILSR 4'b1010 'define IASR 4'b1011 'define IROL 4'b1100 'define IROR 4'b1101 'define IPAS 4'b1110 'define ISWP 4'b1111It is described beforehand to refer to the "alu_op.v" file from the "alu.v" file.
`include "alu_op.v" module alu (A, B, CB, Y, F) ; ... ... ... ... ... endmodule
Next, description of calculation.