Skip to content

Commit

Permalink
fixbugs
Browse files Browse the repository at this point in the history
  • Loading branch information
DX990307 committed Sep 16, 2024
1 parent 49d973a commit 12b9667
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion mem/idealmemcontroller/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ func (b Builder) Build(
Latency: b.latency,
width: b.width,
ctrlState: mem.Pause{
Enable: false,
Enable: true,
Drain: false,
Flush: false,
Invalid: false,
},
state: "enable",
}

c.TickingComponent = sim.NewTickingComponent(name, b.engine, b.freq, c)
Expand Down
16 changes: 11 additions & 5 deletions mem/idealmemcontroller/comp.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ type Comp struct {
func (c *Comp) Tick() bool {
madeProgress := false

// get ctrl msg from ctrl port
madeProgress = c.handleCtrlSignals() || madeProgress
madeProgress = c.updateInflightBuffer() || madeProgress
madeProgress = c.handleBehavior() || madeProgress
Expand Down Expand Up @@ -109,11 +108,15 @@ func (c *Comp) Handle(e sim.Event) error {

func (c *Comp) handleCtrlSignals() (madeProgress bool) {
for {
msg := c.CtrlPort.RetrieveIncoming()
msg := c.CtrlPort.PeekIncoming()
if msg == nil {
return madeProgress
}

if c.state == "drain" {
return madeProgress
}

signalMsg := msg.(*mem.ControlMsg)

if c.handleInvalidOrFlushSignal(signalMsg) {
Expand All @@ -131,6 +134,8 @@ func (c *Comp) handleCtrlSignals() (madeProgress bool) {
if c.handlePauseSignal(signalMsg) {
return true
}

c.CtrlPort.RetrieveIncoming()
}
}

Expand Down Expand Up @@ -193,12 +198,13 @@ func (c *Comp) handleInflightMemReqs() bool {
}

func (c *Comp) handleMemReqs() bool {
msg := c.inflightbuffer[0]
c.inflightbuffer = c.inflightbuffer[1:]
if msg == nil {
if len(c.inflightbuffer) == 0 {
return false
}

msg := c.inflightbuffer[0]
c.inflightbuffer = c.inflightbuffer[1:]

tracing.TraceReqReceive(msg, c)

switch msg := msg.(type) {
Expand Down
2 changes: 0 additions & 2 deletions mem/idealmemcontroller/idealmemcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ var _ = Describe("Ideal Memory Controller", func() {
Build()
port.EXPECT().RetrieveIncoming().Return(readReq)
ctrlPort.EXPECT().PeekIncoming().Return(nil)
ctrlPort.EXPECT().RetrieveIncoming().Return(nil)
engine.EXPECT().CurrentTime().Return(sim.VTimeInSec(10))

engine.EXPECT().
Expand All @@ -69,7 +68,6 @@ var _ = Describe("Ideal Memory Controller", func() {
Build()
port.EXPECT().RetrieveIncoming().Return(writeReq)
ctrlPort.EXPECT().PeekIncoming().Return(nil)
ctrlPort.EXPECT().RetrieveIncoming().Return(nil)
engine.EXPECT().CurrentTime().Return(sim.VTimeInSec(10))

engine.EXPECT().
Expand Down

0 comments on commit 12b9667

Please sign in to comment.