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

Subversion Repositories pss

[/] [pss/] [trunk/] [pss/] [hdl/] [pss/] [zpu_uc/] [motherblock/] [pss_busbridge.v] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 AlexAntono
/*
2
 PSS
3
 
4
 Copyright (c) 2016 Alexander Antonov <153287@niuitmo.ru>
5
 All rights reserved.
6
 
7
 Version 0.9.0
8
 
9
 The FreeBSD license
10
 
11
 Redistribution and use in source and binary forms, with or without
12
 modification, are permitted provided that the following conditions
13
 are met:
14
 
15
 1. Redistributions of source code must retain the above copyright
16
    notice, this list of conditions and the following disclaimer.
17
 2. Redistributions in binary form must reproduce the above
18
    copyright notice, this list of conditions and the following
19
    disclaimer in the documentation and/or other materials
20
    provided with the distribution.
21
 
22
 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
23
 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24
 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25
 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
 PSS PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
 
36
 
37
module PSS_BusBridge
38
(
39
        input clk_i, rst_i,
40
 
41
        input xport_busy_i,
42
        output xport_busy_o,
43
 
44
        input a31_i,
45
 
46
        //// Masters ////
47
        // Debug bus //
48
        input bus_enb_i,
49
        input bus_we_i,
50
        input [31:0] bus_addr_bi,
51
        input [31:0] bus_wdata_bi,
52
        input [3:0] bus_writemask_bi,
53
        output reg bus_ack_o,
54
        output reg [31:0] bus_rdata_bo,
55
 
56
        // Expansion bus //
57
        output reg xport_req_o,
58
        input  xport_ack_i,
59
        input  xport_err_i,
60
        output reg xport_we_o,
61
        output reg [31:0] xport_addr_bo,
62
        output reg [31:0] xport_wdata_bo,
63
        output reg [3:0] xport_writemask_bo,
64
        input xport_resp_i,
65
        input [31:0] xport_rdata_bi
66
);
67
 
68
localparam ST_IDLE                      = 2'h0;
69
localparam ST_WR_WAIT_ACK       = 2'h1;
70
localparam ST_RD_WAIT_ACK       = 2'h2;
71
localparam ST_RD_WAIT_RESP      = 2'h3;
72
 
73
reg [1:0] bb_state;
74
 
75
assign xport_busy_o = bus_enb_i;
76
 
77
assign rdata_bo = xport_rdata_bi;
78
 
79
always @(posedge clk_i)
80
        begin
81
        if (rst_i)
82
                begin
83
                bb_state <= ST_IDLE;
84
 
85
                bus_ack_o <= 1'b0;
86
                bus_rdata_bo <= 32'hx;
87
 
88
                xport_req_o <= 1'b0;
89
                xport_we_o <= 1'b0;
90
                xport_addr_bo <= 32'hx;
91
                xport_wdata_bo <= 32'hx;
92
                xport_writemask_bo <= 4'hx;
93
                end
94
        else
95
                begin
96
 
97
                bus_ack_o <= 1'b0;
98
                bus_rdata_bo <= 32'hx;
99
 
100
                case (bb_state)
101
 
102
                ST_IDLE:
103
                        begin
104
                        if ((bus_enb_i == 1'b1) && (bus_ack_o == 1'b0))
105
                                begin
106
                                if (bus_we_i == 1'b1)
107
                                        begin
108
                                        xport_req_o <= 1'b1;
109
                                        xport_we_o <= 1'b1;
110 7 AlexAntono
                                        xport_addr_bo <= {a31_i, bus_addr_bi[30:0]};
111 5 AlexAntono
                                        xport_wdata_bo <= bus_wdata_bi;
112
                                        xport_writemask_bo <= bus_writemask_bi;
113
                                        bb_state <= ST_WR_WAIT_ACK;
114
                                        end
115
                                else
116
                                        begin
117
                                        xport_req_o <= 1'b1;
118
                                        xport_we_o <= 1'b0;
119 7 AlexAntono
                                        xport_addr_bo <= {a31_i, bus_addr_bi[30:0]};
120 5 AlexAntono
                                        xport_wdata_bo <= bus_wdata_bi;
121
                                        xport_writemask_bo <= bus_writemask_bi;
122
                                        bb_state <= ST_RD_WAIT_ACK;
123
                                        end
124
                                end
125
                        end
126
 
127
                ST_WR_WAIT_ACK:
128
                        begin
129
                        if (xport_ack_i == 1'b1)
130
                                begin
131
                                xport_req_o <= 1'b0;
132
                                xport_we_o <= 1'b0;
133
                                xport_addr_bo <= 32'hx;
134
                                xport_wdata_bo <= 32'hx;
135
                                xport_writemask_bo <= 4'hx;
136
 
137
                                bus_ack_o <= 1'b1;
138
 
139
                                bb_state <= ST_IDLE;
140
                                end
141
                        end
142
 
143
                ST_RD_WAIT_ACK:
144
                        begin
145
                        if (xport_ack_i == 1'b1)
146
                                begin
147
                                xport_req_o <= 1'b0;
148
                                xport_we_o <= 1'b0;
149
                                xport_addr_bo <= 32'hx;
150
                                xport_wdata_bo <= 32'hx;
151
                                xport_writemask_bo <= 4'hx;
152
 
153
                                bb_state <= ST_RD_WAIT_RESP;
154
                                end
155
                        end
156
 
157
                ST_RD_WAIT_RESP:
158
                        begin
159
                        if (xport_resp_i == 1'b1)
160
                                begin
161
                                bus_ack_o <= 1'b1;
162
                                bus_rdata_bo <= xport_rdata_bi;
163
 
164
                                bb_state <= ST_IDLE;
165
                                end
166
                        end
167
 
168
                endcase
169
 
170
                end
171
        end
172
 
173
endmodule

powered by: WebSVN 2.1.0

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