Skip to content

Commit

Permalink
Merge pull request #91 from sarchlab/remove-now-VTimeInSec
Browse files Browse the repository at this point in the history
Remove now v time in sec
  • Loading branch information
syifan committed Apr 3, 2024
2 parents d52bb0e + ab691f2 commit fa81495
Show file tree
Hide file tree
Showing 153 changed files with 1,518 additions and 2,201 deletions.
17 changes: 9 additions & 8 deletions analysis/mock_sim_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mem/acceptancetests/dram/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func main() {
conn.PlugIn(agent.GetPortByName("Mem"), 16)
conn.PlugIn(memCtrl.GetPortByName("Top"), 1)

agent.TickLater(0)
agent.TickLater()

err := engine.Run()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion mem/acceptancetests/idealmemcontroller/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
conn.PlugIn(agent.GetPortByName("Mem"), 16)
conn.PlugIn(dram.GetPortByName("Top"), 16)

agent.TickLater(0)
agent.TickLater()

err := engine.Run()
if err != nil {
Expand Down
26 changes: 12 additions & 14 deletions mem/acceptancetests/memoryagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ func (a *MemAccessAgent) checkReadResult(
}

// Tick updates the states of the agent and issues new read and write requests.
func (a *MemAccessAgent) Tick(now sim.VTimeInSec) bool {
func (a *MemAccessAgent) Tick() bool {
madeProgress := false

madeProgress = a.processMsgRsp(now) || madeProgress
madeProgress = a.processMsgRsp() || madeProgress

if a.ReadLeft == 0 && a.WriteLeft == 0 {
return madeProgress
}

if a.shouldRead() {
madeProgress = a.doRead(now) || madeProgress
madeProgress = a.doRead() || madeProgress
} else {
madeProgress = a.doWrite(now) || madeProgress
madeProgress = a.doWrite() || madeProgress
}

return madeProgress
}

func (a *MemAccessAgent) processMsgRsp(now sim.VTimeInSec) bool {
msg := a.memPort.RetrieveIncoming(now)
func (a *MemAccessAgent) processMsgRsp() bool {
msg := a.memPort.RetrieveIncoming()
if msg == nil {
return false
}
Expand All @@ -82,7 +82,7 @@ func (a *MemAccessAgent) processMsgRsp(now sim.VTimeInSec) bool {
case *mem.WriteDoneRsp:
if dumpLog {
write := a.PendingWriteReq[msg.RespondTo]
log.Printf("%.10f, agent, write complete, 0x%X\n", now, write.Address)
log.Printf("%.10f, agent, write complete, 0x%X\n", a.CurrentTime(), write.Address)
}

delete(a.PendingWriteReq, msg.RespondTo)
Expand All @@ -93,7 +93,7 @@ func (a *MemAccessAgent) processMsgRsp(now sim.VTimeInSec) bool {

if dumpLog {
log.Printf("%.10f, agent, read complete, 0x%X, %v\n",
now, req.Address, msg.Data)
a.CurrentTime(), req.Address, msg.Data)
}

a.checkReadResult(req, msg)
Expand Down Expand Up @@ -122,7 +122,7 @@ func (a *MemAccessAgent) shouldRead() bool {
return dice > 0.5
}

func (a *MemAccessAgent) doRead(now sim.VTimeInSec) bool {
func (a *MemAccessAgent) doRead() bool {
address := a.randomReadAddress()

if a.isAddressInPendingReq(address) {
Expand All @@ -136,15 +136,14 @@ func (a *MemAccessAgent) doRead(now sim.VTimeInSec) bool {
WithByteSize(4).
WithPID(1).
Build()
readReq.SendTime = now

err := a.memPort.Send(readReq)
if err == nil {
a.PendingReadReq[readReq.ID] = readReq
a.ReadLeft--

if dumpLog {
log.Printf("%.10f, agent, read, 0x%X\n", now, address)
log.Printf("%.10f, agent, read, 0x%X\n", a.CurrentTime(), address)
}
return true
}
Expand Down Expand Up @@ -199,7 +198,7 @@ func bytesToUint32(data []byte) uint32 {
return a
}

func (a *MemAccessAgent) doWrite(now sim.VTimeInSec) bool {
func (a *MemAccessAgent) doWrite() bool {
address := rand.Uint64() % (a.MaxAddress / 4) * 4
data := rand.Uint32()

Expand All @@ -214,7 +213,6 @@ func (a *MemAccessAgent) doWrite(now sim.VTimeInSec) bool {
WithPID(1).
WithData(uint32ToBytes(data)).
Build()
writeReq.SendTime = now

err := a.memPort.Send(writeReq)
if err == nil {
Expand All @@ -224,7 +222,7 @@ func (a *MemAccessAgent) doWrite(now sim.VTimeInSec) bool {

if dumpLog {
log.Printf("%.10f, agent, write, 0x%X, %v\n",
now, address, writeReq.Data)
a.CurrentTime(), address, writeReq.Data)
}

return true
Expand Down
2 changes: 1 addition & 1 deletion mem/acceptancetests/writearoundcache/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func buildEnvironment() {
conn.PlugIn(writeevictCache.GetPortByName("Top"), 16)
conn.PlugIn(dram.GetPortByName("Top"), 16)

agent.TickLater(0)
agent.TickLater()
}

func runSimulation() {
Expand Down
2 changes: 1 addition & 1 deletion mem/acceptancetests/writebackcache/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func buildEnvironment() {
conn.PlugIn(writeBackCache.GetPortByName("Top"), 16)
conn.PlugIn(dram.GetPortByName("Top"), 16)

agent.TickLater(0)
agent.TickLater()
}

func runSimulation() {
Expand Down
2 changes: 1 addition & 1 deletion mem/acceptancetests/writeevictcache/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func buildEnvironment() {
conn.PlugIn(writeevictCache.GetPortByName("Top"), 16)
conn.PlugIn(dram.GetPortByName("Top"), 16)

agent.TickLater(0)
agent.TickLater()
}

func runSimulation() {
Expand Down
2 changes: 1 addition & 1 deletion mem/acceptancetests/writethroughcache/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func buildEnvironment() {
conn.PlugIn(writeevictCache.GetPortByName("Top"), 16)
conn.PlugIn(dram.GetPortByName("Top"), 16)

agent.TickLater(0)
agent.TickLater()
}

func runSimulation() {
Expand Down
38 changes: 0 additions & 38 deletions mem/cache/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@ func (r *FlushReq) Meta() *sim.MsgMeta {

// FlushReqBuilder can build flush requests.
type FlushReqBuilder struct {
sendTime sim.VTimeInSec
src, dst sim.Port
invalidateAllCacheLines bool
discardInflight bool
pauseAfterFlushing bool
}

// WithSendTime sets the send time of the message to build.
func (b FlushReqBuilder) WithSendTime(t sim.VTimeInSec) FlushReqBuilder {
b.sendTime = t
return b
}

// WithSrc sets the source of the message to build
func (b FlushReqBuilder) WithSrc(src sim.Port) FlushReqBuilder {
b.src = src
Expand Down Expand Up @@ -73,7 +66,6 @@ func (b FlushReqBuilder) Build() *FlushReq {
r.ID = sim.GetIDGenerator().Generate()
r.Src = b.src
r.Dst = b.dst
r.SendTime = b.sendTime
r.InvalidateAllCachelines = b.invalidateAllCacheLines
r.DiscardInflight = b.discardInflight
r.PauseAfterFlushing = b.pauseAfterFlushing
Expand All @@ -94,19 +86,10 @@ func (r *FlushRsp) Meta() *sim.MsgMeta {

// FlushRspBuilder can build data ready responds.
type FlushRspBuilder struct {
sendTime sim.VTimeInSec
src, dst sim.Port
rspTo string
}

// WithSendTime sets the send time of the message to build.
func (b FlushRspBuilder) WithSendTime(
t sim.VTimeInSec,
) FlushRspBuilder {
b.sendTime = t
return b
}

// WithSrc sets the source of the request to build.
func (b FlushRspBuilder) WithSrc(src sim.Port) FlushRspBuilder {
b.src = src
Expand All @@ -131,7 +114,6 @@ func (b FlushRspBuilder) Build() *FlushRsp {
r.ID = sim.GetIDGenerator().Generate()
r.Src = b.src
r.Dst = b.dst
r.SendTime = b.sendTime
r.RspTo = b.rspTo
return r
}
Expand All @@ -149,18 +131,9 @@ func (r *RestartReq) Meta() *sim.MsgMeta {

// RestartReqBuilder can build data ready responds.
type RestartReqBuilder struct {
sendTime sim.VTimeInSec
src, dst sim.Port
}

// WithSendTime sets the send time of the message to build.
func (b RestartReqBuilder) WithSendTime(
t sim.VTimeInSec,
) RestartReqBuilder {
b.sendTime = t
return b
}

// WithSrc sets the source of the request to build.
func (b RestartReqBuilder) WithSrc(src sim.Port) RestartReqBuilder {
b.src = src
Expand All @@ -179,7 +152,6 @@ func (b RestartReqBuilder) Build() *RestartReq {
r.ID = sim.GetIDGenerator().Generate()
r.Src = b.src
r.Dst = b.dst
r.SendTime = b.sendTime
return r
}

Expand All @@ -197,19 +169,10 @@ func (r *RestartRsp) Meta() *sim.MsgMeta {

// RestartRspBuilder can build data ready responds.
type RestartRspBuilder struct {
sendTime sim.VTimeInSec
src, dst sim.Port
rspTo string
}

// WithSendTime sets the send time of the message to build.
func (b RestartRspBuilder) WithSendTime(
t sim.VTimeInSec,
) RestartRspBuilder {
b.sendTime = t
return b
}

// WithSrc sets the source of the request to build.
func (b RestartRspBuilder) WithSrc(src sim.Port) RestartRspBuilder {
b.src = src
Expand All @@ -234,7 +197,6 @@ func (b RestartRspBuilder) Build() *RestartRsp {
r.ID = xid.New().String()
r.Src = b.src
r.Dst = b.dst
r.SendTime = b.sendTime
r.RspTo = b.rspTo
return r
}
Loading

0 comments on commit fa81495

Please sign in to comment.