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

Subversion Repositories bluespec_md6

[/] [bluespec_md6/] [trunk/] [MD6Control/] [test/] [benchmarks/] [CompressionFunctionLibrary.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
import Vector::*;
27
 
28
import MD6Parameters::*;
29
import MD6Types::*;
30
import CompressionFunctionTypes::*;
31
import CompressionFunctionParameters::*;
32
 
33
 
34
// The following are magic, externally defined parameters in MD6
35
// Other important parameters are derived from them.
36
// These parameters are used solely within the compression
37
// function.
38
 
39
// This set of functions determines the locations of the filter taps
40
// these index into the constant array given in appendix C of the spec.
41
// TODO: kfleming - these are currently constant functions.
42
function Integer determineT0();
43
  Integer returnValue = 0;
44
  if((valueof(MD6_n) == 89) && (valueof(MD6_c) == 16))
45
    begin
46
      returnValue = 17;
47
    end
48
  else if((valueof(MD6_n) == 178) && (valueof(MD6_c) == 32))
49
    begin
50
      returnValue = 33;
51
    end
52
  else
53
    begin
54
      let err = error("T0 not defined");
55
    end
56
  return valueof(MD6_n)-returnValue;
57
endfunction
58
 
59
function Integer determineT1();
60
  Integer returnValue = 0;
61
  if((valueof(MD6_n) == 89) && (valueof(MD6_c) == 16))
62
    begin
63
      returnValue = 18;
64
    end
65
  else if((valueof(MD6_n) == 178) && (valueof(MD6_c) == 32))
66
    begin
67
      returnValue = 35;
68
    end
69
  else
70
    begin
71
      let err = error("T1 not defined");
72
    end
73
  return valueof(MD6_n)-returnValue;
74
endfunction
75
 
76
function Integer determineT2();
77
  Integer returnValue = 0;
78
  if((valueof(MD6_n) == 89) && (valueof(MD6_c) == 16))
79
    begin
80
      returnValue = 21;
81
    end
82
  else if((valueof(MD6_n) == 178) && (valueof(MD6_c) == 32))
83
    begin
84
      returnValue = 49;
85
    end
86
  else
87
    begin
88
      let err = error("T2 not defined");
89
    end
90
  return valueof(MD6_n)-returnValue;
91
endfunction
92
 
93
function Integer determineT3();
94
  Integer returnValue = 0;
95
  if((valueof(MD6_n) == 89) && (valueof(MD6_c) == 16))
96
    begin
97
      returnValue = 31;
98
    end
99
  else if((valueof(MD6_n) == 178) && (valueof(MD6_c) == 32))
100
    begin
101
      returnValue = 53;
102
    end
103
  else
104
    begin
105
      let err = error("T3 not defined");
106
    end
107
  return valueof(MD6_n)-returnValue;
108
endfunction
109
 
110
function Integer determineT4();
111
  Integer returnValue = 0;
112
  if((valueof(MD6_n) == 89) && (valueof(MD6_c) == 16))
113
    begin
114
      returnValue = 67;
115
    end
116
  else if((valueof(MD6_n) == 178) && (valueof(MD6_c) == 32))
117
    begin
118
      returnValue = 111;
119
    end
120
  else
121
    begin
122
      let err = error("T4 not defined");
123
    end
124
  return valueof(MD6_n)-returnValue;
125
endfunction
126
 
127
function Integer determineT5();
128
  return 0;
129
endfunction
130
 
131
// This function returns the shift amounts.  The argument is the step
132
// index.
133
 
134
function ShiftFactor shiftIndexR(Bit#(4) index);
135
  if(valueof(MD6_WordWidth) == 64)
136
    begin
137
      return c64ShiftR[index];
138
    end
139
  else if(valueof(MD6_WordWidth) == 32)
140
    begin
141
      return c32ShiftR[index];
142
    end
143
  else if(valueof(MD6_WordWidth) == 16)
144
    begin
145
      return c16ShiftR[index];
146
    end
147
  else if(valueof(MD6_WordWidth) == 8)
148
    begin
149
      return c8ShiftR[index];
150
    end
151
  else
152
    begin
153
      return 0;
154
    end
155
endfunction
156
 
157
function ShiftFactor shiftIndexL(Bit#(4) index);
158
  if(valueof(MD6_WordWidth) == 64)
159
    begin
160
      return c64ShiftL[index];
161
    end
162
  else if(valueof(MD6_WordWidth) == 32)
163
    begin
164
      return c32ShiftL[index];
165
    end
166
  else if(valueof(MD6_WordWidth) == 16)
167
    begin
168
      return c16ShiftL[index];
169
    end
170
  else if(valueof(MD6_WordWidth) == 8)
171
    begin
172
      return c8ShiftL[index];
173
    end
174
  else
175
    begin
176
      return 0;
177
    end
178
endfunction
179
 
180
function Vector#(MD6_u, MD6Word) makeControlWord(Round rounds,
181
                              TreeHeight maxTreeHeight,
182
                              LastCompression lastCompression,
183
                              PaddingBits paddingBits,
184
                              KeyLength keyLength,
185
                              DigestLength digestLength)
186
  provisos(Bits#(MD6Word, md6_size));
187
  Bit#(64) controlWord = {4'b0000,rounds,maxTreeHeight,lastCompression,
188
          paddingBits,keyLength, digestLength};
189
  MD6Word controlArray[valueof(MD6_u)];
190
  for(Integer i = 0; i < valueof(MD6_u); i = i + 1)
191
    begin
192
      controlArray[fromInteger(i)] = controlWord[(i+1)*valueof(md6_size)-1:i*valueof(md6_size)];
193
    end
194
  Vector#(MD6_u, MD6Word) controlVector = arrayToVector(controlArray);
195
  return controlVector;
196
endfunction

powered by: WebSVN 2.1.0

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