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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [lib/] [stat_counter.v] - Blame information for rev 11

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

Line No. Rev Author Line
1 11 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Tubo 8051 cores common library Module                       ////
4
////                                                              ////
5
////  This file is part of the Turbo 8051 cores project           ////
6
////  http://www.opencores.org/cores/turbo8051/                   ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Turbo 8051 definitions.                                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
 
44
// -----------------------------------------------------------------------
45
// Module Name      : stat_counter.v
46
// Company          : 
47
// Creation date    : 
48
// -----------------------------------------------------------------------
49
// Description      : This is the general purpose statistics counter. 
50
//                 
51
//                    
52
// References       : 
53
// ------------------------------------------------------------------------
54
 
55
//----------------- compiler directives -----------------------------------
56
 
57
// ------------------------------------------------------------------------
58
module stat_counter
59
  (
60
   // Clock and Reset Signals
61
   sys_clk,
62
   s_reset_n,
63
 
64
   count_trigger,
65
 
66
   reg_sel,
67
   reg_wr_data,
68
   reg_wr,
69
 
70
   cntr_intr,
71
   cntrout
72
 
73
 
74
   );
75
 
76
parameter CWD    = 1; // Counter Width
77
   //-------------------- Parameters -------------------------------------
78
 
79
   // ------------------- Clock and Reset Signals ------------------------
80
   input                     sys_clk;
81
   input                     s_reset_n;
82
   input                     count_trigger;
83
   input                     reg_sel;
84
   input                     reg_wr;
85
   input  [CWD-1:0]          reg_wr_data;
86
   output                    cntr_intr;
87
   output [CWD-1:0]          cntrout;
88
   // ------------------- Register Declarations --------------------------
89
   reg [CWD-1:0]             reg_trig_cntr;
90
 
91
 
92
// ------------------- Logic Starts Here ----------------------------------
93
 
94
 
95
 
96
always @ (posedge sys_clk or negedge s_reset_n)
97
begin
98
   if (s_reset_n == 1'b0) begin
99
      reg_trig_cntr <= 'b0;
100
   end
101
   else begin
102
      if (reg_sel && reg_wr) begin
103
         reg_trig_cntr <= reg_wr_data;
104
      end
105
      else begin
106
         if (count_trigger)
107
              reg_trig_cntr <= reg_trig_cntr + 1'b1;
108
         else
109
            reg_trig_cntr <= reg_trig_cntr;
110
      end
111
   end
112
end
113
assign cntr_intr = ((reg_trig_cntr + 1) == 'h0 && count_trigger) ;
114
 
115
assign cntrout = reg_trig_cntr;
116
 
117
endmodule // must_stat_counter

powered by: WebSVN 2.1.0

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