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

Subversion Repositories zet86

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

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

Line No. Rev Author Line
1 45 zeus
module timer (
2
    // Wishbone slave interface
3
    input      wb_clk_i,
4
    input      wb_rst_i,
5
    output reg wb_tgc_o,   // intr
6
    input      wb_tgc_i    // inta
7
  );
8
 
9
  // Registers and nets
10
  reg [17:0] cnt;
11
  reg        old_clk2;
12
  reg        pulse;
13
  wire       clk2;
14
 
15
  // Continuous assignments
16
  assign clk2 = cnt[17];
17
 
18
  // Behaviour
19
  // cnt
20
  always @(posedge wb_clk_i)
21
    cnt <= wb_rst_i ? 18'h00 : (cnt + 18'h1);
22
 
23
  // old_clk2
24
  always @(posedge wb_clk_i)
25
    old_clk2 <= wb_rst_i ? 1'b0 : clk2;
26
 
27
  // pulse
28
  always @(posedge wb_clk_i)
29
    pulse <= wb_rst_i ? 1'b0 : (clk2!=old_clk2);
30
 
31
  // intr
32
  always @(posedge wb_clk_i)
33
    wb_tgc_o <= wb_rst_i ? 1'b0
34
      : ((pulse & !wb_tgc_i) ? 1'b1
35
      : (wb_tgc_o ? !wb_tgc_i : 1'b0));
36
endmodule

powered by: WebSVN 2.1.0

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