Mercurial > pygar
view modules/bluespec/Pygar/lab4/FIFOUtility.bsv @ 65:cf8bb3038cbd pygar svn.66
[svn r66] sim passes
author | punk |
---|---|
date | Tue, 11 May 2010 09:05:22 -0400 |
parents | 74716e9a81cc |
children |
line wrap: on
line source
1 import FIFO::*;2 import FIFOF::*;3 import Clocks::*;4 import GetPut::*;6 function FIFO#(fifo_type) guardedfifofToFifo( FIFOF#(fifo_type) fifo);8 FIFO#(fifo_type) f = interface FIFO#(fifo_type);9 method first = fifo.first;10 method enq = fifo.enq;11 method deq = fifo.deq;12 method clear = fifo.clear;13 endinterface;14 return f;15 endfunction17 function Get#(fifo_type) syncFifoToGet( SyncFIFOIfc#(fifo_type) fifo);18 Get#(fifo_type) f = interface Get#(fifo_type);19 method ActionValue#(fifo_type) get();20 fifo.deq;21 return fifo.first;22 endmethod23 endinterface;24 return f;25 endfunction27 function Put#(fifo_type) syncFifoToPut( SyncFIFOIfc#(fifo_type) fifo);28 Put#(fifo_type) f = interface Put#(fifo_type);29 method Action put(fifo_type data);30 fifo.enq(data);31 endmethod32 endinterface;33 return f;34 endfunction36 function String fifofState(FIFOF#(data) fifo);37 String s = "";39 if(!fifo.notEmpty)40 begin41 s = "Empty";42 end43 else if (!fifo.notFull)44 begin45 s = "Full";46 end47 else48 begin49 s = "Neither Empty Nor Full";50 end52 return s;53 endfunction