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 |
4 |
mcupro |
//// Description: For simulations only to calculate the CPI ////
|
46 |
|
|
//// Cycles Per Instruction ////
|
47 |
2 |
mcupro |
//// ////
|
48 |
|
|
/////////////////////////////////////////////////////////////////////
|
49 |
|
|
//// ////
|
50 |
|
|
//// Change log: ////
|
51 |
|
|
//// ////
|
52 |
|
|
/////////////////////////////////////////////////////////////////////
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
module cal_cpi (
|
57 |
|
|
input clk,
|
58 |
|
|
input rst,
|
59 |
|
|
input is_nop,
|
60 |
|
|
output reg [100:0] ins_no,
|
61 |
|
|
output reg [100:0] clk_no);
|
62 |
|
|
|
63 |
|
|
always @(posedge clk or negedge rst )
|
64 |
|
|
if (~rst )clk_no=0;
|
65 |
|
|
else
|
66 |
|
|
clk_no = 1+clk_no;
|
67 |
|
|
|
68 |
|
|
always @(posedge clk or negedge rst)
|
69 |
|
|
if (~rst )ins_no=0;
|
70 |
|
|
else if (~is_nop)
|
71 |
|
|
ins_no = 1+ins_no;
|
72 |
|
|
endmodule
|