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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [cpu/] [zipcounter.v] - Blame information for rev 110

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

Line No. Rev Author Line
1 21 dgisselq
///////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    zipcounter.v
4
//
5
// Project:     Zip CPU -- a small, lightweight, RISC CPU soft core
6
//
7
// Purpose:
8
//              A very, _very_ simple counter.  It's purpose doesn't really
9
//      include rollover, but it will interrupt on rollover.  It can be set,
10
//      although my design concept is that it can be reset.  It cannot be
11
//      halted.  It will always produce interrupts--whether or not they are 
12
//      handled interrupts is another question--that's up to the interrupt
13
//      controller.
14
//
15
//      My intention is to use this counter for process accounting: I should
16
//      be able to use this to count clock ticks of processor time assigned to
17
//      each task by resetting the counter at the beginning of every task
18
//      interval, and reading the result at the end of the interval.  As long
19
//      as the interval is less than 2^32 clocks, there should be no problem.
20
//      Similarly, this can be used to measure CPU wishbone bus stalls, 
21
//      prefetch stalls, or other CPU stalls (i.e. stalling as part of a JMP
22
//      instruction, or a read from the condition codes following a write).
23
//
24
//
25
// Creator:     Dan Gisselquist, Ph.D.
26
//              Gisselquist Technology, LLC
27
//
28
///////////////////////////////////////////////////////////////////////////
29
//
30 87 dgisselq
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
31 21 dgisselq
//
32
// This program is free software (firmware): you can redistribute it and/or
33
// modify it under the terms of  the GNU General Public License as published
34
// by the Free Software Foundation, either version 3 of the License, or (at
35
// your option) any later version.
36
//
37
// This program is distributed in the hope that it will be useful, but WITHOUT
38
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
39
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
40
// for more details.
41
//
42
// License:     GPL, v3, as defined and found on www.gnu.org,
43
//              http://www.gnu.org/licenses/gpl.html
44
//
45
//
46
///////////////////////////////////////////////////////////////////////////
47
//
48
module  zipcounter(i_clk, i_ce,
49
                i_wb_cyc, i_wb_stb, i_wb_we, i_wb_data,
50
                        o_wb_ack, o_wb_stall, o_wb_data,
51
                o_int);
52
        parameter       BW = 32;
53
        input                           i_clk, i_ce;
54
        // Wishbone inputs
55
        input                           i_wb_cyc, i_wb_stb, i_wb_we;
56
        input           [(BW-1):0]       i_wb_data;
57
        // Wishbone outputs
58
        output  reg                     o_wb_ack;
59
        output  wire                    o_wb_stall;
60
        output  reg     [(BW-1):0]       o_wb_data;
61
        // Interrupt line
62
        output  reg                     o_int;
63
 
64 87 dgisselq
        initial o_int = 0;
65 21 dgisselq
        initial o_wb_data = 32'h00;
66
        always @(posedge i_clk)
67
                if ((i_wb_cyc)&&(i_wb_stb)&&(i_wb_we))
68 87 dgisselq
                        { o_int, o_wb_data } <= { 1'b0, i_wb_data };
69 21 dgisselq
                else if (i_ce)
70 87 dgisselq
                        { o_int, o_wb_data } <= o_wb_data+{{(BW-1){1'b0}},1'b1};
71
                else
72
                        o_int <= 1'b0;
73 21 dgisselq
 
74
        initial o_wb_ack = 1'b0;
75
        always @(posedge i_clk)
76
                o_wb_ack <= (i_wb_cyc)&&(i_wb_stb);
77
        assign  o_wb_stall = 1'b0;
78
endmodule

powered by: WebSVN 2.1.0

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