Mercurial > pygar
diff modules/bluespec/Pygar/lab4/FIFOUtility.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/lab4/FIFOUtility.bsv Fri Apr 23 02:32:05 2010 -0400 1.3 @@ -0,0 +1,54 @@ 1.4 +import FIFO::*; 1.5 +import FIFOF::*; 1.6 +import Clocks::*; 1.7 +import GetPut::*; 1.8 + 1.9 +function FIFO#(fifo_type) guardedfifofToFifo( FIFOF#(fifo_type) fifo); 1.10 + 1.11 + FIFO#(fifo_type) f = interface FIFO#(fifo_type); 1.12 + method first = fifo.first; 1.13 + method enq = fifo.enq; 1.14 + method deq = fifo.deq; 1.15 + method clear = fifo.clear; 1.16 + endinterface; 1.17 + return f; 1.18 +endfunction 1.19 + 1.20 +function Get#(fifo_type) syncFifoToGet( SyncFIFOIfc#(fifo_type) fifo); 1.21 + Get#(fifo_type) f = interface Get#(fifo_type); 1.22 + method ActionValue#(fifo_type) get(); 1.23 + fifo.deq; 1.24 + return fifo.first; 1.25 + endmethod 1.26 + endinterface; 1.27 + return f; 1.28 +endfunction 1.29 + 1.30 +function Put#(fifo_type) syncFifoToPut( SyncFIFOIfc#(fifo_type) fifo); 1.31 + Put#(fifo_type) f = interface Put#(fifo_type); 1.32 + method Action put(fifo_type data); 1.33 + fifo.enq(data); 1.34 + endmethod 1.35 + endinterface; 1.36 + return f; 1.37 +endfunction 1.38 + 1.39 +function String fifofState(FIFOF#(data) fifo); 1.40 + String s = ""; 1.41 + 1.42 + if(!fifo.notEmpty) 1.43 + begin 1.44 + s = "Empty"; 1.45 + end 1.46 + else if (!fifo.notFull) 1.47 + begin 1.48 + s = "Full"; 1.49 + end 1.50 + else 1.51 + begin 1.52 + s = "Neither Empty Nor Full"; 1.53 + end 1.54 + 1.55 + return s; 1.56 +endfunction 1.57 +