1 |
12 |
rehayes |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// WISHBONE revB.2 compliant Xgate Coprocessor - Master Bus interface
|
4 |
|
|
//
|
5 |
|
|
// Author: Bob Hayes
|
6 |
|
|
// rehayes@opencores.org
|
7 |
|
|
//
|
8 |
|
|
// Downloaded from: http://www.opencores.org/projects/xgate.....
|
9 |
|
|
//
|
10 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
11 |
|
|
// Copyright (c) 2009, Robert Hayes
|
12 |
|
|
//
|
13 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
14 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
15 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
16 |
|
|
// (at your option) any later version.
|
17 |
|
|
//
|
18 |
|
|
// Supplemental terms.
|
19 |
|
|
// * Redistributions of source code must retain the above copyright
|
20 |
|
|
// notice, this list of conditions and the following disclaimer.
|
21 |
|
|
// * Neither the name of the <organization> nor the
|
22 |
|
|
// names of its contributors may be used to endorse or promote products
|
23 |
|
|
// derived from this software without specific prior written permission.
|
24 |
|
|
//
|
25 |
|
|
// THIS SOFTWARE IS PROVIDED BY Robert Hayes ''AS IS'' AND ANY
|
26 |
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
27 |
|
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
28 |
|
|
// DISCLAIMED. IN NO EVENT SHALL Robert Hayes BE LIABLE FOR ANY
|
29 |
|
|
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
30 |
|
|
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
31 |
|
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
32 |
|
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
33 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
34 |
|
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
35 |
|
|
//
|
36 |
|
|
// You should have received a copy of the GNU General Public License
|
37 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
38 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
40 |
|
|
|
41 |
|
|
module xgate_wbm_bus #(parameter ARST_LVL = 1'b0, // asynchronous reset level
|
42 |
89 |
rehayes |
parameter DWIDTH = 16,
|
43 |
12 |
rehayes |
parameter SINGLE_CYCLE = 1'b0)
|
44 |
|
|
(
|
45 |
|
|
// Wishbone Signals
|
46 |
|
|
output [DWIDTH-1:0] wbm_dat_o, // databus output
|
47 |
|
|
output wbm_we_o, // write enable output
|
48 |
|
|
output wbm_stb_o, // stobe/core select signal
|
49 |
|
|
output wbm_cyc_o, // valid bus cycle output
|
50 |
|
|
output [ 1:0] wbm_sel_o, // Select byte in word bus transaction
|
51 |
|
|
output [15:0] wbm_adr_o, // Address bits
|
52 |
|
|
input [DWIDTH-1:0] wbm_dat_i, // databus input
|
53 |
|
|
input wbm_ack_i, // bus cycle acknowledge input
|
54 |
|
|
input wbs_clk_i, // master clock input
|
55 |
|
|
input wbs_rst_i, // synchronous active high reset
|
56 |
|
|
input arst_i, // asynchronous reset
|
57 |
29 |
rehayes |
// XGATE Control Signals
|
58 |
12 |
rehayes |
output [DWIDTH-1:0] read_mem_data, // Data from system memory
|
59 |
|
|
output mem_req_ack, // Memory bus transaction complete
|
60 |
53 |
rehayes |
input risc_clk, //
|
61 |
|
|
input async_rst_b, //
|
62 |
34 |
rehayes |
input xge, // XGATE Enabled
|
63 |
53 |
rehayes |
input single_step, // Pulse to trigger a single instruction execution in debug mode
|
64 |
|
|
output ss_mem_ack, // WISHBONE Bus has granted single step memory access
|
65 |
12 |
rehayes |
input [15:0] xgate_address, // Address to system memory
|
66 |
89 |
rehayes |
input mem_access, //
|
67 |
12 |
rehayes |
input write_mem_strb_l, // Strobe for writing low data byte
|
68 |
|
|
input write_mem_strb_h, // Strobe for writing high data bye
|
69 |
|
|
input [DWIDTH-1:0] write_mem_data // Data to system memory
|
70 |
|
|
);
|
71 |
|
|
|
72 |
|
|
|
73 |
34 |
rehayes |
// Wires and Registers
|
74 |
12 |
rehayes |
wire module_sel; // This module is selected for bus transaction
|
75 |
53 |
rehayes |
reg ss_mem_req; // Bus request for single step memory access
|
76 |
12 |
rehayes |
|
77 |
|
|
//
|
78 |
34 |
rehayes |
// Module body
|
79 |
12 |
rehayes |
//
|
80 |
89 |
rehayes |
|
81 |
53 |
rehayes |
// Latch Single Step Request and ask for memory access
|
82 |
|
|
always @(posedge risc_clk or negedge async_rst_b)
|
83 |
|
|
if ( !async_rst_b )
|
84 |
|
|
ss_mem_req <= 1'b0;
|
85 |
|
|
else
|
86 |
|
|
ss_mem_req <= (single_step || ss_mem_req) && !wbm_ack_i && xge;
|
87 |
89 |
rehayes |
|
88 |
53 |
rehayes |
assign ss_mem_ack = ss_mem_req && wbm_ack_i;
|
89 |
|
|
|
90 |
89 |
rehayes |
|
91 |
12 |
rehayes |
assign wbm_dat_o = write_mem_data;
|
92 |
|
|
assign read_mem_data = wbm_dat_i;
|
93 |
|
|
assign wbm_adr_o = xgate_address;
|
94 |
89 |
rehayes |
|
95 |
12 |
rehayes |
assign mem_req_ack = wbm_ack_i;
|
96 |
89 |
rehayes |
|
97 |
29 |
rehayes |
assign wbm_we_o = write_mem_strb_h || write_mem_strb_l;
|
98 |
89 |
rehayes |
|
99 |
29 |
rehayes |
assign wbm_sel_o = {write_mem_strb_h, write_mem_strb_l};
|
100 |
89 |
rehayes |
|
101 |
53 |
rehayes |
assign wbm_cyc_o = xge && (mem_access || ss_mem_req);
|
102 |
89 |
rehayes |
|
103 |
53 |
rehayes |
assign wbm_stb_o = xge && (mem_access || ss_mem_req);
|
104 |
12 |
rehayes |
|
105 |
|
|
endmodule // xgate_wbm_bus
|