/*************************************************************************************** * Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences * Copyright (c) 2020-2021 Peng Cheng Laboratory * * XiangShan is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * * See the Mulan PSL v2 for more details. ***************************************************************************************/ package xiangshan.mem import chipsalliance.rocketchip.config.Parameters import chisel3._ import chisel3.util._ import xiangshan._ import utils._ import xiangshan.backend.roq.RoqPtr import xiangshan.cache._ import xiangshan.backend.fu.FenceToSbuffer object genWmask { def apply(addr: UInt, sizeEncode: UInt): UInt = { (LookupTree(sizeEncode, List( "b00".U -> 0x1.U, //0001 << addr(2:0) "b01".U -> 0x3.U, //0011 "b10".U -> 0xf.U, //1111 "b11".U -> 0xff.U //11111111 )) << addr(2, 0)).asUInt() } } object genWdata { def apply(data: UInt, sizeEncode: UInt): UInt = { LookupTree(sizeEncode, List( "b00".U -> Fill(8, data(7, 0)), "b01".U -> Fill(4, data(15, 0)), "b10".U -> Fill(2, data(31, 0)), "b11".U -> data )) } } class LsPipelineBundle(implicit p: Parameters) extends XSBundle { val vaddr = UInt(VAddrBits.W) val paddr = UInt(PAddrBits.W) val func = UInt(6.W) //fixme??? val mask = UInt(8.W) val data = UInt((XLEN+1).W) val uop = new MicroOp val miss = Bool() val tlbMiss = Bool() val ptwBack = Bool() val mmio = Bool() val rsIdx = UInt(log2Up(IssQueSize).W) val forwardMask = Vec(8, Bool()) val forwardData = Vec(8, UInt(8.W)) // For debug usage val isFirstIssue = Bool() } class StoreDataBundle(implicit p: Parameters) extends XSBundle { val data = UInt((XLEN+1).W) val uop = new MicroOp } class LoadForwardQueryIO(implicit p: Parameters) extends XSBundle { val vaddr = Output(UInt(VAddrBits.W)) val paddr = Output(UInt(PAddrBits.W)) val mask = Output(UInt(8.W)) val uop = Output(new MicroOp) // for replay val pc = Output(UInt(VAddrBits.W)) //for debug val valid = Output(Bool()) //for debug val forwardMaskFast = Input(Vec(8, Bool())) // resp to load_s1 val forwardMask = Input(Vec(8, Bool())) // resp to load_s2 val forwardData = Input(Vec(8, UInt(8.W))) // resp to load_s2 // val lqIdx = Output(UInt(LoadQueueIdxWidth.W)) val sqIdx = Output(new SqPtr) // dataInvalid suggests store to load forward found forward should happen, // but data is not available for now. If dataInvalid, load inst should // be replayed from RS. Feedback type should be RSFeedbackType.dataInvalid val dataInvalid = Input(Bool()) // Addr match, but data is not valid for now // matchInvalid suggests in store to load forward logic, paddr cam result does // to equal to vaddr cam result. If matchInvalid, a microarchitectural exception // should be raised to flush SQ and committed sbuffer. val matchInvalid = Input(Bool()) // resp to load_s2 } // LoadForwardQueryIO used in load pipeline // // Difference between PipeLoadForwardQueryIO and LoadForwardQueryIO: // PipeIO use predecoded sqIdxMask for better forward timing class PipeLoadForwardQueryIO(implicit p: Parameters) extends LoadForwardQueryIO { // val sqIdx = Output(new SqPtr) // for debug, should not be used in pipeline for timing reasons // sqIdxMask is calcuated in earlier stage for better timing val sqIdxMask = Output(UInt(StoreQueueSize.W)) // dataInvalid: addr match, but data is not valid for now val dataInvalidFast = Input(Bool()) // resp to load_s1 // val dataInvalid = Input(Bool()) // resp to load_s2 }