URL
https://opencores.org/ocsvn/cryptosorter/cryptosorter/trunk
Subversion Repositories cryptosorter
[/] [cryptosorter/] [trunk/] [memocodeDesignContest2008/] [ctrl/] [mkTester.bsv] - Rev 6
Compare with Previous | Blame | View Log
/*Copyright (c) 2008 MITPermission is hereby granted, free of charge, to any personobtaining a copy of this software and associated documentationfiles (the "Software"), to deal in the Software withoutrestriction, including without limitation the rights to use,copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom theSoftware is furnished to do so, subject to the followingconditions:The above copyright notice and this permission notice shall beincluded 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 WARRANTIESOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OROTHER DEALINGS IN THE SOFTWARE.Author: Myron King*/import Memocode08Types ::*;import ExternalMemory ::*;import PLBMasterDummy ::*;import Interfaces ::*;import StmtFSM ::*;import GetPut ::*;import Vector ::*;import FIFO ::*;import Four2OneMerger ::*;typedef Bit#(TLog#(RecordsPerMemRequest)) RpmrBits;module mkEMTB (Empty);let recwid = fromInteger(valueOf(RecordWidth));let rpmr = fromInteger(valueOf(RecordsPerMemRequest));RpmrBits rpmr_msk = 0;PLBMaster dummy <- mkPLBMasterDummy();ExternalMemory extMem <- mkExternalMemory(dummy);Reg#(Bit#(32)) count <- mkReg(0);Reg#(int) state <- mkReg(0);Reg#(Bool) need_req <- mkReg(True);rule get_mem((state==0)&&!need_req);RpmrBits tr = truncate(count+1);if(truncate(count+1)==rpmr_msk)need_req <= True;let a <- extMem.read[0].read();$display(a);count <= count+1;if(count+1==8192)state<=1;endrulerule req_mem((state==0)&&need_req);extMem.read[0].readReq(count*recwid/8);need_req <= False;endrulerule fin(state==1);$finish();endruleendmodulemodule mk421TB (Empty);Four2One merger <- mkFour2One();Reg#(Bool) started <- mkReg(False);Stmt feeder =(seqmerger.in[0].put(0);merger.in[1].put(0);merger.in[2].put(0);merger.in[3].put(0);merger.in[0].put(1);merger.in[1].put(2);merger.in[2].put(3);merger.in[3].put(4);merger.in[0].put(4);merger.in[1].put(3);merger.in[2].put(2);merger.in[3].put(1);merger.in[0].put(4);merger.in[1].put(3);merger.in[2].put(1);merger.in[3].put(2);endseq);FSM ffsm <- mkFSM(feeder);rule start (!started);$display("start merge");ffsm.start();started <= True;endrulerule get_stuff (True);let a <- merger.out.get();$display(a);endruleendmodule
