Learning BSV‎ > ‎Interfaces‎ > ‎

FIFO Interface Example

The interface definition for a FIFO-like device:

interface FIFO#(type any_t);
method any_t first() ;
method Action clear() ;
method Action enq( any_t data_in ) ;
method ActionValue#(any_t) deq() ;
endinterface: FIFO

A module which provides a FIFO interface:

module mkFIFO (FIFO#(some_t));
...
endmodule

To instantiate a module with a FIFO interface:

module mkNew
FIFO#(int) f1 <- mkFIFO
FIFO#(int) f2 <- mkFIFO
...
rule r1 (f1.first() > 8);
f2.enq (f1.first() + 2) ;
f1.deq();
endrule
endmodule


The diagram above shows the inputs and outputs generated, including the following handshaking signals:

  • RDY_first An output which indicates that the value is valid
  • RDY_clear An output which indicates that the clear method can (safely) be called.
  • EN_clear An input which triggers the clear method.
  • RDY_enq An output which indicates that the enq method can be called.
  • EN_enq An input which triggers the call to the enq method. Data is the value at data_in, and it is assumed (responsibility of the caller) that RDY_enq is asserted before this signal was asserted.
  • RDY_deq An output which indicates that action value method deq can be called.
  • EN_deq An input signal which triggers the action in deq

Comments