2 Copyright (c) 2013, IIT Madras
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
9 * Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 * Neither the name of IIT Madras nor the names of its contributors
15 may be used to endorse or promote products derived from this software
16 without specific prior written permission.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 -----------------------------------------------------------------------
32 // Copyright (c) 2017 Bluespec, Inc. All Rights Reserved
36 // ================================================================
37 // Separate interfaces for input-side and output-side of FIFOF.
38 // Conversion functions to these, from FIFOF interfaces.
40 // ================================================================
41 // BSV library imports
44 import Connectable :: *;
46 // ================================================================
47 // Semi-FIFOF interfaces
49 interface FIFOF_I #(type t);
50 method Action enq (t x);
51 method Bool notFull ();
54 interface FIFOF_O #(type t);
57 method Bool notEmpty ();
60 // ================================================================
61 // Converters from FIFOF
63 function FIFOF_I #(t) to_FIFOF_I (FIFOF #(t) f);
64 return interface FIFOF_I;
65 method enq (x) = f.enq (x);
66 method notFull = f.notFull;
70 function FIFOF_O #(t) to_FIFOF_O (FIFOF #(t) f);
71 return interface FIFOF_O;
72 method first = f.first;
74 method notEmpty = f.notEmpty;
78 // ================================================================
82 // FIFOF_O to a FIFOF_I
84 instance Connectable #(FIFOF_O #(t), FIFOF_I #(t));
85 module mkConnection #(FIFOF_O #(t) fo, FIFOF_I #(t) fi) (Empty);
96 instance Connectable #(FIFOF_O #(t), FIFOF #(t));
97 module mkConnection #(FIFOF_O #(t) fo, FIFOF #(t) fi) (Empty);
106 // FIFOF to a FIFOF_I
108 instance Connectable #(FIFOF #(t), FIFOF_I #(t));
109 module mkConnection #(FIFOF #(t) fo, FIFOF_I #(t) fi) (Empty);
117 // ================================================================
118 // Convenience function combining first/enq
120 function ActionValue #(t) pop_o (FIFOF_O #(t) f);
127 // ================================================================