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

Subversion Repositories ssbcc

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

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

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

powered by: WebSVN 2.1.0

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