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

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [lib/] [bsv/] [PLBMaster/] [fpga/] [PLBMasterTester.bsv] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 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 PLBMasterDefaultParameters::*;
33
import FIFO::*;
34
import GetPut::*;
35
 
36
interface PLBMasterTester;
37
  interface PLBMasterWires                  plbMasterWires;
38
  interface BRAMInitiatorWires#(Bit#(14))   bramInitiatorWires;
39
endinterface
40
 
41
typedef enum{
42
  Idle,
43
  Running,
44
  Inputing,
45
  Outputing
46
} TesterState deriving (Bits,Eq);
47
 
48
 
49
module mkPLBMasterTester(PLBMasterTester);
50
  Feeder feeder <- mkBRAMFeeder();
51
  PLBMaster     plbMaster <- mkPLBMaster;
52
 
53
  Reg#(TesterState) state <- mkReg(Idle);
54
  Reg#(BlockAddr) baseRegLoad <- mkReg(0);
55
  Reg#(BlockAddr) baseRegStore <- mkReg(0);
56
  Reg#(Bit#(19)) commandCount <- mkReg(0);
57
  Reg#(Bit#(32)) commandsComplete <- mkReg(1);
58
  FIFO#(BusWord) dataFIFO <- mkSizedFIFO(32);
59
  Reg#(Bool) evenZero <- mkReg(True);
60
 
61
  rule grabInstruction(state == Idle);
62
    PPCMessage inst <- feeder.ppcMessageOutput.get;
63
    baseRegLoad <= truncate(pack(inst));
64
    baseRegStore <= truncate(pack(inst));
65
    state <= Running;
66
  endrule
67
 
68
  rule issueCommand(state == Running);
69
    commandCount <= commandCount + 1;
70
    if(commandCount + 1 == 0)
71
      begin
72
        state <= Idle;
73
        feeder.ppcMessageInput.put(pack(commandsComplete));
74
        commandsComplete <= commandsComplete + 1;
75
      end
76
 
77
    if(commandCount[2] == 0)
78
      begin
79
        baseRegLoad <= baseRegLoad + fromInteger(valueof(TMul#(BeatsPerBurst,WordsPerBeat)));
80
        plbMaster.plbMasterCommandInput.put(tagged LoadPage (baseRegLoad));
81
      end
82
    else
83
      begin
84
        baseRegStore <= baseRegStore + fromInteger(valueof(TMul#(BeatsPerBurst,WordsPerBeat)));
85
        plbMaster.plbMasterCommandInput.put(tagged StorePage (baseRegStore));
86
      end
87
  endrule
88
 
89
  rule inputing;
90
     BusWord data <- plbMaster.wordOutput.get;
91
     dataFIFO.enq(data);
92
  endrule
93
 
94
  rule outputing;
95
    plbMaster.wordInput.put(unpack((~(pack(dataFIFO.first))) & (~1)));
96
    dataFIFO.deq;
97
  endrule
98
 
99
  interface plbMasterWires = plbMaster.plbMasterWires;
100
  interface bramInitiatorWires = feeder.bramInitiatorWires;
101
 
102
endmodule

powered by: WebSVN 2.1.0

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