Mercurial > pygar
view modules/bluespec/Pygar/lab4/Trace.bsv @ 69:5c963ab14143 pygar svn.70
[svn r70] added an attempt at multi-fileing
author | punk |
---|---|
date | Wed, 12 May 2010 00:07:40 -0400 |
parents | 74716e9a81cc |
children |
line wrap: on
line source
2 import ClientServer::*;3 import GetPut::*;5 //----------------------------------------------------------------------6 // ToString typeclass7 //----------------------------------------------------------------------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 endtypeclass14 instance Traceable#(String);16 function Action traceTiny( String loc, String ttag, String str );17 $fdisplay(stderr, " => %s:%s %s", loc, ttag, str );18 endfunction20 function Action traceFull( String loc, String ttag, String str );21 $fdisplay(stderr, " => %s:%s %s", loc, ttag, str );22 endfunction24 endinstance26 instance Traceable#(Bit#(n));28 function Action traceTiny( String loc, String ttag, Bit#(n) b );29 $fdisplay(stderr, " => %s:%s %x", loc, ttag, b );30 endfunction32 function Action traceFull( String loc, String ttag, Bit#(n) b );33 $fdisplay(stderr, " => %s:%s %x", loc, ttag, b );34 endfunction36 endinstance38 //----------------------------------------------------------------------39 // Tracing interface wrappers40 //----------------------------------------------------------------------42 function Get#(item_t) traceGet( String locStr, String tagStr, Get#(item_t) g )43 provisos ( Traceable#(item_t) );44 return45 (46 interface Get47 method ActionValue#(item_t) get();48 item_t item <- g.get();49 traceTiny(locStr, tagStr,item);50 return item;51 endmethod52 endinterface53 );54 endfunction56 function Put#(item_t) tracePut( String locStr, String tagStr, Put#(item_t) p )57 provisos ( Traceable#(item_t) );58 return59 (60 interface Put61 method Action put( item_t item );62 traceTiny(locStr, tagStr,item);63 p.put(item);64 endmethod65 endinterface66 );67 endfunction69 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 return73 (74 interface Client75 interface Get request = traceGet(locStr, reqTagStr,c.request);76 interface Put response = tracePut(locStr, respTagStr,c.response);77 endinterface78 );79 endfunction81 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 return85 (86 interface Server87 interface Put request = tracePut(locStr, reqTagStr,c.request);88 interface Get response = traceGet(locStr, respTagStr,c.response);89 endinterface90 );91 endfunction