Skip to content

Commit

Permalink
merge mem protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
DX990307 committed Oct 25, 2024
1 parent 7e562c6 commit d0d5818
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions mem/mem/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,13 @@ func (b WriteDoneRspBuilder) Build() *WriteDoneRsp {
type ControlMsg struct {
sim.MsgMeta

Enable bool
Drain bool
Flush bool
Invalid bool
Enable bool
Drain bool
Flush bool
Invalid bool
DiscardTransations bool
Restart bool
NotifyDone bool
}

// Meta returns the meta data associated with the ControlMsg.
Expand Down Expand Up @@ -439,11 +442,14 @@ func (m *ControlMsg) GenerateRsp() sim.Rsp {

// A ControlMsgBuilder can build control messages.
type ControlMsgBuilder struct {
src, dst sim.Port
Enable bool
Drain bool
Flush bool
Invalid bool
src, dst sim.Port
Enable bool
Drain bool
Flush bool
Invalid bool
discardTransactions bool
restart bool
notifyDone bool
}

// WithSrc sets the source of the request to build.
Expand All @@ -458,6 +464,25 @@ func (b ControlMsgBuilder) WithDst(dst sim.Port) ControlMsgBuilder {
return b
}

// ToDiscardTransactions sets the discard transactions bit of the control
// messages to 1.
func (b ControlMsgBuilder) ToDiscardTransactions() ControlMsgBuilder {
b.discardTransactions = true
return b
}

// ToRestart sets the restart bit of the control messages to 1.
func (b ControlMsgBuilder) ToRestart() ControlMsgBuilder {
b.restart = true
return b
}

// ToNotifyDone sets the "notify done" bit of the control messages to 1.
func (b ControlMsgBuilder) ToNotifyDone() ControlMsgBuilder {
b.notifyDone = true
return b
}

func (b ControlMsgBuilder) WithCtrlInfo(
enableFlag bool,
drainFlag bool,
Expand All @@ -484,6 +509,10 @@ func (b ControlMsgBuilder) Build() *ControlMsg {
m.Flush = b.Flush
m.Invalid = b.Invalid

m.DiscardTransations = b.discardTransactions
m.Restart = b.restart
m.NotifyDone = b.notifyDone

return m
}

Expand Down

0 comments on commit d0d5818

Please sign in to comment.