view modules/bluespec/Pygar/lab4/CBUFF.bsv @ 40:7ac38b0f93fa pygar svn.41

[svn r41] made perl build script automatically generate program.vmh
author rlm
date Tue, 04 May 2010 19:53:09 -0400
parents 74716e9a81cc
children
line wrap: on
line source
1 import Connectable::*;
2 import GetPut::*;
3 import ClientServer::*;
5 `include "asim/provides/librl_bsv_storage.bsh"
7 typedef SCOREBOARD_FIFO_ENTRY_ID#(t) CBUFFToken#(type t);
9 interface CBUFF #(numeric type n, type element_type);
10 interface Get#(CBUFFToken#(n)) reserve;
11 interface Put#(Tuple2 #(CBUFFToken#(n), element_type)) complete;
12 interface Get#(element_type) drain;
13 endinterface
15 module mkCBUFF(CBUFF#(n, element_type))
16 provisos(Bits#(element_type,a__));
18 SCOREBOARD_FIFOF#(n,element_type) cbuff <- mkScoreboardFIFOF();
20 let res = interface Get;
21 method ActionValue#(CBUFFToken#(n)) get();
22 let tok <- cbuff.enq();
23 return tok;
24 endmethod
25 endinterface;
27 let comp = interface Put;
28 method Action put(Tuple2#(CBUFFToken#(n),element_type) t);
29 cbuff.setValue(tpl_1(t), tpl_2(t));
30 endmethod
31 endinterface;
33 let dr = interface Get;
34 method ActionValue#(element_type) get();
35 cbuff.deq();
36 return cbuff.first();
37 endmethod
38 endinterface;
40 interface Get reserve = res;
41 interface Put complete = comp;
42 interface Get drain = dr;
44 endmodule