@@ -2,6 +2,7 @@ package core
22
33import (
44 "fmt"
5+ "log/slog"
56
67 "github.com/sarchlab/akita/v4/sim"
78 "github.com/sarchlab/zeonica/cgra"
@@ -40,10 +41,18 @@ func (c *Core) GetMemory(x int, y int, addr uint32) uint32 {
4041
4142// write memory
4243func (c * Core ) WriteMemory (x int , y int , data uint32 , baseAddr uint32 ) {
43- fmt .Printf ("Core [%d][%d] receive WriteMemory(x=%d, y=%d)\n " , c .state .TileX , c .state .TileY , x , y )
44+ // fmt.Printf("Core [%d][%d] receive WriteMemory(x=%d, y=%d)\n", c.state.TileX, c.state.TileY, x, y)
4445 if x == int (c .state .TileX ) && y == int (c .state .TileY ) {
4546 c .state .Memory [baseAddr ] = data
46- fmt .Printf ("Core [%d][%d] write memory[%d] = %d\n " , c .state .TileX , c .state .TileY , baseAddr , c .state .Memory [baseAddr ])
47+ //fmt.Printf("Core [%d][%d] write memory[%d] = %d\n", c.state.TileX, c.state.TileY, baseAddr, c.state.Memory[baseAddr])
48+ Trace ("Memory" ,
49+ "Behavior" , "WriteMemory" ,
50+ "Time" , float64 (c .Engine .CurrentTime ()* 1e9 ),
51+ "Data" , data ,
52+ "X" , x ,
53+ "Y" , y ,
54+ "Addr" , baseAddr ,
55+ )
4756 } else {
4857 panic (fmt .Sprintf ("Invalid Tile: Expect (%d, %d),but get (%d, %d)" , c .state .TileX , c .state .TileY , x , y ))
4958 }
@@ -77,7 +86,7 @@ func (c *Core) Tick() (madeProgress bool) {
7786
7887func (c * Core ) doSend () bool {
7988 madeProgress := false
80- for i := 0 ; i < 4 ; i ++ {
89+ for i := 0 ; i < 12 ; i ++ {
8190 for color := 0 ; color < 4 ; color ++ {
8291
8392 if ! c .state .SendBufHeadBusy [color ][i ] {
@@ -97,11 +106,14 @@ func (c *Core) doSend() bool {
97106 continue
98107 }
99108
100- fmt .Printf ("%10f, %s, Send %d %s->%s, Color %d\n " ,
101- c .Engine .CurrentTime ()* 1e9 ,
102- c .Name (),
103- msg .Data , msg .Src , msg .Dst ,
104- color )
109+ Trace ("DataFlow" ,
110+ "Behavior" , "Send" ,
111+ slog .Float64 ("Time" , float64 (c .Engine .CurrentTime ()* 1e9 )),
112+ "Data" , msg .Data ,
113+ "Color" , color ,
114+ "Src" , msg .Src ,
115+ "Dst" , msg .Dst ,
116+ )
105117 c .state .SendBufHeadBusy [color ][i ] = false
106118 }
107119 }
@@ -111,7 +123,7 @@ func (c *Core) doSend() bool {
111123
112124func (c * Core ) doRecv () bool {
113125 madeProgress := false
114- for i := 0 ; i < 4 ; i ++ { //direction
126+ for i := 0 ; i < 12 ; i ++ { //direction
115127 item := c .ports [cgra .Side (i )].local .PeekIncoming ()
116128 if item == nil {
117129 continue
@@ -137,11 +149,14 @@ func (c *Core) doRecv() bool {
137149 c .state .RecvBufHeadReady [color ][i ] = true
138150 c .state .RecvBufHead [color ][i ] = msg .Data
139151
140- fmt .Printf ("%10f, %s, Recv %d %s->%s, Color %d\n " ,
141- c .Engine .CurrentTime ()* 1e9 ,
142- c .Name (),
143- msg .Data , msg .Src , msg .Dst ,
144- color )
152+ Trace ("DataFlow" ,
153+ "Behavior" , "Recv" ,
154+ "Time" , float64 (c .Engine .CurrentTime ()* 1e9 ),
155+ "Data" , msg .Data ,
156+ "Src" , msg .Src ,
157+ "Dst" , msg .Dst ,
158+ "Color" , color ,
159+ )
145160
146161 c .ports [cgra .Side (i )].local .RetrieveIncoming ()
147162 madeProgress = true
@@ -158,7 +173,7 @@ func (c *Core) runProgram() bool {
158173 }
159174 combInst := c .state .SelectedBlock .CombinedInsts [c .state .PCInBlock ]
160175
161- fmt .Printf ("%10f, %s, inst: %v inst_length: %d\n " , c .Engine .CurrentTime ()* 1e9 , c .Name (), combInst , len (combInst .Insts ))
176+ // fmt.Printf("%10f, %s, inst: %v inst_length: %d\n", c.Engine.CurrentTime()*1e9, c.Name(), combInst, len(combInst.Insts))
162177
163178 /* do not have label in codes
164179 for inst[len(inst)-1] == ':' {
@@ -174,7 +189,12 @@ func (c *Core) runProgram() bool {
174189 if prevPC == nextPC {
175190 return false
176191 }
177- fmt .Printf ("%10f, %s, Inst %v\n " , c .Engine .CurrentTime ()* 1e9 , c .Name (), combInst )
192+ Trace ("Inst" ,
193+ "Time" , float64 (c .Engine .CurrentTime ()* 1e9 ),
194+ "X" , c .state .TileX ,
195+ "Y" , c .state .TileY ,
196+ "CombinedInst" , combInst .String (),
197+ )
178198 //debug reg value
179199 //fmt.Printf("Core (%d, %d) Register values:\n", c.state.TileX, c.state.TileY)
180200 // for i, val := range c.state.Registers {
@@ -269,7 +289,7 @@ func (c *Core) Router(dst string, src string, color string) bool {
269289 c .state .SendBufHeadBusy [colorIndex ][dstIndex ] = true
270290 c .state .SendBufHead [colorIndex ][dstIndex ] = c .state .RecvBufHead [colorIndex ][srcIndex ]
271291 fmt .Printf ("%10f, %s, ROUTER %d %s->%s\n " ,
272- c .Engine .CurrentTime ()* 1e9 ,
292+ float64 ( c .Engine .CurrentTime ()* 1e9 ) ,
273293 c .Name (),
274294 c .state .RecvBufHead [colorIndex ][srcIndex ], c .Name (), dst )
275295 return true
@@ -282,7 +302,7 @@ func (c *Core) ConditionSend(dst string, src string, resister int, srcColor int,
282302}
283303
284304func (c * Core ) RouterSrcMustBeDirection (src string ) {
285- arr := []string {"NORTH" , "SOUTH" , "WEST" , "EAST" }
305+ arr := []string {"NORTH" , "SOUTH" , "WEST" , "EAST" , "SOUTHWEST" , "SOUTHEAST" , "NORTHWEST" , "NORTHEAST" , "ROUTER" }
286306 res := false
287307 for _ , s := range arr {
288308 if s == src {
@@ -308,6 +328,16 @@ func (c *Core) getIndex(side string) int {
308328 srcIndex = int (cgra .South )
309329 case "EAST" :
310330 srcIndex = int (cgra .East )
331+ case "NORTHEAST" :
332+ srcIndex = int (cgra .NorthEast )
333+ case "NORTHWEST" :
334+ srcIndex = int (cgra .NorthWest )
335+ case "SOUTHEAST" :
336+ srcIndex = int (cgra .SouthEast )
337+ case "SOUTHWEST" :
338+ srcIndex = int (cgra .SouthWest )
339+ case "ROUTER" :
340+ srcIndex = int (cgra .Router )
311341 // Adding new direction
312342 default :
313343 panic ("invalid side" )
0 commit comments