30.04.2013 Views

BSV by Example - Computation Structures Group

BSV by Example - Computation Structures Group

BSV by Example - Computation Structures Group

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

let y = pipe; // was let y = pipe.receive();<br />

Instead of providing the Pipe_ifc interface, the mkPipe module provides a standard register interface:<br />

module mkPipe (Reg#(int));<br />

The standard register interface provides the _write and _read methods instead of the send and<br />

receive methods in the previous example:<br />

method Action _write (int a); // was method Action send (int a);<br />

method int _read (); // was method int receive ();<br />

5.6 Using valid bits<br />

Source directory: rulesregs/validbits<br />

Source listing: Appendix A.4.5<br />

Let’s expand the previous example, adding Valid bits to deal with pipeline bubbles. The testbench<br />

module, mkTb is not changed at all; all changes are in the mkPipe module.<br />

In the mkPipe module, we instantiate 4 validn registers in addition to the xn registers:<br />

Reg#(Bool) valid1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!