annotate modules/bluespec/Pygar/lab4/Trace.bsv @ 73:0f86d486e38e pygar svn.74

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