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

Subversion Repositories aor3000

[/] [aor3000/] [trunk/] [syn/] [soc/] [simple_clock/] [simple_clock.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/*
2
 * This file is subject to the terms and conditions of the BSD License. See
3
 * the file "LICENSE" in the main directory of this archive for more details.
4
 *
5
 * Copyright (C) 2014 Aleksander Osman
6
 */
7
 
8
/* Generated an interrupt every 500000 cycles.
9
 * If the clock is 50 MHz, the interrupt will be at a frequency of 100 Hz.
10
 * Any write acknowledges the interrupt.
11
 */
12
 
13
module simple_clock(
14
        input           clk,
15
        input           rst_n,
16
 
17
        output reg      irq,
18
 
19
        input           avs_write,
20
        input [31:0]    avs_writedata
21
);
22
 
23
reg [18:0] counter;
24
always @(posedge clk or negedge rst_n) begin
25
        if(rst_n == 1'b0)               counter <= 19'd0;
26
        else if(counter == 19'd499999)  counter <= 19'd0;
27
        else                            counter <= counter + 13'd1;
28
end
29
 
30
always @(posedge clk or negedge rst_n) begin
31
        if(rst_n == 1'b0)               irq <= 1'd0;
32
        else if(counter == 19'd499999)  irq <= 1'd1;
33
        else if(avs_write)              irq <= 1'd0;
34
end
35
 
36
endmodule

powered by: WebSVN 2.1.0

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