2022-08-31 19:45:01 +00:00
|
|
|
///////////////////////////////////////////
|
|
|
|
// ahbinterface.sv
|
|
|
|
//
|
|
|
|
// Written: Ross Thompson ross1728@gmail.com August 29, 2022
|
|
|
|
// Modified:
|
|
|
|
//
|
|
|
|
// Purpose: Cache/Bus data path.
|
|
|
|
// Bus Side logic
|
|
|
|
// register the fetch data from the next level of memory.
|
|
|
|
// This register should be necessary for timing. There is no register in the uncore or
|
|
|
|
// ahblite controller between the memories and this cache.
|
|
|
|
//
|
2023-01-11 22:03:44 +00:00
|
|
|
// A component of the CORE-V Wally configurable RISC-V project.
|
2022-08-31 19:45:01 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University
|
2022-08-31 19:45:01 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
|
2022-08-31 19:45:01 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file
|
|
|
|
// except in compliance with the License, or, at your option, the Apache License version 2.0. You
|
|
|
|
// may obtain a copy of the License at
|
2022-08-31 19:45:01 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// https://solderpad.org/licenses/SHL-2.1/
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, any work distributed under the
|
|
|
|
// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
|
|
// either express or implied. See the License for the specific language governing permissions
|
|
|
|
// and limitations under the License.
|
2022-08-31 19:45:01 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
`include "wally-config.vh"
|
|
|
|
|
2022-09-19 15:54:22 +00:00
|
|
|
module ahbinterface #(parameter LSU = 0) // **** modify to use LSU/ifu parameter to control widths of buses
|
2022-08-31 19:45:01 +00:00
|
|
|
(
|
|
|
|
input logic HCLK, HRESETn,
|
|
|
|
|
|
|
|
// bus interface
|
|
|
|
input logic HREADY,
|
|
|
|
input logic [`XLEN-1:0] HRDATA,
|
|
|
|
output logic [1:0] HTRANS,
|
|
|
|
output logic HWRITE,
|
|
|
|
output logic [`XLEN-1:0] HWDATA,
|
|
|
|
output logic [`XLEN/8-1:0] HWSTRB,
|
|
|
|
|
|
|
|
// lsu/ifu interface
|
2022-11-07 21:03:43 +00:00
|
|
|
input logic Flush,
|
2022-09-23 16:46:53 +00:00
|
|
|
input logic [1:0] BusRW,
|
2022-08-31 19:45:01 +00:00
|
|
|
input logic [`XLEN/8-1:0] ByteMask,
|
|
|
|
input logic [`XLEN-1:0] WriteData,
|
2022-12-11 21:51:35 +00:00
|
|
|
input logic Stall,
|
2022-08-31 19:45:01 +00:00
|
|
|
output logic BusStall,
|
|
|
|
output logic BusCommitted,
|
2022-09-28 22:39:51 +00:00
|
|
|
output logic [(LSU ? `XLEN : 32)-1:0] FetchBuffer);
|
2022-08-31 19:45:01 +00:00
|
|
|
|
|
|
|
logic CaptureEn;
|
|
|
|
|
2022-09-18 01:30:01 +00:00
|
|
|
/// *** only 32 bit for IFU.
|
2022-09-19 15:54:22 +00:00
|
|
|
localparam LEN = (LSU ? `XLEN : 32);
|
|
|
|
|
2022-09-28 22:39:51 +00:00
|
|
|
flopen #(LEN) fb(.clk(HCLK), .en(CaptureEn), .d(HRDATA[LEN-1:0]), .q(FetchBuffer));
|
2022-08-31 19:45:01 +00:00
|
|
|
|
2022-09-19 15:54:22 +00:00
|
|
|
if(LSU) begin
|
2022-08-31 19:45:01 +00:00
|
|
|
// delay HWDATA by 1 cycle per spec; *** assumes AHBW = XLEN
|
|
|
|
flop #(`XLEN) wdreg(HCLK, WriteData, HWDATA);
|
|
|
|
flop #(`XLEN/8) HWSTRBReg(HCLK, ByteMask, HWSTRB);
|
|
|
|
end else begin
|
|
|
|
assign HWDATA = '0;
|
|
|
|
assign HWSTRB = '0;
|
|
|
|
end
|
|
|
|
|
2022-11-07 21:03:43 +00:00
|
|
|
busfsm busfsm(.HCLK, .HRESETn, .Flush, .BusRW,
|
2022-12-11 21:51:35 +00:00
|
|
|
.BusCommitted, .Stall, .BusStall, .CaptureEn, .HREADY,
|
2022-08-31 19:45:01 +00:00
|
|
|
.HTRANS, .HWRITE);
|
|
|
|
endmodule
|