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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [rtl/] [cpu/] [altor32_noicache.v] - Blame information for rev 40

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

Line No. Rev Author Line
1 27 ultra_embe
//-----------------------------------------------------------------
2
//                           AltOR32 
3
//                Alternative Lightweight OpenRisc 
4 36 ultra_embe
//                            V2.1
5 27 ultra_embe
//                     Ultra-Embedded.com
6 36 ultra_embe
//                   Copyright 2011 - 2014
7 27 ultra_embe
//
8
//               Email: admin@ultra-embedded.com
9
//
10
//                       License: LGPL
11
//-----------------------------------------------------------------
12
//
13 37 ultra_embe
// Copyright (C) 2011 - 2014 Ultra-Embedded.com
14 27 ultra_embe
//
15
// This source file may be used and distributed without         
16
// restriction provided that this copyright statement is not    
17
// removed from the file and that any derivative work contains  
18
// the original copyright notice and the associated disclaimer. 
19
//
20
// This source file is free software; you can redistribute it   
21
// and/or modify it under the terms of the GNU Lesser General   
22
// Public License as published by the Free Software Foundation; 
23
// either version 2.1 of the License, or (at your option) any   
24
// later version.
25
//
26
// This source is distributed in the hope that it will be       
27
// useful, but WITHOUT ANY WARRANTY; without even the implied   
28
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      
29
// PURPOSE.  See the GNU Lesser General Public License for more 
30
// details.
31
//
32
// You should have received a copy of the GNU Lesser General    
33
// Public License along with this source; if not, write to the 
34
// Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
35
// Boston, MA  02111-1307  USA
36
//-----------------------------------------------------------------
37
 
38
//-----------------------------------------------------------------
39
// Includes
40
//-----------------------------------------------------------------
41
`include "altor32_defs.v"
42
 
43
//-----------------------------------------------------------------
44
// Module - Cache substitute (used when ICache disabled)
45
//-----------------------------------------------------------------
46
module altor32_noicache
47
(
48
    input                       clk_i /*verilator public*/,
49
    input                       rst_i /*verilator public*/,
50
 
51
    // Processor interface
52
    input                       rd_i /*verilator public*/,
53
    input [31:0]                pc_i /*verilator public*/,
54
    output [31:0]               instruction_o /*verilator public*/,
55
    output                      valid_o /*verilator public*/,
56 36 ultra_embe
 
57
    // Invalidate (not used)
58
    input                       invalidate_i /*verilator public*/,
59 27 ultra_embe
 
60 32 ultra_embe
    // Memory interface
61 37 ultra_embe
    output [31:0]               wbm_addr_o /*verilator public*/,
62 32 ultra_embe
    input [31:0]                wbm_dat_i /*verilator public*/,
63
    output [2:0]                wbm_cti_o /*verilator public*/,
64 37 ultra_embe
    output                      wbm_cyc_o /*verilator public*/,
65
    output                      wbm_stb_o /*verilator public*/,
66 32 ultra_embe
    input                       wbm_stall_i/*verilator public*/,
67
    input                       wbm_ack_i/*verilator public*/
68 27 ultra_embe
);
69
 
70
//-----------------------------------------------------------------
71
// Registers / Wires
72
//-----------------------------------------------------------------
73
 
74
// Current state
75 37 ultra_embe
parameter STATE_CHECK   = 0;
76
parameter STATE_FETCH   = 1;
77
reg                     state_q;
78 27 ultra_embe
 
79 37 ultra_embe
reg                     drop_resp_q;
80 27 ultra_embe
 
81 37 ultra_embe
wire                    mem_fetch_w = (state_q == STATE_CHECK);
82
wire                    mem_valid_w;
83
wire                    mem_final_w;
84 32 ultra_embe
 
85 27 ultra_embe
//-----------------------------------------------------------------
86 37 ultra_embe
// Fetch unit
87
//-----------------------------------------------------------------
88
altor32_wb_fetch
89
u_wb
90
(
91
    .clk_i(clk_i),
92
    .rst_i(rst_i),
93
 
94
    .fetch_i(mem_fetch_w),
95
    .burst_i(1'b0),
96
    .address_i(pc_i),
97
 
98
    .resp_addr_o(/* not used */),
99
    .data_o(instruction_o),
100
    .valid_o(mem_valid_w),
101
    .final_o(mem_final_w),
102
 
103
    .wbm_addr_o(wbm_addr_o),
104
    .wbm_dat_i(wbm_dat_i),
105
    .wbm_cti_o(wbm_cti_o),
106
    .wbm_cyc_o(wbm_cyc_o),
107
    .wbm_stb_o(wbm_stb_o),
108
    .wbm_stall_i(wbm_stall_i),
109
    .wbm_ack_i(wbm_ack_i)
110
);
111
 
112
//-----------------------------------------------------------------
113 27 ultra_embe
// Control logic
114
//-----------------------------------------------------------------
115
always @ (posedge rst_i or posedge clk_i )
116
begin
117
   if (rst_i == 1'b1)
118
   begin
119 37 ultra_embe
        drop_resp_q <= 1'b0;
120
        state_q     <= STATE_CHECK;
121 27 ultra_embe
   end
122
   else
123
   begin
124 37 ultra_embe
        case (state_q)
125 27 ultra_embe
 
126
            //-----------------------------------------
127 37 ultra_embe
            // CHECK - Accept read request
128 27 ultra_embe
            //-----------------------------------------
129
            STATE_CHECK :
130
            begin
131 37 ultra_embe
                drop_resp_q         <= 1'b0;
132
                state_q             <= STATE_FETCH;
133 27 ultra_embe
            end
134
            //-----------------------------------------
135 37 ultra_embe
            // FETCH - Wait for read response
136 27 ultra_embe
            //-----------------------------------------
137
            STATE_FETCH :
138
            begin
139 32 ultra_embe
                // Read whilst waiting for previous response?        
140
                if (rd_i)
141 37 ultra_embe
                    drop_resp_q     <= 1'b1;
142 32 ultra_embe
 
143 27 ultra_embe
                // Data ready from memory?
144 37 ultra_embe
                if (mem_final_w)
145
                    state_q         <= STATE_CHECK;
146 27 ultra_embe
            end
147
 
148
            default:
149
                ;
150
           endcase
151
   end
152
end
153
 
154 37 ultra_embe
assign valid_o              = mem_valid_w & ~drop_resp_q & ~rd_i;
155
assign instruction_o        = wbm_dat_i;
156 32 ultra_embe
 
157 27 ultra_embe
endmodule
158 37 ultra_embe
 

powered by: WebSVN 2.1.0

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