diff --git a/timing/rob/rob.go b/timing/rob/rob.go index 3d0e41db..da97b6b4 100644 --- a/timing/rob/rob.go +++ b/timing/rob/rob.go @@ -42,6 +42,10 @@ func (b *ReorderBuffer) getTaskID() string { return "" } +func (rob *ReorderBuffer) CurrentTime() sim.VTimeInSec { + return rob.Engine.CurrentTime() +} + func (b *ReorderBuffer) AddHook(pos *sim.HookPos, hook sim.Hook) { if b.hooks == nil { b.hooks = make(map[*sim.HookPos][]sim.Hook) diff --git a/timing/rob/rob_test.go b/timing/rob/rob_test.go index d6cfda19..143b2aa5 100644 --- a/timing/rob/rob_test.go +++ b/timing/rob/rob_test.go @@ -8,6 +8,7 @@ import ( "github.com/sarchlab/akita/v4/mem/mem" "github.com/sarchlab/akita/v4/sim" "github.com/sarchlab/akita/v4/tracing" + "github.com/sarchlab/akita/v4/datarecording" ) type myHook struct { @@ -18,6 +19,22 @@ func (h *myHook) Func(ctx sim.HookCtx) { h.f(ctx) } +type sqliteTracerBackend struct { + backend *datarecording.SQLiteWriter +} + +func (b *sqliteTracerBackend) Write(task tracing.Task) { + b.backend.InsertData("tasks", task) +} + +func (b *sqliteTracerBackend) WriteMilestone(milestone tracing.Milestone) { + b.backend.InsertData("milestones", milestone) +} + +func (b *sqliteTracerBackend) Flush() { + b.backend.Flush() +} + var _ = Describe("Reorder Buffer", func() { var ( mockCtrl *gomock.Controller @@ -33,9 +50,10 @@ var _ = Describe("Reorder Buffer", func() { topPort = NewMockPort(mockCtrl) bottomPort = NewMockPort(mockCtrl) ctrlPort = NewMockPort(mockCtrl) - + engine := sim.NewSerialEngine() rob = MakeBuilder(). WithBufferSize(10). + WithEngine(engine). Build("ROB") rob.topPort = topPort rob.bottomPort = bottomPort @@ -44,11 +62,16 @@ var _ = Describe("Reorder Buffer", func() { rob.AddHook(tracing.HookPosMilestone, &myHook{ f: func(ctx sim.HookCtx) { milestone := ctx.Item.(tracing.Milestone) - fmt.Printf("Milestone in test: ID=%s, TaskID=%s, Category=%s, Reason=%s, Location=%s\n", - milestone.ID, milestone.TaskID, milestone.BlockingCategory, milestone.BlockingReason, milestone.BlockingLocation) + fmt.Printf("Milestone in test: ID=%s, TaskID=%s, Category=%s, Reason=%s, Location=%s, Time=%f\n", + milestone.ID, + milestone.TaskID, + milestone.BlockingCategory, + milestone.BlockingReason, + milestone.BlockingLocation, + milestone.Time) }, }) - + rob.TickLater() }) AfterEach(func() {