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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [rtl/] [building_blocks/] [counter/] [openhmc_counter48.v] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 juko
/*
2
 *                              .--------------. .----------------. .------------.
3
 *                             | .------------. | .--------------. | .----------. |
4
 *                             | | ____  ____ | | | ____    ____ | | |   ______ | |
5
 *                             | ||_   ||   _|| | ||_   \  /   _|| | | .' ___  || |
6
 *       ___  _ __   ___ _ __  | |  | |__| |  | | |  |   \/   |  | | |/ .'   \_|| |
7
 *      / _ \| '_ \ / _ \ '_ \ | |  |  __  |  | | |  | |\  /| |  | | || |       | |
8
 *       (_) | |_) |  __/ | | || | _| |  | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
9
 *      \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
10
 *           | |               | |            | | |              | | |          | |
11
 *           |_|               | '------------' | '--------------' | '----------' |
12
 *                              '--------------' '----------------' '------------'
13
 *
14
 *  openHMC - An Open Source Hybrid Memory Cube Controller
15
 *  (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
16
 *  www.ziti.uni-heidelberg.de
17
 *  B6, 26
18
 *  68159 Mannheim
19
 *  Germany
20
 *
21
 *  Contact: openhmc@ziti.uni-heidelberg.de
22
 *  http://ra.ziti.uni-heidelberg.de/openhmc
23
 *
24
 *   This source file is free software: you can redistribute it and/or modify
25
 *   it under the terms of the GNU Lesser General Public License as published by
26
 *   the Free Software Foundation, either version 3 of the License, or
27
 *   (at your option) any later version.
28
 *
29
 *   This source file is distributed in the hope that it will be useful,
30
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 *   GNU Lesser General Public License for more details.
33
 *
34
 *   You should have received a copy of the GNU Lesser General Public License
35
 *   along with this source file.  If not, see <http://www.gnu.org/licenses/>.
36
 *
37
 *
38
 *  Module name: openhmc_counter48
39
 *
40
 */
41
 
42
`default_nettype none
43
 
44
module openhmc_counter48 #(
45
        parameter DATASIZE  = 16    // width of the counter, must be <=48 bits!
46
    ) (
47
        input wire                  clk,
48
        input wire                  res_n,
49
        input wire                  increment,
50
        input wire                  load_enable,
51
        output wire [DATASIZE-1:0]  value
52
);
53
 
54
    reg [DATASIZE-1:0]  value_reg;
55
    reg                 load_enable_reg;
56
 
57
    assign value    = value_reg;
58
 
59
    `ifdef ASYNC_RES
60
    always @(posedge clk or negedge res_n) `else
61
    always @(posedge clk) `endif
62
    begin
63
        if(!res_n) begin
64
            value_reg               <= {DATASIZE{1'b0}};
65
            load_enable_reg         <= 1'b0;
66
        end else begin
67
            load_enable_reg         <= load_enable;
68
            case ({load_enable_reg,increment})
69
                    2'b00:
70
                        value_reg   <= value_reg;
71
                    2'b01:
72
                        value_reg   <= (value_reg + 1'b1);
73
                    2'b10:
74
                        value_reg   <= {DATASIZE{1'b0}};
75
                    2'b11:
76
                        value_reg   <= {DATASIZE{1'b0}} + 1'b1;
77
            endcase
78
        end
79
    end
80
 
81
endmodule
82
`default_nettype wire

powered by: WebSVN 2.1.0

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