Mercurial > pygar
annotate modules/bluespec/Pygar/lab4/FIFOUtility.bsv @ 68:44cc00df1168 pygar svn.69
[svn r69] runs separate eofs (I think)
author | punk |
---|---|
date | Wed, 12 May 2010 00:06:05 -0400 |
parents | 74716e9a81cc |
children |
rev | line source |
---|---|
rlm@8 | 1 import FIFO::*; |
rlm@8 | 2 import FIFOF::*; |
rlm@8 | 3 import Clocks::*; |
rlm@8 | 4 import GetPut::*; |
rlm@8 | 5 |
rlm@8 | 6 function FIFO#(fifo_type) guardedfifofToFifo( FIFOF#(fifo_type) fifo); |
rlm@8 | 7 |
rlm@8 | 8 FIFO#(fifo_type) f = interface FIFO#(fifo_type); |
rlm@8 | 9 method first = fifo.first; |
rlm@8 | 10 method enq = fifo.enq; |
rlm@8 | 11 method deq = fifo.deq; |
rlm@8 | 12 method clear = fifo.clear; |
rlm@8 | 13 endinterface; |
rlm@8 | 14 return f; |
rlm@8 | 15 endfunction |
rlm@8 | 16 |
rlm@8 | 17 function Get#(fifo_type) syncFifoToGet( SyncFIFOIfc#(fifo_type) fifo); |
rlm@8 | 18 Get#(fifo_type) f = interface Get#(fifo_type); |
rlm@8 | 19 method ActionValue#(fifo_type) get(); |
rlm@8 | 20 fifo.deq; |
rlm@8 | 21 return fifo.first; |
rlm@8 | 22 endmethod |
rlm@8 | 23 endinterface; |
rlm@8 | 24 return f; |
rlm@8 | 25 endfunction |
rlm@8 | 26 |
rlm@8 | 27 function Put#(fifo_type) syncFifoToPut( SyncFIFOIfc#(fifo_type) fifo); |
rlm@8 | 28 Put#(fifo_type) f = interface Put#(fifo_type); |
rlm@8 | 29 method Action put(fifo_type data); |
rlm@8 | 30 fifo.enq(data); |
rlm@8 | 31 endmethod |
rlm@8 | 32 endinterface; |
rlm@8 | 33 return f; |
rlm@8 | 34 endfunction |
rlm@8 | 35 |
rlm@8 | 36 function String fifofState(FIFOF#(data) fifo); |
rlm@8 | 37 String s = ""; |
rlm@8 | 38 |
rlm@8 | 39 if(!fifo.notEmpty) |
rlm@8 | 40 begin |
rlm@8 | 41 s = "Empty"; |
rlm@8 | 42 end |
rlm@8 | 43 else if (!fifo.notFull) |
rlm@8 | 44 begin |
rlm@8 | 45 s = "Full"; |
rlm@8 | 46 end |
rlm@8 | 47 else |
rlm@8 | 48 begin |
rlm@8 | 49 s = "Neither Empty Nor Full"; |
rlm@8 | 50 end |
rlm@8 | 51 |
rlm@8 | 52 return s; |
rlm@8 | 53 endfunction |
rlm@8 | 54 |