Skip to content

Commit

Permalink
update noc with Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Mengyang He committed Jun 5, 2024
1 parent 706021b commit 4e89555
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
7 changes: 7 additions & 0 deletions noc/acceptance/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func (m *trafficMsg) Meta() *sim.MsgMeta {
return &m.MsgMeta
}

func (m *trafficMsg) Clone() sim.Msg {
cloneMsg := *m
cloneMsg.ID = sim.GetIDGenerator().Generate()

return &cloneMsg
}

// Test is a test case.
type Test struct {
agents []*Agent
Expand Down
10 changes: 10 additions & 0 deletions noc/messaging/flit.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ func (f *Flit) Meta() *sim.MsgMeta {
return &f.MsgMeta
}

// Clone returns cloned Flit with different ID
func (f *Flit) Clone() sim.Msg {
cloneMsg := *f
cloneMsg.ID = fmt.Sprintf("flit-%d-msg-%s-%s",
cloneMsg.SeqID, cloneMsg.Msg.Meta().ID,
sim.GetIDGenerator().Generate())

return &cloneMsg
}

// FlitBuilder can build flits
type FlitBuilder struct {
src, dst sim.Port
Expand Down
4 changes: 4 additions & 0 deletions noc/networking/arbitration/xbar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func (m *SampleMsg) Meta() *sim.MsgMeta {
return &m.MsgMeta
}

func (m *SampleMsg) Clone() sim.Msg {
return m
}

var _ = Describe("XBar", func() {
var (
mockCtrl *gomock.Controller
Expand Down
4 changes: 4 additions & 0 deletions noc/networking/switching/endpoint/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ func (m *sampleMsg) Meta() *sim.MsgMeta {
return &m.MsgMeta
}

func (m *sampleMsg) Clone() sim.Msg {
return m
}

var _ = Describe("End Point", func() {
var (
mockCtrl *gomock.Controller
Expand Down
4 changes: 4 additions & 0 deletions noc/networking/switching/switches/swtich_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func (m *sampleMsg) Meta() *sim.MsgMeta {
return &m.MsgMeta
}

func (m *sampleMsg) Clone() sim.Msg {
return m
}

var _ = Describe("Switch", func() {
var (
mockCtrl *gomock.Controller
Expand Down
5 changes: 5 additions & 0 deletions noc/standalone/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ func (m *TrafficMsg) Meta() *sim.MsgMeta {
return &m.MsgMeta
}

// Clone returns cloned TrafficMsg
func (m *TrafficMsg) Clone() sim.Msg {
return m
}

// NewTrafficMsg creates a new traffic message
func NewTrafficMsg(src, dst sim.Port, byteSize int) *TrafficMsg {
msg := new(TrafficMsg)
Expand Down
10 changes: 2 additions & 8 deletions sim/examples/ping/comp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ func (p *PingMsg) Meta() *sim.MsgMeta {
}

func (p *PingMsg) Clone() sim.Msg {
cloneMsg := *p
cloneMsg.ID = sim.GetIDGenerator().Generate()

return &cloneMsg
return p
}

type PingRsp struct {
Expand All @@ -36,10 +33,7 @@ func (p *PingRsp) Meta() *sim.MsgMeta {
}

func (p *PingRsp) Clone() sim.Msg {
cloneMsg := *p
cloneMsg.ID = sim.GetIDGenerator().Generate()

return &cloneMsg
return p
}

type StartPingEvent struct {
Expand Down

0 comments on commit 4e89555

Please sign in to comment.