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

Subversion Repositories bluespec_md6

[/] [bluespec_md6/] [trunk/] [MD6Control/] [fpga/] [MD6ControlEngine.bsv] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 kfleming
//----------------------------------------------------------------------//
2
// The MIT License
3
//
4
// Copyright (c) 2008 Kermin Fleming, kfleming@mit.edu
5
//
6
// Permission is hereby granted, free of charge, to any person
7
// obtaining a copy of this software and associated documentation
8
// files (the "Software"), to deal in the Software without
9
// restriction, including without limitation the rights to use,
10
// copy, modify, merge, publish, distribute, sublicense, and/or sell
11
// copies of the Software, and to permit persons to whom the
12
// Software is furnished to do so, subject to the following conditions:
13
//
14
// The above copyright notice and this permission notice shall be
15
// included in all copies or substantial portions of the Software.
16
//
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
// OTHER DEALINGS IN THE SOFTWARE.
25
//----------------------------------------------------------------------//
26 2 kfleming
/*
27
Copyright (c) 2008 MIT
28
 
29
Permission is hereby granted, free of charge, to any person
30
obtaining a copy of this software and associated documentation
31
files (the "Software"), to deal in the Software without
32
restriction, including without limitation the rights to use,
33
copy, modify, merge, publish, distribute, sublicense, and/or sell
34
copies of the Software, and to permit persons to whom the
35
Software is furnished to do so, subject to the following
36
conditions:
37
 
38
The above copyright notice and this permission notice shall be
39
included in all copies or substantial portions of the Software.
40
 
41
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
42
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
43
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
44
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
45
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
46
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
48
OTHER DEALINGS IN THE SOFTWARE.
49
 
50
Author: Kermin Fleming
51
*/
52
 
53
/****
54
 *
55
 * This module serves as the top level for the MD6 control engine.
56
 *
57
 ****/
58
 
59
// Bluespec Lib
60
import FIFO::*;
61
import GetPut::*;
62
import Vector::*;
63
import Connectable::*;
64
 
65
// CSG Lib
66
import PLBMasterWires::*;
67
import BRAMInitiatorWires::*;
68
import PLBMaster::*;
69
import BRAMFeeder::*;
70
import PLBMaster::*;
71
import PLBMasterDefaultParameters::*;
72
import RegisterMapper::*;
73
import Register::*;
74
 
75
// Local includes
76
import MD6Control::*;
77
import MD6Parameters::*;
78
import MD6Types::*;
79
 
80
 
81
interface MD6Engine;
82
  interface PLBMasterWires                  plbMasterWires;
83
  interface BRAMInitiatorWires#(Bit#(14))   bramInitiatorWires;
84
endinterface
85
 
86
 
87
 
88
typedef Bit#(16) ControlReg;
89
 
90
/******
91
 * The reg map
92
 * 0-31   key
93
 * 32-33  source ptr
94
 * 34-35  destination ptr
95
 * 36-37  buffer ptr
96
 * 38-41  bitSize
97
 * 42     endianess
98
 * 43     start/status
99
 ******/
100
 
101
typedef 16 TotalMD6ControlRegs;
102
 
103
 
104
// This might ought to be baked out into some sort of BSP
105
function  MapperRequest#(regsSize, ControlReg) mapPPCMessageToMapperRequest(PPCMessage msg)
106
  provisos (Add#(xxx, TLog#(regsSize), 15));
107
  MapperRequest#(regsSize, ControlReg) mapperRequest;
108
  mapperRequest.command = unpack(msg[31]);
109
  mapperRequest.location = truncate(msg[30:16]);
110
  mapperRequest.payload = msg[15:0];
111
  return mapperRequest;
112
endfunction
113
 
114
function PPCMessage mapMapperRequestToPPCMessage(ControlReg data);
115
  return 32'hc0000 | zeroExtend(data);
116
endfunction
117
 
118
module mkMD6ControlEngine (MD6Engine);
119
  Feeder feeder <- mkBRAMFeeder();
120
  PLBMaster     plbmaster <- mkPLBMaster;
121
  MD6Control#(1,32) control <- mkMD6Control;
122
 
123
  /* create action-based registers */
124
  /* Maybe push this down? */
125
  function Action wrapStart(Bool bool);
126
    action
127
    if(!control.running())
128
      begin
129
        control.startDecode();
130
      end
131
    endaction
132
  endfunction
133
 
134
  Reg#(Bool) startReg = mkRegFromActions(control.running,wrapStart);
135
 
136
  // Probably build a list and map and concat would be best?
137
 
138
    let regBank = append(append(append(append(append(append(append(
139
                              explodeRegister(control.keyRegister),
140
                              explodeRegister(control.sourceAddress)),
141
                              explodeRegister(control.destinationAddress)),
142
                              explodeRegister(control.bufferAddress)),
143
                              explodeRegister(control.bitSize)),
144
                              explodeRegister(control.bigEndian)),
145
                              explodeRegister(startReg)),
146
                              explodeRegister(control.digestLength));
147
 
148
  RegisterMapper#(PPCMessage,
149
                  PPCMessage
150
                 ) regMapper <- mkRegisterMapper(mapPPCMessageToMapperRequest,
151
                                                 mapMapperRequestToPPCMessage,
152
                                                 regBank);
153
 
154
 
155
  // Hook up the system
156
  mkConnection(plbmaster.wordInput.put,control.wordOutput);
157
  mkConnection(control.wordInput,plbmaster.wordOutput.get);
158
  mkConnection(plbmaster.plbMasterCommandInput.put,control.outputCommand);
159
  mkConnection(regMapper.registerRequest, feeder.ppcMessageOutput.get);
160
  mkConnection(feeder.ppcMessageInput.put, regMapper.registerResponse);
161
 
162
  interface plbMasterWires = plbmaster.plbMasterWires;
163
  interface bramInitiatorWires = feeder.bramInitiatorWires;
164
 
165
endmodule

powered by: WebSVN 2.1.0

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