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

Subversion Repositories hive

[/] [hive/] [trunk/] [v01.09/] [cond_test.v] - Blame information for rev 4

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

Line No. Rev Author Line
1 2 ericw
/*
2
--------------------------------------------------------------------------------
3
 
4
Module : cond_test.v
5
 
6
--------------------------------------------------------------------------------
7
 
8
Function:
9
- Processor tests for conditional jumps, etc.
10
 
11
Instantiates:
12
- (2x) vector_sr.v
13
 
14
Notes:
15
- Parameterized register(s) test inputs.
16
- Parameterized register(s) @ output.
17
 
18
--------------------------------------------------------------------------------
19
*/
20
 
21
module cond_test
22
        #(
23
        parameter       integer                                                 REGS_TST                        = 0,             // reg option input to test
24
        parameter       integer                                                 REGS_OUT                        = 0              // reg option test to output
25
        )
26
        (
27
        // clocks & resets
28
        input                   wire                                                            clk_i,                                          // clock
29
        input                   wire                                                            rst_i,                                          // async. reset, active high
30
        // flags (combinatorial)
31
        input                   wire                                                            nez_i,                                          //      a != 0
32
        input                   wire                                                            ne_i,                                                   //      a != b
33
        input                   wire                                                            ltz_i,                                          //      a < 0
34
        input                   wire                                                            lt_i,                                                   //      a < b
35
        // tests (optionally registered)
36
        input                   wire                                                            tst_gt_i,                                       // > test
37
        input                   wire                                                            tst_lt_i,                                       // < test
38
        input                   wire                                                            tst_eq_i,                                       // = test
39
        input                   wire                                                            tst_ab_i,                                       // 1=a/b test; 0=a/z test
40
        // output (optionally registered)
41
        output          wire                                                            tst_o                                                   // 1=true; 0=false
42
        );
43
 
44
 
45
        /*
46
        ----------------------
47
        -- internal signals --
48
        ----------------------
49
        */
50
        wire                                                                                            tst_ab, tst_gt, tst_lt, tst_eq;
51
        wire                                                                                            eqz, gtz;
52
        wire                                                                                            eq, gt;
53
        wire                                    [2:0]                                            t_cat, az_cat, ab_cat;
54
        wire                                                                                            res_az, res_ab, tst;
55
 
56
 
57
 
58
        /*
59
        ================
60
        == code start ==
61
        ================
62
        */
63
 
64
 
65
        // input to test regs
66
        vector_sr
67
        #(
68
        .REGS                   ( REGS_TST ),
69
        .DATA_W         ( 4 ),
70
        .RESET_VAL      ( 0 )
71
        )
72
        tst_regs
73
        (
74
        .clk_i          ( clk_i ),
75
        .rst_i          ( rst_i ),
76
        .data_i         ( { tst_ab_i, tst_gt_i, tst_lt_i, tst_eq_i } ),
77
        .data_o         ( { tst_ab,   tst_gt,   tst_lt,   tst_eq } )
78
        );
79
 
80
 
81
        // concat tests
82
        assign t_cat = { tst_gt, tst_lt, tst_eq };
83
 
84
        // decode conditionals, & mask, | bit reduction => results
85
        assign eqz = ~nez_i;
86
        assign gtz = ~( ltz_i | eqz );
87
        assign az_cat = { gtz, ltz_i, eqz };
88
        assign res_az = |( t_cat & az_cat );
89
        //
90
        assign eq = ~ne_i;
91
        assign gt = ~( lt_i | eq );
92
        assign ab_cat = { gt, lt_i, eq };
93
        assign res_ab = |( t_cat & ab_cat );
94
 
95
        // select result
96
        assign tst = ( tst_ab ) ? res_ab : res_az;
97
 
98
 
99
        // result to output regs
100
        vector_sr
101
        #(
102
        .REGS                   ( REGS_OUT ),
103
        .DATA_W         ( 1 ),
104
        .RESET_VAL      ( 0 )
105
        )
106
        out_regs
107
        (
108
        .clk_i          ( clk_i ),
109
        .rst_i          ( rst_i ),
110
        .data_i         ( tst ),
111
        .data_o         ( tst_o )
112
        );
113
 
114
 
115
endmodule

powered by: WebSVN 2.1.0

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