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

Subversion Repositories via6522

[/] [via6522/] [trunk/] [rtl/] [ready_gen.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2018-2019  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@opencores.org
6
//       ||
7
//
8
// This source file is free software: you can redistribute it and/or modify 
9
// it under the terms of the GNU Lesser General Public License as published 
10
// by the Free Software Foundation, either version 3 of the License, or     
11
// (at your option) any later version.                                      
12
//                                                                          
13
// This source file is distributed in the hope that it will be useful,      
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
16
// GNU General Public License for more details.                             
17
//                                                                          
18
// You should have received a copy of the GNU General Public License        
19
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
20
//                                                            
21
// ready_gen.v
22
// - generates a ready signal after a specified number of clocks.
23
// - this is not a simple delay line. Output is set low as soom as the
24
//   input goes low.
25
//
26
// ============================================================================
27
//
28
module ready_gen(clk_i, ce_i, i, o, id_i, id_o);
29
input clk_i;
30
input ce_i;
31
input i;
32
output reg o = 1'd0;
33
input [3:0] id_i;
34
output reg [3:0] id_o;
35
parameter STAGES = 3;
36
 
37
integer n;
38
reg [STAGES-1:0] rdy;
39
reg [3:0] id [0:STAGES-1];
40
always @(posedge clk_i)
41
if (ce_i) begin
42
        rdy[0] <= i;
43
        id[0] <= id_i;
44
        for (n = 1; n < STAGES; n = n + 1) begin
45
                rdy[n] <= rdy[n-1] & i;
46
                id[n] <= id[n-1] & {4{i}};
47
        end
48
        o <= rdy[STAGES-1] & i;
49
        id_o <= id[STAGES-1] & {4{i}};
50
end
51
 
52
endmodule

powered by: WebSVN 2.1.0

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