Mercurial > pygar
view modules/bluespec/Pygar/lab4/GetPutExt.bsv @ 36:99519a031813 pygar svn.37
[svn r37] moved the server into audioCorePipeline
author | punk |
---|---|
date | Tue, 04 May 2010 18:54:54 -0400 |
parents | 74716e9a81cc |
children |
line wrap: on
line source
1 import FIFOF::*;2 import RWire::*;3 import GetPut::*;5 // Convert a FIFOF into a put interface7 function Put#(item_t) fifofToPut( FIFOF#(item_t) f ) provisos ( );8 return9 (10 interface Put11 method Action put( item_t item );12 f.enq(item);13 endmethod14 endinterface15 );16 endfunction18 // Convert a FIFOF into a get interface20 function Get#(item_t) fifofToGet( FIFOF#(item_t) f ) provisos ( );21 return22 (23 interface Get24 method ActionValue#(item_t) get();25 f.deq();26 return f.first();27 endmethod28 endinterface29 );30 endfunction32 // Convert a register into an (always ready) put interface34 function Put#(item_t) regToPut( Reg#(item_t) r ) provisos ( );35 return36 (37 interface Put38 method Action put( item_t item );39 r <= item;40 endmethod41 endinterface42 );43 endfunction45 // Convert a register into an (always ready) get interface47 function Get#(item_t) regToGet( Reg#(item_t) r ) provisos ( );48 return49 (50 interface Get51 method ActionValue#(item_t) get();52 return r;53 endmethod54 endinterface55 );56 endfunction58 // Convert a Wire into a put interface60 function Put#(item_t) wireToPut( Wire#(item_t) w ) provisos ( );61 return62 (63 interface Put64 method Action put( item_t item );65 w._write(item);66 endmethod67 endinterface68 );69 endfunction71 // Convert a WIREF into a get interface73 function Get#(item_t) wireToGet( Wire#(item_t) w ) provisos ( );74 return75 (76 interface Get77 method ActionValue#(item_t) get();78 return w._read();79 endmethod80 endinterface81 );82 endfunction84 // Convert a RWire into a put interface86 function Put#(item_t) rwireToPut( RWire#(item_t) w ) provisos ( );87 return88 (89 interface Put90 method Action put( item_t item );91 w.wset(item);92 endmethod93 endinterface94 );95 endfunction97 // Convert a RWire into a get interface99 function Get#(item_t) rwireToGet( RWire#(item_t) w ) provisos ( );100 return101 (102 interface Get103 method ActionValue#(item_t) get() if ( isValid(w.wget()) );104 return unJust(w.wget());105 endmethod106 endinterface107 );108 endfunction