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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [amber25/] [a25_wishbone_buf.v] - Blame information for rev 35

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 csantifort
//////////////////////////////////////////////////////////////////
2
//                                                              //
3
//  Wishbone master interface port buffer                       //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  This is a sub-module of the Amber wishbone master           //
10
//  interface. The wishbone master interface connects a number  //
11
//  of internal amber ports to the wishbone bus. The ports      //
12
//  are;                                                        //
13
//       instruction cache read accesses                        //
14
//       data cache read and write accesses (cached)            //
15
//       data cache read and write accesses (uncached)          //
16
//                                                              //
17
//  The buffer module buffers a single port. For write          //
18
//  requests, this allows the processor core to continue        //
19
//  executing withont having to wait for the wishbone write     //
20
//  operation to complete.                                      //
21
//                                                              //
22
//  Author(s):                                                  //
23
//      - Conor Santifort, csantifort.amber@gmail.com           //
24
//                                                              //
25
//////////////////////////////////////////////////////////////////
26
//                                                              //
27
// Copyright (C) 2011 Authors and OPENCORES.ORG                 //
28
//                                                              //
29
// This source file may be used and distributed without         //
30
// restriction provided that this copyright statement is not    //
31
// removed from the file and that any derivative work contains  //
32
// the original copyright notice and the associated disclaimer. //
33
//                                                              //
34
// This source file is free software; you can redistribute it   //
35
// and/or modify it under the terms of the GNU Lesser General   //
36
// Public License as published by the Free Software Foundation; //
37
// either version 2.1 of the License, or (at your option) any   //
38
// later version.                                               //
39
//                                                              //
40
// This source is distributed in the hope that it will be       //
41
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
42
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
43
// PURPOSE.  See the GNU Lesser General Public License for more //
44
// details.                                                     //
45
//                                                              //
46
// You should have received a copy of the GNU Lesser General    //
47
// Public License along with this source; if not, download it   //
48
// from http://www.opencores.org/lgpl.shtml                     //
49
//                                                              //
50
//////////////////////////////////////////////////////////////////
51
 
52
module a25_wishbone_buf (
53
input                       i_clk,
54
 
55
// Core side
56
input                       i_req,
57
input                       i_write,
58
input       [127:0]         i_wdata,
59
input       [15:0]          i_be,
60
input       [31:0]          i_addr,
61
output      [127:0]         o_rdata,
62
output                      o_ready,
63
 
64
// Wishbone side
65
output                      o_valid,
66
input                       i_accepted,
67
output                      o_write,
68
output      [127:0]         o_wdata,
69
output      [15:0]          o_be,
70
output      [31:0]          o_addr,
71
input       [127:0]         i_rdata,
72
input                       i_rdata_valid
73
);
74
 
75
 
76
// ----------------------------------------------------
77
// Signals
78
// ----------------------------------------------------
79
reg                         wbuf_used_r = 'd0;
80
reg  [127:0]                wbuf_wdata_r;
81
reg  [31:0]                 wbuf_addr_r;
82
reg  [15:0]                 wbuf_be_r;
83
reg                         wbuf_write_r = 'd0;
84
wire                        in_wreq = i_req && i_write;
85
reg                         busy_reading_r = 'd0;
86
 
87
 
88
// ----------------------------------------------------
89
// Access Buffer
90
// ----------------------------------------------------
91
always @(posedge i_clk)
92
    if (!wbuf_used_r && i_req)
93
        begin
94
        wbuf_used_r     <= !i_accepted;
95
        wbuf_wdata_r    <= i_wdata;
96
        wbuf_addr_r     <= i_addr;
97
        wbuf_be_r       <= i_write ? i_be : 16'hffff;
98
        wbuf_write_r    <= i_write;
99
        end
100
    else if (o_valid && i_accepted && wbuf_write_r)
101
        wbuf_used_r     <= 1'd0;
102
    else if (i_rdata_valid && !wbuf_write_r)
103
        wbuf_used_r     <= 1'd0;
104
 
105
 
106
// ----------------------------------------------------
107
// Output logic
108
// ----------------------------------------------------
109
assign o_wdata = wbuf_used_r ? wbuf_wdata_r : i_wdata;
110
assign o_write = wbuf_used_r ? wbuf_write_r : i_write;
111
assign o_addr  = wbuf_used_r ? wbuf_addr_r  : i_addr;
112
assign o_be    = wbuf_used_r ? wbuf_be_r    : i_write ? i_be : 16'hffff;
113
 
114
assign o_valid   = (wbuf_used_r || i_req) && !busy_reading_r;
115
 
116
assign o_rdata = i_rdata;
117
assign o_ready = in_wreq ? (!wbuf_used_r || i_accepted) : i_rdata_valid;
118
 
119
 
120
always@(posedge i_clk)
121
    if (o_valid && !o_write && i_accepted)
122
        busy_reading_r <= 1'd1;
123
    else if (i_rdata_valid)
124
        busy_reading_r <= 1'd0;
125
 
126
 
127
 
128
endmodule
129
 
130
 
131
 
132
 

powered by: WebSVN 2.1.0

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