annotate core/src/Trace.bsv @ 23:90197e3375e2 pygar svn.24

[svn r24] added testing, but something is wrong with our c++ file.
author rlm
date Wed, 28 Apr 2010 08:19:09 -0400
parents 91a1f76ddd62
children
rev   line source
punk@1 1
punk@1 2 import ClientServer::*;
punk@1 3 import GetPut::*;
punk@1 4
punk@1 5 //----------------------------------------------------------------------
punk@1 6 // ToString typeclass
punk@1 7 //----------------------------------------------------------------------
punk@1 8
punk@1 9 typeclass Traceable#( type item_t );
punk@1 10 function Action traceTiny( String loc, String traceTag, item_t item );
punk@1 11 function Action traceFull( String loc, String traceTag, item_t item );
punk@1 12 endtypeclass
punk@1 13
punk@1 14 instance Traceable#(String);
punk@1 15
punk@1 16 function Action traceTiny( String loc, String ttag, String str );
punk@1 17 $fdisplay(stderr, " => %s:%s %s", loc, ttag, str );
punk@1 18 endfunction
punk@1 19
punk@1 20 function Action traceFull( String loc, String ttag, String str );
punk@1 21 $fdisplay(stderr, " => %s:%s %s", loc, ttag, str );
punk@1 22 endfunction
punk@1 23
punk@1 24 endinstance
punk@1 25
punk@1 26 instance Traceable#(Bit#(n));
punk@1 27
punk@1 28 function Action traceTiny( String loc, String ttag, Bit#(n) b );
punk@1 29 $fdisplay(stderr, " => %s:%s %x", loc, ttag, b );
punk@1 30 endfunction
punk@1 31
punk@1 32 function Action traceFull( String loc, String ttag, Bit#(n) b );
punk@1 33 $fdisplay(stderr, " => %s:%s %x", loc, ttag, b );
punk@1 34 endfunction
punk@1 35
punk@1 36 endinstance
punk@1 37
punk@1 38 //----------------------------------------------------------------------
punk@1 39 // Tracing interface wrappers
punk@1 40 //----------------------------------------------------------------------
punk@1 41
punk@1 42 function Get#(item_t) traceGet( String locStr, String tagStr, Get#(item_t) g )
punk@1 43 provisos ( Traceable#(item_t) );
punk@1 44 return
punk@1 45 (
punk@1 46 interface Get
punk@1 47 method ActionValue#(item_t) get();
punk@1 48 item_t item <- g.get();
punk@1 49 traceTiny(locStr, tagStr,item);
punk@1 50 return item;
punk@1 51 endmethod
punk@1 52 endinterface
punk@1 53 );
punk@1 54 endfunction
punk@1 55
punk@1 56 function Put#(item_t) tracePut( String locStr, String tagStr, Put#(item_t) p )
punk@1 57 provisos ( Traceable#(item_t) );
punk@1 58 return
punk@1 59 (
punk@1 60 interface Put
punk@1 61 method Action put( item_t item );
punk@1 62 traceTiny(locStr, tagStr,item);
punk@1 63 p.put(item);
punk@1 64 endmethod
punk@1 65 endinterface
punk@1 66 );
punk@1 67 endfunction
punk@1 68
punk@1 69 function Client#(req_t,resp_t) traceClient( String locStr, String reqTagStr, String respTagStr,
punk@1 70 Client#(req_t,resp_t) c )
punk@1 71 provisos ( Traceable#(req_t), Traceable#(resp_t) );
punk@1 72 return
punk@1 73 (
punk@1 74 interface Client
punk@1 75 interface Get request = traceGet(locStr, reqTagStr,c.request);
punk@1 76 interface Put response = tracePut(locStr, respTagStr,c.response);
punk@1 77 endinterface
punk@1 78 );
punk@1 79 endfunction
punk@1 80
punk@1 81 function Server#(req_t,resp_t) traceServer( String locStr, String reqTagStr, String respTagStr,
punk@1 82 Server#(req_t,resp_t) c )
punk@1 83 provisos ( Traceable#(req_t), Traceable#(resp_t) );
punk@1 84 return
punk@1 85 (
punk@1 86 interface Server
punk@1 87 interface Put request = tracePut(locStr, reqTagStr,c.request);
punk@1 88 interface Get response = traceGet(locStr, respTagStr,c.response);
punk@1 89 endinterface
punk@1 90 );
punk@1 91 endfunction
punk@1 92