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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [vlog/] [amber25/] [a25_fetch.v] - Diff between revs 16 and 35

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 16 Rev 35
Line 44... Line 44...
 
 
module a25_fetch
module a25_fetch
(
(
input                       i_clk,
input                       i_clk,
input                       i_mem_stall,
input                       i_mem_stall,
 
input                       i_exec_stall,
input                       i_conflict,         // Decode stage stall pipeline because of an instruction conflict
input                       i_conflict,         // Decode stage stall pipeline because of an instruction conflict
output                      o_fetch_stall,      // when this is asserted all registers 
output                      o_fetch_stall,      // when this is asserted all registers 
                                                // in decode and exec stages are frozen
                                                // in decode and exec stages are frozen
input                       i_system_rdy,       // External system can stall core with this signal
input                       i_system_rdy,       // External system can stall core with this signal
 
 
Line 59... Line 60...
input                       i_cache_enable,     // cache enable
input                       i_cache_enable,     // cache enable
input                       i_cache_flush,      // cache flush
input                       i_cache_flush,      // cache flush
input       [31:0]          i_cacheable_area,   // each bit corresponds to 2MB address space
input       [31:0]          i_cacheable_area,   // each bit corresponds to 2MB address space
 
 
output                      o_wb_req,
output                      o_wb_req,
output                      o_wb_qword,         // High for a quad-word fetch request
 
output      [31:0]          o_wb_address,
output      [31:0]          o_wb_address,
input       [31:0]          i_wb_read_data,
input       [127:0]         i_wb_read_data,
input                       i_wb_ready
input                       i_wb_ready
 
 
);
);
 
 
`include "memory_configuration.v"
`include "memory_configuration.v"
 
 
wire                        core_stall;
wire                        core_stall;
wire                        cache_stall;
wire                        cache_stall;
 
wire    [127:0]             cache_read_data128;
wire    [31:0]              cache_read_data;
wire    [31:0]              cache_read_data;
wire                        sel_cache;
wire                        sel_cache;
wire                        uncached_instruction_read;
wire                        uncached_instruction_read;
wire                        address_cachable;
wire                        address_cachable;
wire                        icache_wb_req;
wire                        icache_wb_req;
wire                        wait_wb;
wire                        wait_wb;
reg                         wb_req_r = 'd0;
reg                         wb_req_r = 'd0;
 
wire    [31:0]              wb_rdata32;
 
 
// ======================================
// ======================================
// Memory Decode
// Memory Decode
// ======================================
// ======================================
assign address_cachable  = in_cachable_mem( i_iaddress ) && i_cacheable_area[i_iaddress[25:21]];
assign address_cachable  = in_cachable_mem( i_iaddress ) && i_cacheable_area[i_iaddress[25:21]];
Line 90... Line 92...
// Don't start wishbone transfers when the cache is stalling the core
// Don't start wishbone transfers when the cache is stalling the core
// The cache stalls the core during its initialization sequence
// The cache stalls the core during its initialization sequence
assign uncached_instruction_read = !sel_cache && i_iaddress_valid && !(cache_stall);
assign uncached_instruction_read = !sel_cache && i_iaddress_valid && !(cache_stall);
 
 
// Return read data either from the wishbone bus or the cache
// Return read data either from the wishbone bus or the cache
 
 
 
assign cache_read_data     = i_iaddress[3:2] == 2'd0    ? cache_read_data128[ 31: 0] :
 
                             i_iaddress[3:2] == 2'd1    ? cache_read_data128[ 63:32] :
 
                             i_iaddress[3:2] == 2'd2    ? cache_read_data128[ 95:64] :
 
                                                          cache_read_data128[127:96] ;
 
 
 
assign wb_rdata32 = i_iaddress[3:2] == 2'd0 ? i_wb_read_data[ 31: 0] :
 
                    i_iaddress[3:2] == 2'd1 ? i_wb_read_data[ 63:32] :
 
                    i_iaddress[3:2] == 2'd2 ? i_wb_read_data[ 95:64] :
 
                                              i_wb_read_data[127:96] ;
 
 
assign o_fetch_instruction = sel_cache                  ? cache_read_data :
assign o_fetch_instruction = sel_cache                  ? cache_read_data :
                             uncached_instruction_read  ? i_wb_read_data  :
                             uncached_instruction_read  ? wb_rdata32      :
                                                          32'hffeeddcc    ;
                                                          32'hffeeddcc    ;
 
 
// Stall the instruction decode and execute stages of the core
// Stall the instruction decode and execute stages of the core
// when the fetch stage needs more than 1 cycle to return the requested
// when the fetch stage needs more than 1 cycle to return the requested
// read data
// read data
assign o_fetch_stall    = !i_system_rdy || wait_wb || cache_stall;
assign o_fetch_stall    = !i_system_rdy || wait_wb || cache_stall;
 
 
assign o_wb_address     = i_iaddress;
assign o_wb_address     = i_iaddress;
assign o_wb_req         = icache_wb_req || uncached_instruction_read;
assign o_wb_req         = icache_wb_req || uncached_instruction_read;
assign o_wb_qword       = icache_wb_req;
 
 
 
assign wait_wb          = (o_wb_req || wb_req_r) && !i_wb_ready;
assign wait_wb          = (o_wb_req || wb_req_r) && !i_wb_ready;
 
 
always @(posedge i_clk)
always @(posedge i_clk)
    wb_req_r <= o_wb_req && !i_wb_ready;
    wb_req_r <= o_wb_req && !i_wb_ready;
 
 
assign core_stall = o_fetch_stall || i_mem_stall || i_conflict;
assign core_stall = o_fetch_stall || i_mem_stall || i_exec_stall || i_conflict;
 
 
// ======================================
// ======================================
// L1 Instruction Cache
// L1 Instruction Cache
// ======================================
// ======================================
a25_icache u_cache (
a25_icache u_cache (
Line 123... Line 135...
    .i_select                   ( sel_cache             ),
    .i_select                   ( sel_cache             ),
    .i_address                  ( i_iaddress            ),
    .i_address                  ( i_iaddress            ),
    .i_address_nxt              ( i_iaddress_nxt        ),
    .i_address_nxt              ( i_iaddress_nxt        ),
    .i_cache_enable             ( i_cache_enable        ),
    .i_cache_enable             ( i_cache_enable        ),
    .i_cache_flush              ( i_cache_flush         ),
    .i_cache_flush              ( i_cache_flush         ),
    .o_read_data                ( cache_read_data       ),
    .o_read_data                ( cache_read_data128    ),
 
 
    .o_wb_req                   ( icache_wb_req         ),
    .o_wb_req                   ( icache_wb_req         ),
    .i_wb_read_data             ( i_wb_read_data        ),
    .i_wb_read_data             ( i_wb_read_data        ),
    .i_wb_ready                 ( i_wb_ready            )
    .i_wb_ready                 ( i_wb_ready            )
);
);

powered by: WebSVN 2.1.0

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