annotate modules/bluespec/Pygar/lab4/GetPutExt.bsv @ 72:34fc182a1daa pygar svn.73

[svn r73] fixed bad code
author punk
date Wed, 12 May 2010 00:40:01 -0400
parents 74716e9a81cc
children
rev   line source
rlm@8 1 import FIFOF::*;
rlm@8 2 import RWire::*;
rlm@8 3 import GetPut::*;
rlm@8 4
rlm@8 5 // Convert a FIFOF into a put interface
rlm@8 6
rlm@8 7 function Put#(item_t) fifofToPut( FIFOF#(item_t) f ) provisos ( );
rlm@8 8 return
rlm@8 9 (
rlm@8 10 interface Put
rlm@8 11 method Action put( item_t item );
rlm@8 12 f.enq(item);
rlm@8 13 endmethod
rlm@8 14 endinterface
rlm@8 15 );
rlm@8 16 endfunction
rlm@8 17
rlm@8 18 // Convert a FIFOF into a get interface
rlm@8 19
rlm@8 20 function Get#(item_t) fifofToGet( FIFOF#(item_t) f ) provisos ( );
rlm@8 21 return
rlm@8 22 (
rlm@8 23 interface Get
rlm@8 24 method ActionValue#(item_t) get();
rlm@8 25 f.deq();
rlm@8 26 return f.first();
rlm@8 27 endmethod
rlm@8 28 endinterface
rlm@8 29 );
rlm@8 30 endfunction
rlm@8 31
rlm@8 32 // Convert a register into an (always ready) put interface
rlm@8 33
rlm@8 34 function Put#(item_t) regToPut( Reg#(item_t) r ) provisos ( );
rlm@8 35 return
rlm@8 36 (
rlm@8 37 interface Put
rlm@8 38 method Action put( item_t item );
rlm@8 39 r <= item;
rlm@8 40 endmethod
rlm@8 41 endinterface
rlm@8 42 );
rlm@8 43 endfunction
rlm@8 44
rlm@8 45 // Convert a register into an (always ready) get interface
rlm@8 46
rlm@8 47 function Get#(item_t) regToGet( Reg#(item_t) r ) provisos ( );
rlm@8 48 return
rlm@8 49 (
rlm@8 50 interface Get
rlm@8 51 method ActionValue#(item_t) get();
rlm@8 52 return r;
rlm@8 53 endmethod
rlm@8 54 endinterface
rlm@8 55 );
rlm@8 56 endfunction
rlm@8 57
rlm@8 58 // Convert a Wire into a put interface
rlm@8 59
rlm@8 60 function Put#(item_t) wireToPut( Wire#(item_t) w ) provisos ( );
rlm@8 61 return
rlm@8 62 (
rlm@8 63 interface Put
rlm@8 64 method Action put( item_t item );
rlm@8 65 w._write(item);
rlm@8 66 endmethod
rlm@8 67 endinterface
rlm@8 68 );
rlm@8 69 endfunction
rlm@8 70
rlm@8 71 // Convert a WIREF into a get interface
rlm@8 72
rlm@8 73 function Get#(item_t) wireToGet( Wire#(item_t) w ) provisos ( );
rlm@8 74 return
rlm@8 75 (
rlm@8 76 interface Get
rlm@8 77 method ActionValue#(item_t) get();
rlm@8 78 return w._read();
rlm@8 79 endmethod
rlm@8 80 endinterface
rlm@8 81 );
rlm@8 82 endfunction
rlm@8 83
rlm@8 84 // Convert a RWire into a put interface
rlm@8 85
rlm@8 86 function Put#(item_t) rwireToPut( RWire#(item_t) w ) provisos ( );
rlm@8 87 return
rlm@8 88 (
rlm@8 89 interface Put
rlm@8 90 method Action put( item_t item );
rlm@8 91 w.wset(item);
rlm@8 92 endmethod
rlm@8 93 endinterface
rlm@8 94 );
rlm@8 95 endfunction
rlm@8 96
rlm@8 97 // Convert a RWire into a get interface
rlm@8 98
rlm@8 99 function Get#(item_t) rwireToGet( RWire#(item_t) w ) provisos ( );
rlm@8 100 return
rlm@8 101 (
rlm@8 102 interface Get
rlm@8 103 method ActionValue#(item_t) get() if ( isValid(w.wget()) );
rlm@8 104 return unJust(w.wget());
rlm@8 105 endmethod
rlm@8 106 endinterface
rlm@8 107 );
rlm@8 108 endfunction