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

Subversion Repositories via6522

[/] [via6522/] [trunk/] [rtl/] [ack_gen.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2018-2022  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
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 .
20
//
21
// ack_gen.v
22
// - generates a acknowledge signal after a specified number of clocks.
23
// - separate stages for read and write
24
//
25
// ============================================================================
26
//
27
module ack_gen(rst_i, clk_i, ce_i, i, rid_i, we_i, wid_i, o, rid_o, wid_o);
28
input rst_i;
29
input clk_i;
30
input ce_i;
31
input i;
32
input [3:0] rid_i;
33
input we_i;
34
input [3:0] wid_i;
35
output reg o;
36
output reg [3:0] rid_o;
37
output reg [3:0] wid_o;
38
parameter READ_STAGES = 3;
39
parameter WRITE_STAGES = 0;
40
parameter ACK_LEVEL = 1'b0;
41
parameter REGISTER_OUTPUT = 1'b0;
42
 
43
wire ro, wo;
44
wire [3:0] rid, wid;
45
generate begin : gRdy
46
if (READ_STAGES==0) begin
47
assign ro = 0;
48
assign rid = rid_i;
49
end
50
else begin
51
ready_gen #(READ_STAGES) urrdy (clk_i, ce_i, i, ro, rid_i, rid);
52
end
53
if (WRITE_STAGES==0) begin
54
assign wo = we_i;
55
assign wid = wid_i;
56
end
57
else begin
58
ready_gen #(WRITE_STAGES) uwrdy (clk_i, ce_i, we_i, wo, wid_i, wid);
59
end
60
if (REGISTER_OUTPUT) begin
61
always @(posedge clk_i)
62
if (rst_i)
63
        o <= 1'b0;
64
else
65
        o <= we_i ? wo : (i ? ro : ACK_LEVEL);
66
always @(posedge clk_i)
67
        rid_o <= rid;
68
always @(posedge clk_i)
69
        wid_o <= wid;
70
end
71
else begin
72
always @*
73
        o <= we_i ? wo : (i ? ro : ACK_LEVEL);
74
always @*
75
        rid_o <= rid;
76
always @*
77
        wid_o <= wid;
78
end
79
end
80
endgenerate
81
 
82
endmodule

powered by: WebSVN 2.1.0

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