-
Notifications
You must be signed in to change notification settings - Fork 8
/
transaction.go
52 lines (41 loc) · 1.15 KB
/
transaction.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package signal
import "github.com/sarchlab/akita/v3/mem/mem"
// Transaction is the state associated with the processing of a read or write
// request.
type Transaction struct {
Read *mem.ReadReq
Write *mem.WriteReq
InternalAddress uint64
SubTransactions []*SubTransaction
}
// GlobalAddress returns the address that the transaction is accessing.
func (t *Transaction) GlobalAddress() uint64 {
if t.Read != nil {
return t.Read.Address
}
return t.Write.Address
}
// AccessByteSize returns the number of bytes that the transaction is accessing.
func (t *Transaction) AccessByteSize() uint64 {
if t.Read != nil {
return t.Read.AccessByteSize
}
return uint64(len(t.Write.Data))
}
// IsRead returns true if the transaction is a read transaction.
func (t *Transaction) IsRead() bool {
return t.Read != nil
}
// IsWrite returns true if the transaction is a write transaction.
func (t *Transaction) IsWrite() bool {
return t.Write != nil
}
// IsCompleted returns true if the transaction is fully ready to be returned.
func (t *Transaction) IsCompleted() bool {
for _, st := range t.SubTransactions {
if !st.Completed {
return false
}
}
return true
}