view modules/bluespec/Pygar/lab4/FIFOUtility.bsv @ 42:ced2ebd41347 pygar svn.43

[svn r43] bunch of updates that almost work...
author punk
date Wed, 05 May 2010 01:09:09 -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 endfunction
17 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 endmethod
23 endinterface;
24 return f;
25 endfunction
27 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 endmethod
32 endinterface;
33 return f;
34 endfunction
36 function String fifofState(FIFOF#(data) fifo);
37 String s = "";
39 if(!fifo.notEmpty)
40 begin
41 s = "Empty";
42 end
43 else if (!fifo.notFull)
44 begin
45 s = "Full";
46 end
47 else
48 begin
49 s = "Neither Empty Nor Full";
50 end
52 return s;
53 endfunction