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

Subversion Repositories yacc

[/] [yacc/] [trunk/] [syn/] [xilinx/] [alu_xilinx.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tak.sugawa
`include "define.h"
2
//Feb.25.2005 Verilog2001 Style
3
//Jan.20.2005 implict event list
4
//Jun.14.2004 Initial Version
5
//Jul.4.2004 sensibity list bug fix
6
//Jul.5.2004 less area version
7
 
8
module alu (input [31:0] a,b,
9
                     output reg [31:0] alu_out,
10
                     input [3:0] alu_func);
11
 
12
parameter   [3:0] ALU_NOTHING                       =4'b0000,
13
                              ALU_ADD                              =4'b0001,
14
                                ALU_SUBTRACT               =4'b0010,
15
                              ALU_LESS_THAN_UNSIGNED =4'b0101, //Jul.5.2004
16
                                ALU_LESS_THAN_SIGNED     =4'b0100, //Jul.5.2004
17
                                ALU_OR                                     =4'b0011,
18
                              ALU_AND                              =4'b0110,
19
                                ALU_XOR                                    =4'b0111,
20
                                ALU_NOR                                    =4'b1000;
21
 
22
        reg [32:0] sum;
23
 
24
        always @* begin //
25
                case (alu_func)
26
                        ALU_NOTHING    : alu_out=32'h0000;
27
                        ALU_ADD        : alu_out=a+b;
28
                        ALU_SUBTRACT   : alu_out=a+~b+1'b1;//a-b;
29
                        ALU_OR         : alu_out=a | b;
30
                        ALU_AND        : alu_out=a & b;
31
                        ALU_XOR        : alu_out=a ^ b;
32
                        ALU_NOR        : alu_out=~(a | b);
33
                        ALU_LESS_THAN_UNSIGNED : alu_out=a < b;//Jun.29.2004
34
                        ALU_LESS_THAN_SIGNED: begin
35
                                                 sum={a[31],a}+~{b[31],b}+1'b1;//a-b                                                                      $signed(a) > $signed(b);
36
                                                 alu_out={31'h0000_0000,sum[32]};
37
                                               end
38
                        default : alu_out=32'h0000_0000;
39
 
40
 
41
                endcase
42
        end
43
endmodule
44
 
45
 
46
 

powered by: WebSVN 2.1.0

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