1 |
2 |
mcupro |
/////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// Author: Liwei ////
|
3 |
|
|
//// ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// If you encountered any problem, please contact : ////
|
6 |
|
|
//// Email: mcupro@yahoo.com.hk or mcupro@opencores.org ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Downloaded from: ////
|
9 |
|
|
//// http://www.opencores.org/pdownloads.cgi/list/mips789 ////
|
10 |
|
|
/////////////////////////////////////////////////////////////////////
|
11 |
|
|
//// ////
|
12 |
|
|
//// Copyright (C) 2006-2007 Liwei ////
|
13 |
|
|
//// mcupro@yahoo.com.hk ////
|
14 |
|
|
//// ////
|
15 |
|
|
//// ////
|
16 |
|
|
//// This source file may be used and distributed freely without ////
|
17 |
|
|
//// restriction provided that this copyright statement is not ////
|
18 |
|
|
//// removed from the file and any derivative work contains the ////
|
19 |
|
|
//// original copyright notice and the associated disclaimer. ////
|
20 |
|
|
//// ////
|
21 |
|
|
//// Please let the author know if it is used ////
|
22 |
|
|
//// for commercial purpose. ////
|
23 |
|
|
//// ////
|
24 |
|
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
25 |
|
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
26 |
|
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
27 |
|
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
28 |
|
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
29 |
|
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
30 |
|
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
31 |
|
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
32 |
|
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
33 |
|
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
34 |
|
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
35 |
|
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
36 |
|
|
//// POSSIBILITY OF SUCH DAMAGE. ////
|
37 |
|
|
//// ////
|
38 |
|
|
/////////////////////////////////////////////////////////////////////
|
39 |
|
|
//// ////
|
40 |
|
|
//// ////
|
41 |
|
|
//// Date of Creation: 2007.8.1 ////
|
42 |
|
|
//// ////
|
43 |
|
|
//// Version: 0.0.1 ////
|
44 |
|
|
//// ////
|
45 |
|
|
//// Description: ////
|
46 |
|
|
//// ////
|
47 |
|
|
//// ////
|
48 |
|
|
/////////////////////////////////////////////////////////////////////
|
49 |
|
|
//// ////
|
50 |
|
|
//// Change log: ////
|
51 |
|
|
//// ////
|
52 |
|
|
/////////////////////////////////////////////////////////////////////
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
`define CMP_BEQ 1
|
56 |
|
|
`define CMP_BNE 2
|
57 |
|
|
`define CMP_BLEZ 3
|
58 |
|
|
`define CMP_BGEZ 4
|
59 |
|
|
`define CMP_BGTZ 5
|
60 |
|
|
`define CMP_BLTZ 6
|
61 |
|
|
`define CMP_NOP 0
|
62 |
|
|
|
63 |
|
|
module compare (
|
64 |
|
|
input [31:0] s,
|
65 |
|
|
input [31:0] t,
|
66 |
|
|
input [2:0]ctl,
|
67 |
|
|
output reg res
|
68 |
|
|
);
|
69 |
|
|
reg [32:0]sum;
|
70 |
|
|
always @ (*)
|
71 |
|
|
case (ctl)
|
72 |
|
|
`CMP_BEQ: res = s==t;
|
73 |
|
|
`CMP_BNE: res = s!=t;
|
74 |
|
|
`CMP_BLTZ: res = s[31];
|
75 |
|
|
`CMP_BGTZ: res = ~s[31] && (|s[30:0]);
|
76 |
|
|
`CMP_BLEZ: res = s[31] |(~|s);
|
77 |
|
|
`CMP_BGEZ: res = ~s[31];
|
78 |
|
|
default res=1'B0;
|
79 |
|
|
endcase
|
80 |
|
|
endmodule
|