|
Message
From: cvs at opencores.org<cvs@o...>
Date: Mon Jun 30 19:06:18 CEST 2008
Subject: [cvs-checkins] MODIFIED: cryptosorter ...
Date: 00/08/06 30:19:06 Added: cryptosorter/lib/bsv/BRAM/blue_sim_model BRAM.bsv Log: Adding library codes Revision Changes Path 1.1 cryptosorter/lib/bsv/BRAM/blue_sim_model/BRAM.bsv http://www.opencores.org/cvsweb.shtml/cryptosorter/lib/bsv/BRAM/blue_sim_model/BRAM.bsv?rev=1.1&content-type=text/x-cvsweb-markup Index: BRAM.bsv =================================================================== //----------------------------------------------------------------------// // The MIT License // // Copyright (c) 2008 Kermin Fleming, kfleming@m... // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. //----------------------------------------------------------------------// import FIFO::*; import RegFile::*; interface BRAM#(type idx_type, type data_type); method Action read_req(idx_type idx); method ActionValue#(data_type) read_resp(); method Action write(idx_type idx, data_type data); endinterface module mkBRAM#(Integer low, Integer high) //interface: (BRAM#(idx_type, data_type)) provisos (Bits#(idx_type, idx), Bits#(data_type, data), Literal#(idx_type), Bounded#(idx_type)); BRAM#(idx_type, data_type) m <- (valueof(data) == 0) ? mkBRAM_Zero() : mkBRAM_NonZero(low, high); return m; endmodule module mkBRAM_NonZero#(Integer low, Integer high) //interface: (BRAM#(idx_type, data_type)) provisos (Bits#(idx_type, idx), Bits#(data_type, data), Literal#(idx_type), Bounded#(idx_type)); RegFile#(idx_type, data_type) arr <- mkRegFileFull(); FIFO#(data_type) outfifo <- mkSizedFIFO(8); method Action read_req(idx_type idx); outfifo.enq(arr.sub(idx)); endmethod method ActionValue#(data_type) read_resp(); outfifo.deq(); return outfifo.first(); endmethod method Action write(idx_type idx, data_type data); arr.upd(idx, data); endmethod endmodule module mkBRAM_Zero //interface: (BRAM#(idx_type, data_type)) provisos (Bits#(idx_type, idx), Bits#(data_type, data), Literal#(idx_type));
FIFO#(data_type) q <- mkSizedFIFO(8);
method Action read_req(idx_type i);
q.enq(?);
endmethod
method Action write(idx_type i, data_type d);
noAction;
endmethod
method ActionValue#(data_type) read_resp();
q.deq();
return q.first();
endmethod
endmodule
module mkBRAM_Full
//interface:
(BRAM#(idx_type, data_type))
provisos
(Bits#(idx_type, idx),
Bits#(data_type, data),
Literal#(idx_type),
Bounded#(idx_type));
BRAM#(idx_type, data_type) br <- mkBRAM(0, valueof(TExp#(idx)) - 1);
return br;
endmodule
|
 |