Skip to content

CTSRD-CHERI/BlueBasics

Repository files navigation

BlueBasics

The Source and Sink types are the most central types introduced by BlueBasics. They augment the standard Get and Put with explicit control flow signal (the way FIFOF augments FIFO). They are used virtually everywhere else in BlueBasics (and in Bluespec code that relies on BlueBasics). They are particulary usefull to design low latency interconnect components.

1.1. Types

1.1.1. Source

interface Source #(type t);
  (* always_ready *) method Bool canPeek;
  method t peek;
  method Action drop;
endinterface

1.1.2. Sink

interface Sink #(type t);
  (* always_ready *) method Bool canPut;
  method Action put (t val);
endinterface

1.1.3. SourceSinkShim

interface SourceSinkShim #(type t);
  interface Source #(t) source;
  interface Sink   #(t) sink;
endinterface

Miscelaneous primitives that get used throughout BlueBasics and outside.

2.1. Proxy types

Proxy types are provided to palliate the lack of type application in Bluespec.

2.1.1. Proxy

typedef struct {} Proxy #(type t);

2.1.2. NumProxy

typedef struct {} NumProxy #(numeric type n);

In addition to the previous Source and Sink interfaces, some credit-based SourceWithCredit and SinkWithCredit are also provided whose flow control is guarded on the presence of credit which is exchange through an extra Sink or Source interface.

3.1. Types

3.1.1. SourceWithCredit

typedef struct {
  Source #(t) data;
  Sink #(Bit #(0)) credit;
} SourceWithCredit #(type t);

3.1.2. SinkWithCredit

typedef struct {
  Sink #(t) data;
  Source #(Bit #(0)) credit;
} SinkWithCredit #(type t);

3.2. Helpers

Some helper Bluespec modules are provided to augment `Source`s and `Sink`s with credit.

3.2.1. toSourceWithCredit

module toSourceWithCredit #(parameter NumProxy #(t_max_credits) _proxy, t_src s)
                           (SourceWithCredit #(t));

3.2.2. toSinkWithCredit

module toSinkWithCredit #(parameter NumProxy #(t_max_credits) _proxy, t_snk s)
                         (SinkWithCredit #(t));

A Master is a Source of requests and a Sink for responses. A Slave is a Sink for requests and a Source of responses.

4.1. Types

4.1.1. Master

interface Master #(type t_req, type t_rsp);
  interface Source #(t_req) req;
  interface Sink   #(t_rsp) rsp;
endinterface

4.1.2. Slave

interface Slave #(type t_req, type t_rsp);
  interface Sink   #(t_req) req;
  interface Source #(t_rsp) rsp;
endinterface

The Virtualizable typeclass provides a single method, virtualize, which receive an instance of an interface together with an integer n, and return an array of n virtualized interfaces to the initial interface. Virtualizable instances are also provided for Reg, Server and Slave.

5.1. Types

5.1.1. Virtualizable

typeclass Virtualizable #(type t);
  module virtualize #(t x, Integer n)(Array #(t));
endtypeclass