1/*************************************************************************************** 2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences 3* Copyright (c) 2020-2021 Peng Cheng Laboratory 4* 5* XiangShan is licensed under Mulan PSL v2. 6* You can use this software according to the terms and conditions of the Mulan PSL v2. 7* You may obtain a copy of Mulan PSL v2 at: 8* http://license.coscl.org.cn/MulanPSL2 9* 10* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13* 14* See the Mulan PSL v2 for more details. 15***************************************************************************************/ 16 17// See LICENSE.Berkeley for license details. 18 19package xiangshan.cache 20 21import chisel3._ 22import chisel3.util._ 23import xiangshan.XSBundle 24 25trait MemoryOpConstants { 26 val NUM_XA_OPS = 9 27 val M_SZ = 5 28 def M_X = BitPat("b?????") 29 def M_XRD = "b00000".U // int load 30 def M_XWR = "b00001".U // int store 31 def M_PFR = "b00010".U // prefetch with intent to read 32 def M_PFW = "b00011".U // prefetch with intent to write 33 def M_XA_SWAP = "b00100".U 34 def M_FLUSH_ALL = "b00101".U // flush all lines 35 def M_XLR = "b00110".U 36 def M_XSC = "b00111".U 37 def M_XA_ADD = "b01000".U 38 def M_XA_XOR = "b01001".U 39 def M_XA_OR = "b01010".U 40 def M_XA_AND = "b01011".U 41 def M_XA_MIN = "b01100".U 42 def M_XA_MAX = "b01101".U 43 def M_XA_MINU = "b01110".U 44 def M_XA_MAXU = "b01111".U 45 def M_FLUSH = "b10000".U // write back dirty data and cede R/W permissions 46 def M_PWR = "b10001".U // partial (masked.U store 47 def M_PRODUCE = "b10010".U // write back dirty data and cede W permissions 48 def M_CLEAN = "b10011".U // write back dirty data and retain R/W permissions 49 def M_SFENCE = "b10100".U // flush TLB 50 def M_WOK = "b10111".U // check write permissions but don't perform a write 51 def M_XA_CASQ = "b11000".U // AMOCAS.Q 52 def M_XA_CASW = "b11010".U // AMOCAS.W 53 def M_XA_CASD = "b11011".U // AMOCAS.D 54 55 def isAMOLogical(cmd: UInt) = cmd === M_XA_SWAP || cmd === M_XA_XOR || cmd === M_XA_OR || cmd === M_XA_AND 56 def isAMOArithmetic(cmd: UInt) = cmd === M_XA_ADD || cmd === M_XA_MIN || cmd === M_XA_MAX || cmd === M_XA_MINU || cmd === M_XA_MAXU 57 def isAMOCAS(cmd: UInt) = cmd === M_XA_CASW || cmd === M_XA_CASD || cmd === M_XA_CASQ 58 def isAMOCASQ(cmd: UInt) = cmd === M_XA_CASQ 59 def isAMO(cmd: UInt) = isAMOLogical(cmd) || isAMOArithmetic(cmd) || isAMOCAS(cmd) 60 def isPrefetch(cmd: UInt) = cmd === M_PFR || cmd === M_PFW 61 def isRead(cmd: UInt) = cmd === M_XRD || cmd === M_XLR || cmd === M_XSC || isAMO(cmd) 62 def isWrite(cmd: UInt) = cmd === M_XWR || cmd === M_PWR || cmd === M_XSC || isAMO(cmd) 63 def isWriteIntent(cmd: UInt) = isWrite(cmd) || cmd === M_PFW || cmd === M_XLR 64} 65 66object MemoryOpConstants extends MemoryOpConstants 67