xref: /XiangShan/src/main/scala/xiangshan/backend/fu/FunctionUnit.scala (revision 124bf66ab86a0eea8a5ebddde77457289668a0e7)
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
17package xiangshan.backend.fu
18
19import chipsalliance.rocketchip.config.Parameters
20import chisel3._
21import chisel3.util._
22import utils.XSPerfAccumulate
23import xiangshan._
24import xiangshan.backend.fu.fpu._
25
26trait HasFuLatency {
27  val latencyVal: Option[Int]
28}
29
30case class CertainLatency(value: Int) extends HasFuLatency {
31  override val latencyVal: Option[Int] = Some(value)
32}
33
34case class UncertainLatency() extends HasFuLatency {
35  override val latencyVal: Option[Int] = None
36}
37
38class FuOutput(val len: Int)(implicit p: Parameters) extends XSBundle {
39  val data = UInt(len.W)
40  val uop = new MicroOp
41}
42
43class FunctionUnitInput(val len: Int)(implicit p: Parameters) extends XSBundle {
44  val src = Vec(3, UInt(len.W))
45  val uop = new MicroOp
46}
47
48class FunctionUnitIO(val len: Int)(implicit p: Parameters) extends XSBundle {
49  val in = Flipped(DecoupledIO(new FunctionUnitInput(len)))
50
51  val out = DecoupledIO(new FuOutput(len))
52
53  val redirectIn = Flipped(ValidIO(new Redirect))
54}
55
56abstract class FunctionUnit(len: Int = 64)(implicit p: Parameters) extends XSModule {
57
58  val io = IO(new FunctionUnitIO(len))
59
60  XSPerfAccumulate("in_valid", io.in.valid)
61  XSPerfAccumulate("in_fire", io.in.fire)
62  XSPerfAccumulate("out_valid", io.out.valid)
63  XSPerfAccumulate("out_fire", io.out.fire)
64
65}
66