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

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [peripherals/] [timer.v] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinclairrf
//
2
// PERIPHERAL timer:  @NAME@
3 10 sinclairrf
// Copyright 2013, Sinclair R.F., Inc.
4 2 sinclairrf
//
5
localparam L__COUNT = @RATEMETHOD@-1;
6
localparam L__COUNT_NBITS = $clog2(L__COUNT);
7
generate
8
reg [L__COUNT_NBITS-1:0] s__count = L__COUNT[0+:L__COUNT_NBITS];
9
always @ (posedge i_clk)
10
  if (i_rst) begin
11
    s__count <= L__COUNT[0+:L__COUNT_NBITS];
12
    s__expired <= 1'b0;
13
  end else begin
14
    if (s__expired)
15
      s__count <= L__COUNT[0+:L__COUNT_NBITS];
16
    else
17
      s__count <= s__count - { {(L__COUNT_NBITS-1){1'b0}}, 1'b1 };
18
    s__expired <= (s__count == { {(L__COUNT_NBITS-1){1'b0}}, 1'b1 });
19
  end
20
endgenerate

powered by: WebSVN 2.1.0

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