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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fpga/] [mc/] [src/] [tmr/] [tmr.v] - Diff between revs 67 and 68

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 67 Rev 68
Line 1... Line 1...
 
//
 
// tmr.v -- programmable timer
 
//
 
 
 
 
module tmr(clk, reset,
module tmr(clk, reset,
           en, wr, addr,
           en, wr, addr,
           data_in, data_out,
           data_in, data_out,
           wt, irq);
           wt, irq);
    input clk;
    input clk;
Line 10... Line 15...
    input [31:0] data_in;
    input [31:0] data_in;
    output [31:0] data_out;
    output [31:0] data_out;
    output wt;
    output wt;
    output irq;
    output irq;
 
 
  reg [15:0] prescaler;
  reg [5:0] prescaler;
  reg tick;
  reg tick;
  reg [31:0] counter;
  reg [31:0] counter;
  reg [31:0] divisor;
  reg [31:0] divisor;
  reg divisor_loaded;
  reg divisor_loaded;
  reg expired;
  reg expired;
  reg alarm;
  reg alarm;
  reg ien;
  reg ien;
 
 
  always @(posedge clk) begin
  always @(posedge clk) begin
    if (reset == 1) begin
    if (reset == 1) begin
      prescaler <= 16'd50000;
      prescaler <= 6'd50;
      tick <= 0;
      tick <= 0;
    end else begin
    end else begin
      if (prescaler == 16'd1) begin
      if (prescaler == 6'd1) begin
        prescaler <= 16'd50000;
        prescaler <= 6'd50;
        tick <= 1;
        tick <= 1;
      end else begin
      end else begin
        prescaler <= prescaler - 1;
        prescaler <= prescaler - 1;
        tick <= 0;
        tick <= 0;
      end
      end

powered by: WebSVN 2.1.0

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