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

Subversion Repositories microriscii

[/] [microriscii/] [trunk/] [verilog/] [rtl/] [ex.v] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 alikat
//--------------------------------------------------------------------------------------------------
2
//
3
// Title       : ex
4
// Design      : MicroRISCII
5
// Author      : Ali Mashtizadeh
6
//
7
//-------------------------------------------------------------------------------------------------
8
`timescale 1ps / 1ps
9
 
10
module ex(a,b,ex_op,ex_mux,clk,carryin,ex_flush,ex_halt,o,t_out);
11
        // Inputs
12
        input   [31:0]   a;
13
        wire    [31:0]   a;
14
        input   [31:0]   b;
15
        wire    [31:0]   b;
16
        input   [3:0]    ex_op;
17
        wire    [3:0]    ex_op;
18
        input   [1:0]    ex_mux;
19
        wire    [1:0]    ex_mux;
20
        input                   clk;
21
        wire                    clk;
22
        input                   carryin;
23
        wire                    carryin;
24
        input                   ex_flush;
25
        wire                    ex_flush;
26
        input                   ex_halt;
27
        wire                    ex_halt;
28
        // Outputs
29
        output  [31:0]   o;
30
        reg             [31:0]   o;
31
        output                  t_out;
32
        reg                             t_out;
33
        // Internal
34
        wire    [31:0]   au_o;
35
        wire    [31:0]   lu_o;
36
        wire                    testresult;
37
        wire                    carryout;
38
        wire                    testout;
39
        wire                    rndau;
40
        reg                             CARRYSTATE;
41
 
42
        au arith_unit(
43
                .a(a),
44
                .b(b),
45
                .arith_op(ex_op),
46
                .carry(carryout),
47
                .o(au_o),
48
                .rndin(rndau)
49
        );
50
 
51
        lu logic_unit(
52
                .a(a),
53
                .b(b),
54
                .logic_op(ex_op),
55
                .o(lu_o)
56
        );
57
 
58
        cmp compare_unit(
59
                .a(a),
60
                .b(b),
61
                .cmp_op(ex_op),
62
                .true(testout),
63
                .c(CARRYSTATE)
64
        );
65
 
66
        always @ (posedge clk || ex_flush || ex_halt || a || b || testout || carryout)
67
                if (ex_halt == 1'b0)
68
                        if (ex_flush == 1'b0)
69
                                begin
70
                                        case (ex_mux)
71
                                                2'b00 : o = au_o;
72
                                                2'b01 : o = lu_o;
73
                                                2'b10 : o = a;
74
                                                2'b11 : o = b;
75
                                        endcase
76
                                        t_out = testout;
77
                                        if (ex_mux == 2'b0)
78
                                                CARRYSTATE = carryout;
79
                                end
80
                        else
81
                                begin
82
                                        o = 32'b0;
83
                                        CARRYSTATE = carryin;
84
                                end
85
 
86
endmodule

powered by: WebSVN 2.1.0

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