2022-08-31 17:35:57 +00:00
|
|
|
///////////////////////////////////////////
|
2023-04-14 04:02:15 +00:00
|
|
|
// controllerinput.sv
|
2022-08-31 17:35:57 +00:00
|
|
|
//
|
2024-10-15 15:27:53 +00:00
|
|
|
// Written: Rose Thompson rose@rosethompson.net
|
2023-01-18 23:14:37 +00:00
|
|
|
// Created: August 31, 2022
|
|
|
|
// Modified: 18 January 2023
|
2022-08-31 17:35:57 +00:00
|
|
|
//
|
2022-09-14 19:03:37 +00:00
|
|
|
// Purpose: AHB multi controller interface to merge LSU and IFU controls.
|
2022-08-31 17:35:57 +00:00
|
|
|
// See ARM_HIH0033A_AMBA_AHB-Lite_SPEC 1.0
|
|
|
|
// Arbitrates requests from instruction and data streams
|
|
|
|
// Connects core to peripherals and I/O pins on SOC
|
|
|
|
// Bus width presently matches XLEN
|
|
|
|
//
|
2024-06-14 10:42:15 +00:00
|
|
|
// Documentation: RISC-V System on Chip Design
|
2023-01-18 23:14:37 +00:00
|
|
|
//
|
2023-01-11 23:15:08 +00:00
|
|
|
// A component of the CORE-V-WALLY configurable RISC-V project.
|
2024-01-29 13:38:11 +00:00
|
|
|
// https://github.com/openhwgroup/cvw
|
2022-08-31 17:35:57 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University
|
2022-08-31 17:35:57 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
|
2022-08-31 17:35:57 +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 17:35:57 +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 17:35:57 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2023-03-24 22:57:02 +00:00
|
|
|
module controllerinput #(
|
2023-05-24 19:56:02 +00:00
|
|
|
parameter PA_BITS,
|
2023-01-18 23:14:37 +00:00
|
|
|
parameter SAVE_ENABLED = 1 // 1: Save manager inputs if Save = 1, 0: Don't save inputs
|
|
|
|
)(
|
2023-04-14 04:02:15 +00:00
|
|
|
input logic HCLK,
|
|
|
|
input logic HRESETn,
|
|
|
|
input logic Save, // Two or more managers requesting (HTRANS != 00) at the same time. Save the non-granted manager inputs
|
|
|
|
input logic Restore, // Restore a saved manager inputs when it is finally granted
|
|
|
|
input logic Disable, // Suppress HREADY to the non-granted manager
|
2023-03-24 20:01:38 +00:00
|
|
|
output logic Request, // This manager is making a request
|
2023-01-15 03:29:45 +00:00
|
|
|
// controller input
|
2023-04-14 04:02:15 +00:00
|
|
|
input logic [1:0] HTRANSIn, // Manager input. AHB transaction type, 00: IDLE, 10 NON_SEQ, 11 SEQ
|
|
|
|
input logic HWRITEIn, // Manager input. AHB 0: Read operation 1: Write operation
|
|
|
|
input logic [2:0] HSIZEIn, // Manager input. AHB transaction width
|
|
|
|
input logic [2:0] HBURSTIn, // Manager input. AHB burst length
|
2023-06-11 01:26:06 +00:00
|
|
|
input logic [PA_BITS-1:0] HADDRIn, // Manager input. AHB address
|
2023-04-14 04:02:15 +00:00
|
|
|
output logic HREADYOut, // Indicate to manager the peripheral is not busy and another manager does not have priority
|
2023-01-15 03:29:45 +00:00
|
|
|
// controller output
|
2023-04-14 04:02:15 +00:00
|
|
|
output logic [1:0] HTRANSOut, // Arbitrated manager transaction. AHB transaction type, 00: IDLE, 10 NON_SEQ, 11 SEQ
|
|
|
|
output logic HWRITEOut, // Arbitrated manager transaction. AHB 0: Read operation 1: Write operation
|
|
|
|
output logic [2:0] HSIZEOut, // Arbitrated manager transaction. AHB transaction width
|
|
|
|
output logic [2:0] HBURSTOut, // Arbitrated manager transaction. AHB burst length
|
2023-06-11 01:26:06 +00:00
|
|
|
output logic [PA_BITS-1:0] HADDROut, // Arbitrated manager transaction. AHB address
|
2023-04-14 04:02:15 +00:00
|
|
|
input logic HREADYIn // Peripheral ready
|
2023-01-15 03:29:45 +00:00
|
|
|
);
|
2022-08-31 17:35:57 +00:00
|
|
|
|
2023-01-15 03:29:45 +00:00
|
|
|
logic HWRITESave;
|
|
|
|
logic [2:0] HSIZESave;
|
|
|
|
logic [2:0] HBURSTSave;
|
|
|
|
logic [1:0] HTRANSSave;
|
2023-06-11 01:26:06 +00:00
|
|
|
logic [PA_BITS-1:0] HADDRSave;
|
2022-08-31 17:35:57 +00:00
|
|
|
|
2022-09-29 23:37:34 +00:00
|
|
|
if (SAVE_ENABLED) begin
|
2023-05-24 19:56:02 +00:00
|
|
|
flopenr #(1+3+3+2+PA_BITS) SaveReg(HCLK, ~HRESETn, Save,
|
2023-01-15 03:29:45 +00:00
|
|
|
{HWRITEIn, HSIZEIn, HBURSTIn, HTRANSIn, HADDRIn},
|
|
|
|
{HWRITESave, HSIZESave, HBURSTSave, HTRANSSave, HADDRSave});
|
2023-05-24 19:56:02 +00:00
|
|
|
mux2 #(1+3+3+2+PA_BITS) RestorMux({HWRITEIn, HSIZEIn, HBURSTIn, HTRANSIn, HADDRIn},
|
2023-01-15 03:29:45 +00:00
|
|
|
{HWRITESave, HSIZESave, HBURSTSave, HTRANSSave, HADDRSave},
|
|
|
|
Restore,
|
|
|
|
{HWRITEOut, HSIZEOut, HBURSTOut, HTRANSOut, HADDROut});
|
2022-09-29 23:37:34 +00:00
|
|
|
end else begin
|
|
|
|
assign HWRITEOut = HWRITEIn;
|
|
|
|
assign HSIZEOut = HSIZEIn;
|
|
|
|
assign HBURSTOut = HBURSTIn;
|
|
|
|
assign HTRANSOut = HTRANSIn;
|
|
|
|
assign HADDROut = HADDRIn;
|
|
|
|
end
|
2022-08-31 17:35:57 +00:00
|
|
|
|
2022-09-06 01:49:35 +00:00
|
|
|
assign Request = HTRANSOut != 2'b00;
|
2022-09-29 23:37:34 +00:00
|
|
|
assign HREADYOut = HREADYIn & ~Disable;
|
2022-08-31 17:35:57 +00:00
|
|
|
|
|
|
|
endmodule
|