Mercurial > pygar
comparison modules/bluespec/Pygar/lab4/Trace.bsv @ 8:74716e9a81cc pygar svn.9
[svn r9] Pygar now has the proper directory structure to play nicely with awb. Also, the apm file for audio-core willcompile successfully.
author | rlm |
---|---|
date | Fri, 23 Apr 2010 02:32:05 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:7393cd19371e | 8:74716e9a81cc |
---|---|
1 | |
2 import ClientServer::*; | |
3 import GetPut::*; | |
4 | |
5 //---------------------------------------------------------------------- | |
6 // ToString typeclass | |
7 //---------------------------------------------------------------------- | |
8 | |
9 typeclass Traceable#( type item_t ); | |
10 function Action traceTiny( String loc, String traceTag, item_t item ); | |
11 function Action traceFull( String loc, String traceTag, item_t item ); | |
12 endtypeclass | |
13 | |
14 instance Traceable#(String); | |
15 | |
16 function Action traceTiny( String loc, String ttag, String str ); | |
17 $fdisplay(stderr, " => %s:%s %s", loc, ttag, str ); | |
18 endfunction | |
19 | |
20 function Action traceFull( String loc, String ttag, String str ); | |
21 $fdisplay(stderr, " => %s:%s %s", loc, ttag, str ); | |
22 endfunction | |
23 | |
24 endinstance | |
25 | |
26 instance Traceable#(Bit#(n)); | |
27 | |
28 function Action traceTiny( String loc, String ttag, Bit#(n) b ); | |
29 $fdisplay(stderr, " => %s:%s %x", loc, ttag, b ); | |
30 endfunction | |
31 | |
32 function Action traceFull( String loc, String ttag, Bit#(n) b ); | |
33 $fdisplay(stderr, " => %s:%s %x", loc, ttag, b ); | |
34 endfunction | |
35 | |
36 endinstance | |
37 | |
38 //---------------------------------------------------------------------- | |
39 // Tracing interface wrappers | |
40 //---------------------------------------------------------------------- | |
41 | |
42 function Get#(item_t) traceGet( String locStr, String tagStr, Get#(item_t) g ) | |
43 provisos ( Traceable#(item_t) ); | |
44 return | |
45 ( | |
46 interface Get | |
47 method ActionValue#(item_t) get(); | |
48 item_t item <- g.get(); | |
49 traceTiny(locStr, tagStr,item); | |
50 return item; | |
51 endmethod | |
52 endinterface | |
53 ); | |
54 endfunction | |
55 | |
56 function Put#(item_t) tracePut( String locStr, String tagStr, Put#(item_t) p ) | |
57 provisos ( Traceable#(item_t) ); | |
58 return | |
59 ( | |
60 interface Put | |
61 method Action put( item_t item ); | |
62 traceTiny(locStr, tagStr,item); | |
63 p.put(item); | |
64 endmethod | |
65 endinterface | |
66 ); | |
67 endfunction | |
68 | |
69 function Client#(req_t,resp_t) traceClient( String locStr, String reqTagStr, String respTagStr, | |
70 Client#(req_t,resp_t) c ) | |
71 provisos ( Traceable#(req_t), Traceable#(resp_t) ); | |
72 return | |
73 ( | |
74 interface Client | |
75 interface Get request = traceGet(locStr, reqTagStr,c.request); | |
76 interface Put response = tracePut(locStr, respTagStr,c.response); | |
77 endinterface | |
78 ); | |
79 endfunction | |
80 | |
81 function Server#(req_t,resp_t) traceServer( String locStr, String reqTagStr, String respTagStr, | |
82 Server#(req_t,resp_t) c ) | |
83 provisos ( Traceable#(req_t), Traceable#(resp_t) ); | |
84 return | |
85 ( | |
86 interface Server | |
87 interface Put request = tracePut(locStr, reqTagStr,c.request); | |
88 interface Get response = traceGet(locStr, respTagStr,c.response); | |
89 endinterface | |
90 ); | |
91 endfunction | |
92 |