annotate modules/bluespec/Pygar/lab4/CBUFF.bsv @ 25:220c14f5963c pygar svn.26

[svn r26] Not fully connected but passes audio successfully
author punk
date Wed, 28 Apr 2010 12:01:37 -0400
parents 74716e9a81cc
children
rev   line source
rlm@8 1 import Connectable::*;
rlm@8 2 import GetPut::*;
rlm@8 3 import ClientServer::*;
rlm@8 4
rlm@8 5 `include "asim/provides/librl_bsv_storage.bsh"
rlm@8 6
rlm@8 7 typedef SCOREBOARD_FIFO_ENTRY_ID#(t) CBUFFToken#(type t);
rlm@8 8
rlm@8 9 interface CBUFF #(numeric type n, type element_type);
rlm@8 10 interface Get#(CBUFFToken#(n)) reserve;
rlm@8 11 interface Put#(Tuple2 #(CBUFFToken#(n), element_type)) complete;
rlm@8 12 interface Get#(element_type) drain;
rlm@8 13 endinterface
rlm@8 14
rlm@8 15 module mkCBUFF(CBUFF#(n, element_type))
rlm@8 16 provisos(Bits#(element_type,a__));
rlm@8 17
rlm@8 18 SCOREBOARD_FIFOF#(n,element_type) cbuff <- mkScoreboardFIFOF();
rlm@8 19
rlm@8 20 let res = interface Get;
rlm@8 21 method ActionValue#(CBUFFToken#(n)) get();
rlm@8 22 let tok <- cbuff.enq();
rlm@8 23 return tok;
rlm@8 24 endmethod
rlm@8 25 endinterface;
rlm@8 26
rlm@8 27 let comp = interface Put;
rlm@8 28 method Action put(Tuple2#(CBUFFToken#(n),element_type) t);
rlm@8 29 cbuff.setValue(tpl_1(t), tpl_2(t));
rlm@8 30 endmethod
rlm@8 31 endinterface;
rlm@8 32
rlm@8 33 let dr = interface Get;
rlm@8 34 method ActionValue#(element_type) get();
rlm@8 35 cbuff.deq();
rlm@8 36 return cbuff.first();
rlm@8 37 endmethod
rlm@8 38 endinterface;
rlm@8 39
rlm@8 40 interface Get reserve = res;
rlm@8 41 interface Put complete = comp;
rlm@8 42 interface Get drain = dr;
rlm@8 43
rlm@8 44 endmodule