diff modules/bluespec/Pygar/core/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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/bluespec/Pygar/core/Trace.bsv	Fri Apr 23 02:32:05 2010 -0400
     1.3 @@ -0,0 +1,92 @@
     1.4 +
     1.5 +import ClientServer::*;
     1.6 +import GetPut::*;
     1.7 +
     1.8 +//----------------------------------------------------------------------
     1.9 +// ToString typeclass
    1.10 +//----------------------------------------------------------------------
    1.11 +
    1.12 +typeclass Traceable#( type item_t );
    1.13 +  function Action traceTiny( String loc, String traceTag, item_t item );
    1.14 +  function Action traceFull( String loc, String traceTag, item_t item );
    1.15 +endtypeclass
    1.16 +
    1.17 +instance Traceable#(String);
    1.18 +
    1.19 +  function Action traceTiny( String loc, String ttag, String str );
    1.20 +    $fdisplay(stderr,  " => %s:%s %s", loc, ttag, str );
    1.21 +  endfunction
    1.22 +
    1.23 +  function Action traceFull( String loc, String ttag, String str );
    1.24 +    $fdisplay(stderr,  " => %s:%s %s", loc, ttag, str );
    1.25 +  endfunction
    1.26 +
    1.27 +endinstance
    1.28 +
    1.29 +instance Traceable#(Bit#(n));
    1.30 +
    1.31 +  function Action traceTiny( String loc, String ttag, Bit#(n) b );
    1.32 +    $fdisplay(stderr,  " => %s:%s %x", loc, ttag, b );
    1.33 +  endfunction
    1.34 +
    1.35 +  function Action traceFull( String loc, String ttag, Bit#(n) b );
    1.36 +    $fdisplay(stderr,  " => %s:%s %x", loc, ttag, b );
    1.37 +  endfunction
    1.38 +
    1.39 +endinstance
    1.40 +
    1.41 +//----------------------------------------------------------------------
    1.42 +// Tracing interface wrappers
    1.43 +//----------------------------------------------------------------------
    1.44 +
    1.45 +function Get#(item_t) traceGet( String locStr, String tagStr, Get#(item_t) g )
    1.46 +                      provisos ( Traceable#(item_t) );
    1.47 +  return 
    1.48 +  (
    1.49 +    interface Get
    1.50 +      method ActionValue#(item_t) get();
    1.51 +        item_t item <- g.get();
    1.52 +        traceTiny(locStr, tagStr,item);
    1.53 +        return item;
    1.54 +      endmethod
    1.55 +    endinterface
    1.56 +  );
    1.57 +endfunction
    1.58 +
    1.59 +function Put#(item_t) tracePut( String locStr, String tagStr, Put#(item_t) p )
    1.60 +                      provisos ( Traceable#(item_t) );
    1.61 +  return 
    1.62 +  (
    1.63 +    interface Put
    1.64 +      method Action put( item_t item );
    1.65 +        traceTiny(locStr, tagStr,item);
    1.66 +        p.put(item);
    1.67 +      endmethod
    1.68 +    endinterface
    1.69 +  );
    1.70 +endfunction
    1.71 +
    1.72 +function Client#(req_t,resp_t) traceClient( String locStr, String reqTagStr, String respTagStr,
    1.73 +                                            Client#(req_t,resp_t) c )
    1.74 +                                  provisos ( Traceable#(req_t), Traceable#(resp_t) );
    1.75 +  return
    1.76 +  (
    1.77 +     interface Client
    1.78 +       interface Get request  = traceGet(locStr, reqTagStr,c.request);
    1.79 +       interface Put response = tracePut(locStr, respTagStr,c.response);
    1.80 +     endinterface
    1.81 +  );
    1.82 +endfunction
    1.83 +
    1.84 +function Server#(req_t,resp_t) traceServer( String locStr, String reqTagStr, String respTagStr,
    1.85 +                                            Server#(req_t,resp_t) c )
    1.86 +                                  provisos ( Traceable#(req_t), Traceable#(resp_t) );
    1.87 +  return
    1.88 +  (
    1.89 +     interface Server
    1.90 +       interface Put request  = tracePut(locStr, reqTagStr,c.request);
    1.91 +       interface Get response = traceGet(locStr, respTagStr,c.response);
    1.92 +     endinterface
    1.93 +  );
    1.94 +endfunction
    1.95 +