2021-04-22 19:34:02 +00:00
|
|
|
///////////////////////////////////////////
|
|
|
|
// pmachecker.sv
|
|
|
|
//
|
|
|
|
// Written: tfleming@hmc.edu & jtorrey@hmc.edu 20 April 2021
|
|
|
|
// Modified:
|
|
|
|
//
|
|
|
|
// Purpose: Examines all physical memory accesses and identifies attributes of
|
|
|
|
// the memory region accessed.
|
|
|
|
// Can report illegal accesses to the trap unit and cause a fault.
|
|
|
|
//
|
|
|
|
// A component of the Wally configurable RISC-V project.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
|
|
|
|
//
|
2022-01-07 12:58:40 +00:00
|
|
|
// MIT LICENSE
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
|
|
// software and associated documentation files (the "Software"), to deal in the Software
|
|
|
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
|
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
|
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
2021-04-22 19:34:02 +00:00
|
|
|
//
|
2022-01-07 12:58:40 +00:00
|
|
|
// The above copyright notice and this permission notice shall be included in all copies or
|
|
|
|
// substantial portions of the Software.
|
2021-04-22 19:34:02 +00:00
|
|
|
//
|
2022-01-07 12:58:40 +00:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
|
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
|
|
// OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
2021-04-22 19:34:02 +00:00
|
|
|
|
|
|
|
`include "wally-config.vh"
|
|
|
|
|
|
|
|
module pmachecker (
|
2021-06-08 17:39:32 +00:00
|
|
|
// input logic clk, reset, // *** unused in this module and all sub modules.
|
2021-04-29 06:20:39 +00:00
|
|
|
|
2021-06-21 05:27:02 +00:00
|
|
|
input logic [`PA_BITS-1:0] PhysicalAddress,
|
|
|
|
input logic [1:0] Size,
|
2021-06-08 17:39:32 +00:00
|
|
|
input logic AtomicAccessM, ExecuteAccessF, WriteAccessM, ReadAccessM, // *** atomicaccessM is unused but might want to stay in for future use.
|
2021-04-22 19:34:02 +00:00
|
|
|
output logic Cacheable, Idempotent, AtomicAllowed,
|
2021-04-29 06:20:39 +00:00
|
|
|
output logic PMAInstrAccessFaultF,
|
|
|
|
output logic PMALoadAccessFaultM,
|
|
|
|
output logic PMAStoreAccessFaultM
|
2021-04-22 19:34:02 +00:00
|
|
|
);
|
|
|
|
|
2021-06-17 20:28:06 +00:00
|
|
|
logic PMAAccessFault;
|
|
|
|
logic AccessRW, AccessRWX, AccessRX;
|
2021-11-17 18:47:19 +00:00
|
|
|
logic [8:0] SelRegions;
|
2021-04-22 19:34:02 +00:00
|
|
|
|
2021-06-17 20:28:06 +00:00
|
|
|
// Determine what type of access is being made
|
|
|
|
assign AccessRW = ReadAccessM | WriteAccessM;
|
|
|
|
assign AccessRWX = ReadAccessM | WriteAccessM | ExecuteAccessF;
|
|
|
|
assign AccessRX = ReadAccessM | ExecuteAccessF;
|
2021-04-22 19:34:02 +00:00
|
|
|
|
2021-06-17 20:28:06 +00:00
|
|
|
// Determine which region of physical memory (if any) is being accessed
|
2021-06-24 23:59:29 +00:00
|
|
|
adrdecs adrdecs(PhysicalAddress, AccessRW, AccessRX, AccessRWX, Size, SelRegions);
|
2021-06-17 20:28:06 +00:00
|
|
|
|
|
|
|
// Only RAM memory regions are cacheable
|
2021-11-17 18:47:19 +00:00
|
|
|
// *** Ross Thompson fix these. They should be part of adrdec
|
|
|
|
assign Cacheable = SelRegions[7] | SelRegions[6] | SelRegions[5];
|
|
|
|
assign Idempotent = SelRegions[7] | SelRegions[5];
|
|
|
|
assign AtomicAllowed = SelRegions[7] | SelRegions[5];
|
2021-04-22 19:34:02 +00:00
|
|
|
|
2021-06-17 22:54:39 +00:00
|
|
|
// Detect access faults
|
2021-11-17 18:47:19 +00:00
|
|
|
assign PMAAccessFault = SelRegions[8] & AccessRWX;
|
2022-01-02 21:47:21 +00:00
|
|
|
assign PMAInstrAccessFaultF = ExecuteAccessF & PMAAccessFault;
|
|
|
|
assign PMALoadAccessFaultM = ReadAccessM & PMAAccessFault;
|
|
|
|
assign PMAStoreAccessFaultM = WriteAccessM & PMAAccessFault;
|
2021-04-26 16:48:58 +00:00
|
|
|
endmodule
|
2021-07-02 18:56:49 +00:00
|
|
|
|