view modules/bluespec/Pygar/lab4/GetPutExt.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 source
1 import FIFOF::*;
2 import RWire::*;
3 import GetPut::*;
5 // Convert a FIFOF into a put interface
7 function Put#(item_t) fifofToPut( FIFOF#(item_t) f ) provisos ( );
8 return
9 (
10 interface Put
11 method Action put( item_t item );
12 f.enq(item);
13 endmethod
14 endinterface
15 );
16 endfunction
18 // Convert a FIFOF into a get interface
20 function Get#(item_t) fifofToGet( FIFOF#(item_t) f ) provisos ( );
21 return
22 (
23 interface Get
24 method ActionValue#(item_t) get();
25 f.deq();
26 return f.first();
27 endmethod
28 endinterface
29 );
30 endfunction
32 // Convert a register into an (always ready) put interface
34 function Put#(item_t) regToPut( Reg#(item_t) r ) provisos ( );
35 return
36 (
37 interface Put
38 method Action put( item_t item );
39 r <= item;
40 endmethod
41 endinterface
42 );
43 endfunction
45 // Convert a register into an (always ready) get interface
47 function Get#(item_t) regToGet( Reg#(item_t) r ) provisos ( );
48 return
49 (
50 interface Get
51 method ActionValue#(item_t) get();
52 return r;
53 endmethod
54 endinterface
55 );
56 endfunction
58 // Convert a Wire into a put interface
60 function Put#(item_t) wireToPut( Wire#(item_t) w ) provisos ( );
61 return
62 (
63 interface Put
64 method Action put( item_t item );
65 w._write(item);
66 endmethod
67 endinterface
68 );
69 endfunction
71 // Convert a WIREF into a get interface
73 function Get#(item_t) wireToGet( Wire#(item_t) w ) provisos ( );
74 return
75 (
76 interface Get
77 method ActionValue#(item_t) get();
78 return w._read();
79 endmethod
80 endinterface
81 );
82 endfunction
84 // Convert a RWire into a put interface
86 function Put#(item_t) rwireToPut( RWire#(item_t) w ) provisos ( );
87 return
88 (
89 interface Put
90 method Action put( item_t item );
91 w.wset(item);
92 endmethod
93 endinterface
94 );
95 endfunction
97 // Convert a RWire into a get interface
99 function Get#(item_t) rwireToGet( RWire#(item_t) w ) provisos ( );
100 return
101 (
102 interface Get
103 method ActionValue#(item_t) get() if ( isValid(w.wget()) );
104 return unJust(w.wget());
105 endmethod
106 endinterface
107 );
108 endfunction