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

Subversion Repositories rtf_sprite_controller

[/] [rtf_sprite_controller/] [trunk/] [rtl/] [verilog/] [busTimeoutCtr.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robfinch
/* ===============================================================
2
        (C) 2005  Robert Finch
3
        All rights reserved.
4
        rob@birdcomputer.ca
5
 
6
        busTimeoutCtr.v
7
                Generates a timeout signal if the bus hasn't responded
8
        within a preset period.
9
 
10
 
11
        This source code is free for use and modification for
12
        non-commercial or evaluation purposes, provided this
13
        copyright statement and disclaimer remains present in
14
        the file.
15
 
16
        If you do modify the code, please state the origin and
17
        note that you have modified the code.
18
 
19
        NO WARRANTY.
20
        THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF
21
        ANY KIND, WHETHER EXPRESS OR IMPLIED. The user must assume
22
        the entire risk of using the Work.
23
 
24
        IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
25
        ANY INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES
26
        WHATSOEVER RELATING TO THE USE OF THIS WORK, OR YOUR
27
        RELATIONSHIP WITH THE AUTHOR.
28
 
29
        IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU
30
        TO USE THE WORK IN APPLICATIONS OR SYSTEMS WHERE THE
31
        WORK'S FAILURE TO PERFORM CAN REASONABLY BE EXPECTED
32
        TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN LOSS
33
        OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK,
34
        AND YOU AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS
35
        FROM ANY CLAIMS OR LOSSES RELATING TO SUCH UNAUTHORIZED
36
        USE.
37
 
38
 
39
                The default reset state is to request the bus.
40
                This little circuit asserts the br line to an external
41
        bus when req pulses high (for a clock cycle or more) and
42
        removes the br signal if there is no pending req, once a
43
        bg has been given.
44
 
45
        br goes high as soon as req goes high, but then remains
46
        high even if req is removed.
47
        br goes low as soon as bg goes high UNLESS there is also
48
        a req present, in which case it stays high.
49
 
50
        br      = the signal to the external bus that a request is
51
                  present
52
        bg      = the signal from the external bus that the bus has
53
              been granted
54
        req     = signal provided by the master to indicate that it
55
                  needs the bus. The master should monitor the bg
56
                  signal to know when it has control of the bus.
57
        rdy = input indicating that the bus transaction is
58
              complete
59
        timeout = flag indicating that the request has timed out.
60
              Pulses high for one cycle.
61
 
62
        9LUTs / 8 slices
63
=============================================================== */
64
 
65
module busTimeoutCtr(
66
        input rst,              // reset
67
        input crst,             // critical reset
68
        input clk,              // system clock
69
        input ce,               // core clock enable
70
        input req,              // request bus
71
        input rdy,              // data ready input
72
        output timeout  // timeout
73
);
74
        parameter pTimeout = 20;                // max 61
75
 
76
        reg [5:0] btc;   // bus timeout counter
77
 
78
        always @(posedge clk)
79
                if (rst)
80
                        btc <= 0;
81
                else if (ce) begin
82
                        if (req)
83
                                btc <= pTimeout+2;
84
                        else if (rdy)
85
                                btc <= 0;
86
                        else if (btc > 0)
87
                                btc <= btc - 1;
88
                end
89
 
90
        assign timeout = btc==6'd1;
91
 
92
endmodule
93
 
94
 

powered by: WebSVN 2.1.0

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