OpenCores
URL https://opencores.org/ocsvn/cryptosorter/cryptosorter/trunk

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [memocodeDesignContest2008/] [xup/] [BRAMFIFO/] [BRAMFIFOTester.bsv] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 kfleming
/*
2
Copyright (c) 2008 MIT
3
 
4
Permission is hereby granted, free of charge, to any person
5
obtaining a copy of this software and associated documentation
6
files (the "Software"), to deal in the Software without
7
restriction, including without limitation the rights to use,
8
copy, modify, merge, publish, distribute, sublicense, and/or sell
9
copies of the Software, and to permit persons to whom the
10
Software is furnished to do so, subject to the following
11
conditions:
12
 
13
The above copyright notice and this permission notice shall be
14
included in all copies or substantial portions of the Software.
15
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
OTHER DEALINGS IN THE SOFTWARE.
24
 
25
Author: Kermin Fleming
26
*/
27
 
28
import PLBMasterWires::*;
29
import BRAMInitiatorWires::*;
30
import PLBMaster::*;
31
import BRAMFeeder::*;
32
import Interfaces::*;
33
import Parameters::*;
34
import FIFO::*;
35
import GetPut::*;
36
import Types::*;
37
import Memocode08Types::*;
38
import BRAMFIFO::*;
39
 
40
interface BRAMFIFOTester;
41
  interface PLBMasterWires                  plbMasterWires;
42
  interface BRAMInitiatorWires#(Bit#(14))   bramInitiatorWires;
43
endinterface
44
 
45
typedef enum{
46
  Idle,
47
  Running,
48
  Inputing,
49
  Outputing
50
} TesterState deriving (Bits,Eq);
51
 
52
 
53
module mkBRAMFIFOTester (BRAMFIFOTester);
54
  Feeder feeder <- mkBRAMFeeder();
55
  PLBMaster     plbMaster <- mkPLBMaster;
56
 
57
  Reg#(TesterState) state <- mkReg(Idle);
58
  Reg#(BlockAddr) baseRegLoad <- mkReg(0);
59
  Reg#(BlockAddr) baseRegStore <- mkReg(0);
60
  Reg#(Bit#(20)) commandCount <- mkReg(0);
61
  Reg#(Bit#(20)) maxCommands <- mkReg(0);
62
  FIFO#(Record) dataFIFO <- mkBRAMFIFO(8);
63
 
64
  rule grabInstruction(state == Idle);
65
    PPCMessage inst <- feeder.ppcMessageOutput.get;
66
    Bit#(5) size = truncate(pack(inst));
67
    maxCommands <= 1 << (size); // + 1 since we need R/W -2 for 4/bursts +1 for needing two iters
68
    commandCount <= 0;
69
    baseRegLoad <= 0;
70
    baseRegStore <= 0;
71
    state <= Running;
72
  endrule
73
 
74
  rule issueCommand(state == Running);
75
    commandCount <= commandCount + 1;
76
    if(commandCount + 1 == maxCommands)
77
      begin
78
        state <= Idle;
79
        feeder.ppcMessageInput.put(zeroExtend(pack(maxCommands)));
80
      end
81
 
82
    if(commandCount[1] == 0)
83
      begin
84
        baseRegLoad <= baseRegLoad + fromInteger(valueof(BlockSize));
85
        plbMaster.plbMasterCommandInput.put(tagged LoadPage (baseRegLoad));
86
 
87
      end
88
    else
89
      begin
90
        baseRegStore <= baseRegStore + fromInteger(valueof(BlockSize));
91
        plbMaster.plbMasterCommandInput.put(tagged StorePage (baseRegStore));
92
      end
93
  endrule
94
 
95
  rule inputing;
96
     Record data <- plbMaster.wordOutput.get;
97
     dataFIFO.enq(data);
98
  endrule
99
 
100
  rule outputing;
101
    plbMaster.wordInput.put(dataFIFO.first);
102
    dataFIFO.deq;
103
  endrule
104
 
105
  interface plbMasterWires = plbMaster.plbMasterWires;
106
  interface bramInitiatorWires = feeder.bramInitiatorWires;
107
 
108
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.