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

Subversion Repositories zet86

[/] [zet86/] [trunk/] [soc/] [timer.v] - Blame information for rev 52

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 52 zeus
 /*
2
  *  Phase accumulator clock:
3
  *   Fo = Fc * N / 2^bits
4
  *   here N: 12507 and bits: 32
5
  *   it gives a frequency of 18.200080376 Hz
6
  */
7
 
8
module timer #(
9
    parameter res   = 33,   // bit resolution (default: 33 bits)
10
    parameter phase = 12507 // phase value for the counter
11
  )
12
  (
13 45 zeus
    // Wishbone slave interface
14
    input      wb_clk_i,
15
    input      wb_rst_i,
16 52 zeus
    output reg wb_tgc_o   // intr
17 45 zeus
  );
18
 
19
  // Registers and nets
20 52 zeus
  reg [res-1:0] cnt;
21
  reg           old_clk2;
22
  wire          clk2;
23 45 zeus
 
24
  // Continuous assignments
25 52 zeus
  assign clk2 = cnt[res-1];
26 45 zeus
 
27
  // Behaviour
28
  // cnt
29
  always @(posedge wb_clk_i)
30 52 zeus
    cnt <= wb_rst_i ? 0 : (cnt + phase);
31 45 zeus
 
32
  // old_clk2
33
  always @(posedge wb_clk_i)
34
    old_clk2 <= wb_rst_i ? 1'b0 : clk2;
35
 
36 52 zeus
  // intr
37 45 zeus
  always @(posedge wb_clk_i)
38 52 zeus
    wb_tgc_o <= wb_rst_i ? 1'b0 : (!old_clk2 & clk2);
39 45 zeus
 
40
endmodule

powered by: WebSVN 2.1.0

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