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

Subversion Repositories cryptosorter

[/] [cryptosorter/] [trunk/] [memocodeDesignContest2008/] [xup/] [Top/] [Sorter.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
/* This is the top-level sorter module.  It interfaces to the PLB bus, the
29
   DSOCM, and the sorter core. Not much functionality, but it does have
30
   a cycle timer, and sends periodic messages back to the PPC over the
31
   DSOCM
32
*/
33
 
34
import PLBMasterWires::*;
35
//import BRAMTargetWires::*;
36
import BRAMInitiatorWires::*;
37
import PLBMaster::*;
38
import BRAMFeeder::*;
39
//import BRAMModel::*;
40
import Interfaces::*;
41
import Parameters::*;
42
import FIFO::*;
43
import GetPut::*;
44
import Types::*;
45
import Memocode08Types::*;
46
import mkCtrl::*;
47
import ExternalMemory::*;
48
import PLBMaster::*;
49
 
50
interface Sorter;
51
  interface PLBMasterWires                  plbMasterWires;
52
  interface BRAMInitiatorWires#(Bit#(14))   bramInitiatorWires;
53
 
54
 
55
endinterface
56
 
57
 
58
typedef enum {
59
  Idle,
60
  Waiting,
61
  SendingResp
62
} TopState deriving (Bits,Eq);
63
 
64
module mkSorter#(Clock fastClock, Reset fastReset)(Sorter);
65
  Feeder feeder <- mkBRAMFeeder();
66
  PLBMaster     plbMaster <- mkPLBMaster;
67
  ExternalMemory extMem <- mkExternalMemory(plbMaster);
68
  Control  controller <- mkControl(extMem, fastClock, fastReset);
69
 
70
  Reg#(Bit#(5)) size <- mkReg(0);
71
  Reg#(Bit#(3)) passes <- mkReg(1);
72
  Reg#(TopState) state <- mkReg(Idle);
73
  Reg#(Bit#(31)) counter <- mkReg(0);
74
 
75
  rule getfinished((state == Waiting) && controller.finished);
76
    state <= SendingResp;
77
  endrule
78
 
79
  rule countUp(state != Idle);
80
    counter <= counter + 1;
81
  endrule
82
 
83
  rule sendCommand(controller.finished && (state == Idle));
84
    PPCMessage inst <- feeder.ppcMessageOutput.get;
85
    controller.doSort(truncate(pack(inst)));
86
    size <= truncate(pack(inst));
87
    state <= Waiting;
88
    counter <= 0;
89
    passes <= 1;
90
  endrule
91
 
92
  rule returnPass;
93
    let msg <- controller.msgs.get;
94
    passes <= passes + 1;
95
    //feeder.ppcMessageInput.put(zeroExtend(32'hC000|msg));
96
  endrule
97
 
98
 
99
  rule returnResp(state == SendingResp);
100
    state <= Idle;
101
    feeder.ppcMessageInput.put(zeroExtend(counter));
102
  endrule
103
 
104
  interface plbMasterWires = plbMaster.plbMasterWires;
105
  interface bramInitiatorWires = feeder.bramInitiatorWires;
106
 
107
endmodule

powered by: WebSVN 2.1.0

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