OpenCores
URL https://opencores.org/ocsvn/mips_16/mips_16/trunk

Subversion Repositories mips_16

[/] [mips_16/] [trunk/] [rtl/] [alu.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 Doyya
/***************************************************
2
 * Module: alu
3
 * Project: mips_16
4
 * Author: fzy
5
 * Description:
6
 *     alu implementation
7
 *
8
 * Revise history:
9
 *
10
 ***************************************************/
11
`timescale 1ns/1ps
12
`include "mips_16_defs.v"
13
module alu
14
(
15
        input           [15:0]   a,              //src1
16
        input           [15:0]   b,              //src2
17
        input           [2:0]    cmd,    //function sel
18
 
19
        output  reg     [15:0]   r               //result        
20
);
21
        always @ (*) begin
22
                case(cmd)
23
                        `ALU_NC :
24
                                r = 16'bx;
25
                        `ALU_ADD:
26
                                r = a + b;
27
                        `ALU_SUB:
28
                                r = a - b;
29
                        `ALU_AND:
30
                                r = a & b;
31
                        `ALU_OR :
32
                                r = a | b;
33
                        `ALU_XOR:
34
                                r = a ^ b;
35
                        `ALU_SL :
36
                                r = a << b;
37
                        `ALU_SR :
38
                                r = {{16{a[15]}},a} >> b;
39
                        `ALU_SRU        :
40
                                r = {16'b0,a} >> b;
41
                        default :
42
                                begin
43
                                        r = 0;
44
`ifndef CODE_FOR_SYNTHESIS
45
                                        $display("ERROR: Unknown alu cmd: %b \n", cmd);
46
                                        //$stop;
47
`endif
48
                                end
49
                endcase
50
        end
51
 
52
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.