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

Subversion Repositories fluid_core_2

[/] [fluid_core_2/] [trunk/] [xilinx14.5 project/] [int_ALU.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 azmathmoos
`timescale 1ns / 1ps
2
`include "Configuration.v"
3
 
4
module int_ALU(
5
        input [0:`mod_sel_msb] Module,
6
        input [0:`operation_msb] Operation,
7
        input [0:`dpw] OP1,
8
        input [0:`dpw] OP2,
9
        output [0:`dpw] Result,
10
        output [0:3] Flag,
11
        input [0:3] prev_Flag
12
    );
13
 
14
        wire en;
15
        assign en = (Module==`int_ALU);
16
 
17
        wire [0:`dpw] OP1_;
18
        assign OP1_ = (~OP1 + `dpw'b01);
19
 
20
        reg [0:`dpw] result_buff;
21
        reg C,Z,S,O;
22
         //----[C|Z|S|O]------// 
23
 
24
        initial begin
25
                {C,Z,S,O} = {0,0,0,0};
26
                result_buff = 0;
27
        end
28
        always@(*) begin
29
 
30
                if (en) begin
31
                        case (Operation)
32
                        `ADD: {C,result_buff} <= OP1 + OP2;
33
                        `SUB: {C,result_buff} <= OP2 + OP1_;
34
                        `ADC: {C,result_buff} <= OP1 + OP2 + prev_Flag[0];
35
                        `SBC: {C,result_buff} <= OP2 + OP1_ + prev_Flag[0];
36
                        `AND: result_buff <= OP1 & OP2;
37
                        `OR:    result_buff <= OP1 | OP2;
38
                        `XOR: result_buff <= OP1 ^ OP2;
39
                        endcase
40
 
41
                        S <= result_buff[0];
42
                        O <= OP1_[0]^OP2[0]^result_buff[0]^C;
43
                        Z <= result_buff == 0;
44
 
45
                end
46
        end
47
 
48
        assign Result = en ? result_buff : 'bz;
49
        assign Flag = {C,Z,S,O};
50
endmodule

powered by: WebSVN 2.1.0

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