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+ package difftest
18+
19+ import chisel3 ._
20+ import chisel3 .util ._
21+ import Chisel .BlackBox
22+
23+ trait DifftestParameter {
24+ }
25+
26+ trait DifftestWithClock {
27+ val clock = Input (Clock ())
28+ }
29+
30+ trait DifftestWithCoreid {
31+ val coreid = Input (UInt (8 .W ))
32+ }
33+
34+ trait DifftestWithIndex {
35+ val index = Input (UInt (8 .W ))
36+ }
37+
38+ abstract class DifftestBundle extends Bundle
39+ with DifftestParameter
40+ with DifftestWithClock
41+ with DifftestWithCoreid
42+
43+ class DiffArchEventIO extends DifftestBundle {
44+ val intrNO = Input (UInt (32 .W ))
45+ val cause = Input (UInt (32 .W ))
46+ val exceptionPC = Input (UInt (64 .W ))
47+ val exceptionInst = Input (UInt (32 .W ))
48+ }
49+
50+ class DiffInstrCommitIO extends DifftestBundle with DifftestWithIndex {
51+ val valid = Input (Bool ())
52+ val pc = Input (UInt (64 .W ))
53+ val instr = Input (UInt (32 .W ))
54+ val special = Input (UInt (8 .W ))
55+ val skip = Input (Bool ())
56+ val isRVC = Input (Bool ())
57+ val scFailed = Input (Bool ())
58+ val wen = Input (Bool ())
59+ val wdata = Input (UInt (64 .W ))
60+ val wdest = Input (UInt (8 .W ))
61+ }
62+
63+ class DiffTrapEventIO extends DifftestBundle {
64+ val valid = Input (Bool ())
65+ val code = Input (UInt (3 .W ))
66+ val pc = Input (UInt (64 .W ))
67+ val cycleCnt = Input (UInt (64 .W ))
68+ val instrCnt = Input (UInt (64 .W ))
69+ }
70+
71+ class DiffCSRStateIO extends DifftestBundle {
72+ val priviledgeMode = Input (UInt (2 .W ))
73+ val mstatus = Input (UInt (64 .W ))
74+ val sstatus = Input (UInt (64 .W ))
75+ val mepc = Input (UInt (64 .W ))
76+ val sepc = Input (UInt (64 .W ))
77+ val mtval = Input (UInt (64 .W ))
78+ val stval = Input (UInt (64 .W ))
79+ val mtvec = Input (UInt (64 .W ))
80+ val stvec = Input (UInt (64 .W ))
81+ val mcause = Input (UInt (64 .W ))
82+ val scause = Input (UInt (64 .W ))
83+ val satp = Input (UInt (64 .W ))
84+ val mip = Input (UInt (64 .W ))
85+ val mie = Input (UInt (64 .W ))
86+ val mscratch = Input (UInt (64 .W ))
87+ val sscratch = Input (UInt (64 .W ))
88+ val mideleg = Input (UInt (64 .W ))
89+ val medeleg = Input (UInt (64 .W ))
90+ }
91+
92+ class DiffArchIntRegStateIO extends DifftestBundle {
93+ val gpr = Input (Vec (32 , UInt (64 .W )))
94+ }
95+
96+ class DiffArchFpRegStateIO extends DifftestBundle {
97+ val fpr = Input (Vec (32 , UInt (64 .W )))
98+ }
99+
100+ class DiffSbufferEventIO extends DifftestBundle {
101+ val sbufferResp = Input (Bool ())
102+ val sbufferAddr = Input (UInt (64 .W ))
103+ val sbufferData = Input (Vec (64 , UInt (8 .W )))
104+ val sbufferMask = Input (UInt (64 .W ))
105+ }
106+
107+ class DiffStoreEventIO extends DifftestBundle with DifftestWithIndex {
108+ val valid = Input (Bool ())
109+ val storeAddr = Input (UInt (64 .W ))
110+ val storeData = Input (UInt (64 .W ))
111+ val storeMask = Input (UInt (8 .W ))
112+ }
113+
114+ class DiffLoadEventIO extends DifftestBundle with DifftestWithIndex {
115+ val valid = Input (Bool ())
116+ val paddr = Input (UInt (64 .W ))
117+ val opType = Input (UInt (8 .W ))
118+ val fuType = Input (UInt (8 .W ))
119+ }
120+
121+ class DiffAtomicEventIO extends DifftestBundle {
122+ val atomicResp = Input (Bool ())
123+ val atomicAddr = Input (UInt (64 .W ))
124+ val atomicData = Input (UInt (64 .W ))
125+ val atomicMask = Input (UInt (8 .W ))
126+ val atomicFuop = Input (UInt (8 .W ))
127+ val atomicOut = Input (UInt (64 .W ))
128+ }
129+
130+ class DiffPtwEventIO extends DifftestBundle {
131+ val ptwResp = Input (Bool ())
132+ val ptwAddr = Input (UInt (64 .W ))
133+ val ptwData = Input (Vec (4 , UInt (64 .W )))
134+ }
135+
136+ class DiffRefillEventIO extends DifftestBundle {
137+ val valid = Input (Bool ())
138+ val addr = Input (UInt (64 .W ))
139+ val data = Input (Vec (8 , UInt (64 .W )))
140+ }
141+
142+ class DifftestArchEvent extends BlackBox {
143+ val io = IO (new DiffArchEventIO )
144+ }
145+
146+ class DifftestInstrCommit extends BlackBox {
147+ val io = IO (new DiffInstrCommitIO )
148+ }
149+
150+ class DifftestTrapEvent extends BlackBox {
151+ val io = IO (new DiffTrapEventIO )
152+ }
153+
154+ class DifftestCSRState extends BlackBox {
155+ val io = IO (new DiffCSRStateIO )
156+ }
157+
158+ class DifftestArchIntRegState extends BlackBox {
159+ val io = IO (new DiffArchIntRegStateIO )
160+ }
161+
162+ class DifftestArchFpRegState extends BlackBox {
163+ val io = IO (new DiffArchFpRegStateIO )
164+ }
165+
166+ class DifftestSbufferEvent extends BlackBox {
167+ val io = IO (new DiffSbufferEventIO )
168+ }
169+
170+ class DifftestStoreEvent extends BlackBox {
171+ val io = IO (new DiffStoreEventIO )
172+ }
173+
174+ class DifftestLoadEvent extends BlackBox {
175+ val io = IO (new DiffLoadEventIO )
176+ }
177+
178+ class DifftestAtomicEvent extends BlackBox {
179+ val io = IO (new DiffAtomicEventIO )
180+ }
181+
182+ class DifftestPtwEvent extends BlackBox {
183+ val io = IO (new DiffPtwEventIO )
184+ }
185+
186+ class DifftestRefillEvent extends BlackBox {
187+ val io = IO (new DiffRefillEventIO )
188+ }
189+
190+ // Difftest emulator top
191+
192+ // XiangShan log / perf ctrl, should be inited in SimTop IO
193+ // If not needed, just ingore these signals
194+ class PerfInfoIO extends Bundle {
195+ val clean = Input (Bool ())
196+ val dump = Input (Bool ())
197+ }
198+
199+ class LogCtrlIO extends Bundle {
200+ val log_begin, log_end = Input (UInt (64 .W ))
201+ val log_level = Input (UInt (64 .W )) // a cpp uint
202+ }
203+
204+ // UART IO, if needed, should be inited in SimTop IO
205+ // If not needed, just hardwire all output to 0
206+ class UARTIO extends Bundle {
207+ val out = new Bundle {
208+ val valid = Output (Bool ())
209+ val ch = Output (UInt (8 .W ))
210+ }
211+ val in = new Bundle {
212+ val valid = Output (Bool ())
213+ val ch = Input (UInt (8 .W ))
214+ }
215+ }
216+
217+ package object difftest {
218+
219+ }
0 commit comments