Mercurial > pygar
comparison 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 |
comparison
equal
deleted
inserted
replaced
7:7393cd19371e | 8:74716e9a81cc |
---|---|
1 import FIFO::*; | |
2 import FIFOF::*; | |
3 import Clocks::*; | |
4 import GetPut::*; | |
5 | |
6 function FIFO#(fifo_type) guardedfifofToFifo( FIFOF#(fifo_type) fifo); | |
7 | |
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 | |
16 | |
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 | |
26 | |
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 | |
35 | |
36 function String fifofState(FIFOF#(data) fifo); | |
37 String s = ""; | |
38 | |
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 | |
51 | |
52 return s; | |
53 endfunction | |
54 |