URL
https://opencores.org/ocsvn/cryptosorter/cryptosorter/trunk
Subversion Repositories cryptosorter
[/] [cryptosorter/] [trunk/] [memocodeDesignContest2008/] [xup/] [BRAMFIFO/] [BRAMFIFOTester.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: Kermin Fleming*/import PLBMasterWires::*;import BRAMInitiatorWires::*;import PLBMaster::*;import BRAMFeeder::*;import Interfaces::*;import Parameters::*;import FIFO::*;import GetPut::*;import Types::*;import Memocode08Types::*;import BRAMFIFO::*;interface BRAMFIFOTester;interface PLBMasterWires plbMasterWires;interface BRAMInitiatorWires#(Bit#(14)) bramInitiatorWires;endinterfacetypedef enum{Idle,Running,Inputing,Outputing} TesterState deriving (Bits,Eq);module mkBRAMFIFOTester (BRAMFIFOTester);Feeder feeder <- mkBRAMFeeder();PLBMaster plbMaster <- mkPLBMaster;Reg#(TesterState) state <- mkReg(Idle);Reg#(BlockAddr) baseRegLoad <- mkReg(0);Reg#(BlockAddr) baseRegStore <- mkReg(0);Reg#(Bit#(20)) commandCount <- mkReg(0);Reg#(Bit#(20)) maxCommands <- mkReg(0);FIFO#(Record) dataFIFO <- mkBRAMFIFO(8);rule grabInstruction(state == Idle);PPCMessage inst <- feeder.ppcMessageOutput.get;Bit#(5) size = truncate(pack(inst));maxCommands <= 1 << (size); // + 1 since we need R/W -2 for 4/bursts +1 for needing two iterscommandCount <= 0;baseRegLoad <= 0;baseRegStore <= 0;state <= Running;endrulerule issueCommand(state == Running);commandCount <= commandCount + 1;if(commandCount + 1 == maxCommands)beginstate <= Idle;feeder.ppcMessageInput.put(zeroExtend(pack(maxCommands)));endif(commandCount[1] == 0)beginbaseRegLoad <= baseRegLoad + fromInteger(valueof(BlockSize));plbMaster.plbMasterCommandInput.put(tagged LoadPage (baseRegLoad));endelsebeginbaseRegStore <= baseRegStore + fromInteger(valueof(BlockSize));plbMaster.plbMasterCommandInput.put(tagged StorePage (baseRegStore));endendrulerule inputing;Record data <- plbMaster.wordOutput.get;dataFIFO.enq(data);endrulerule outputing;plbMaster.wordInput.put(dataFIFO.first);dataFIFO.deq;endruleinterface plbMasterWires = plbMaster.plbMasterWires;interface bramInitiatorWires = feeder.bramInitiatorWires;endmodule
