-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTinyORAMCore.v
More file actions
executable file
·286 lines (231 loc) · 9.33 KB
/
TinyORAMCore.v
File metadata and controls
executable file
·286 lines (231 loc) · 9.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
//==============================================================================
// Section: Includes
//==============================================================================
`include "Const.vh"
//==============================================================================
//==============================================================================
// Module: TinyORAMCore
// Desc: The Top-level TinyORAM module.
// Includes {Unified} x {Basic, REW} frontends/backends with
// encryption, integrity verification, & a FIFO DRAM interface.
//
// This module can be instantiated in a larger design or
// synthesized directly as a top module (using the default
// parameters specified below).
//==============================================================================
module TinyORAMCore(
Clock, Reset,
Cmd, PAddr, WMask,
CmdValid, CmdReady,
DataIn,
DataInValid, DataInReady,
DataOut,
DataOutValid, DataOutReady,
DRAMAddress, DRAMCommand, DRAMCommandValid, DRAMCommandReady,
DRAMReadData, DRAMReadDataValid,
DRAMWriteData, DRAMWriteDataValid, DRAMWriteDataReady,
Mode_DummyGen,
JTAG_UORAM, JTAG_PMMAC, JTAG_Frontend,
JTAG_AES, JTAG_StashCore, JTAG_Stash, JTAG_StashTop, JTAG_BackendCore, JTAG_Backend
);
//--------------------------------------------------------------------------
// Parameters
//--------------------------------------------------------------------------
// Debugging
/*
SlowAESClock: AES should use the same clock as the rest of the design
DebugDRAMReadTiming: Don't send PathBuffer data to AES until the PathBuffer has received an entire path.
This eliminates differences in MIG vs. simulation read timing.
*/
parameter SlowAESClock = 1; // NOTE: set to 0 for performance run
parameter DebugDRAMReadTiming = 0; // NOTE: set to 0 for performance run [NOTE: we un-implemented this. look in SVN for old code ...]
//--------------------------------------------------------------------------
// Constants
//--------------------------------------------------------------------------
`include "PathORAM.vh"
`include "UORAM.vh"
`include "DMLocal.vh"
`include "DDR3SDRAMLocal.vh"
`include "BucketLocal.vh"
`include "CommandsLocal.vh"
`include "JTAG.vh"
// TODO: remove localparam DelayedWB = 0;
// there is some logic in BackendControllerCore that implicitly
// assumes REW==DWB. Careful when enabling it.
//--------------------------------------------------------------------------
// System I/O
//--------------------------------------------------------------------------
input Clock, Reset;
//--------------------------------------------------------------------------
// User interface
//--------------------------------------------------------------------------
input [BECMDWidth-1:0] Cmd;
input [ORAMU-1:0] PAddr;
input [DMWidth-1:0] WMask;
input CmdValid;
output CmdReady;
input [FEDWidth-1:0] DataIn;
input DataInValid;
output DataInReady;
output [FEDWidth-1:0] DataOut;
output DataOutValid;
input DataOutReady;
//--------------------------------------------------------------------------
// DRAM interface
//--------------------------------------------------------------------------
output [DDRAWidth-1:0] DRAMAddress;
output [DDRCWidth-1:0] DRAMCommand;
output DRAMCommandValid;
input DRAMCommandReady;
input [BEDWidth-1:0] DRAMReadData;
input DRAMReadDataValid;
output [BEDWidth-1:0] DRAMWriteData;
output DRAMWriteDataValid;
input DRAMWriteDataReady;
//--------------------------------------------------------------------------
// Utility interface
//--------------------------------------------------------------------------
input Mode_DummyGen;
//--------------------------------------------------------------------------
// Status/Debugging interface
//--------------------------------------------------------------------------
output [JTWidth_PMMAC-1:0] JTAG_PMMAC;
output [JTWidth_UORAM-1:0] JTAG_UORAM;
output [JTWidth_Frontend-1:0] JTAG_Frontend;
output [JTWidth_AES-1:0] JTAG_AES;
output [JTWidth_StashCore-1:0] JTAG_StashCore;
output [JTWidth_Stash-1:0] JTAG_Stash;
output [JTWidth_StashTop-1:0] JTAG_StashTop;
output [JTWidth_BackendCore-1:0] JTAG_BackendCore;
output [JTWidth_Backend-1:0] JTAG_Backend;
//--------------------------------------------------------------------------
// Wires & Regs
//--------------------------------------------------------------------------
wire AESClock;
// Frontend - Backend
(* mark_debug = "TRUE" *) wire BEnd_CmdReady, BEnd_CmdValid;
(* mark_debug = "TRUE" *) wire [BECMDWidth-1:0] BEnd_Cmd;
(* mark_debug = "TRUE" *) wire [ORAMU-1:0] BEnd_PAddr;
(* mark_debug = "TRUE" *) wire [ORAML-1:0] CurrentLeaf, RemappedLeaf;
(* mark_debug = "TRUE" *) wire [FEDWidth-1:0] LoadData, StoreData;
(* mark_debug = "TRUE" *) wire LoadReady, LoadValid, StoreValid, StoreReady;
//--------------------------------------------------------------------------
// Simulation checks
//--------------------------------------------------------------------------
`ifdef SIMULATION
initial begin
$display("[%m] DDRAWidth = %d", DDRAWidth);
if (ORAML + 1 > 32) begin
$display("[%m] WARNING: Designs with more than 32 levels will be slightly more expensive resource-wise, because path-deep FIFOs won't pack as efficiently into LUTRAM.");
end
if (DDRDWidth < BEDWidth ||
DebugDRAMReadTiming || // TODO this is commented out in backend right now ...
DDRDWidth % BEDWidth != 0) begin
$display("[%m] ERROR: Illegal parameter setting."); // See BucketLocal.vh for more information.
$finish;
end
end
`endif
//--------------------------------------------------------------------------
// Clocking
//--------------------------------------------------------------------------
generate if (SlowAESClock || `ifndef FPGA 1 `else 0 `endif) begin:SLOW_AES
assign AESClock = Clock;
end else begin:FAST_AES
// Increases the clock by 50%
aes_clock ci15( .clk_in1( Clock),
.clk_out1( AESClock),
.reset( Reset),
.locked( ));
end endgenerate
//--------------------------------------------------------------------------
// Core modules
//--------------------------------------------------------------------------
`ifndef FPGA
Frontend
`else
Frontend #( .ORAMU( ORAMU),
.ORAML( ORAML),
.ORAMB( ORAMB),
.FEDWidth( FEDWidth),
.EnableIV( EnableIV),
.Recursion( Recursion),
.EnablePLB( EnablePLB),
.PLBCapacity( PLBCapacity),
.PRFPosMap( PRFPosMap))
`endif
front_end( .Clock( Clock),
.Reset( Reset),
.CmdInReady( CmdReady),
.CmdInValid( CmdValid),
.CmdIn( Cmd),
.WMaskIn( WMask),
.ProgAddrIn( PAddr),
.DataInReady( DataInReady),
.DataInValid( DataInValid),
.DataIn( DataIn),
.ReturnDataReady( DataOutReady),
.ReturnDataValid( DataOutValid),
.ReturnData( DataOut),
.CmdOutReady( BEnd_CmdReady),
.CmdOutValid( BEnd_CmdValid),
.CmdOut( BEnd_Cmd),
.AddrOut( BEnd_PAddr),
.OldLeaf( CurrentLeaf),
.NewLeaf( RemappedLeaf),
.StoreDataReady( StoreReady),
.StoreDataValid( StoreValid),
.StoreData( StoreData),
.LoadDataReady( LoadReady),
.LoadDataValid( LoadValid),
.LoadData( LoadData),
.JTAG_PMMAC( JTAG_PMMAC),
.JTAG_UORAM( JTAG_UORAM),
.JTAG_Frontend( JTAG_Frontend));
PathORAMBackend #( .ORAMB( ORAMB),
.ORAMU( ORAMU),
.ORAML( ORAML),
.ORAMZ( ORAMZ),
.ORAMC( ORAMC),
.ORAME( ORAME),
.Overclock( Overclock),
.EnableAES( EnableAES),
.EnableREW( EnableREW),
.EnableIV( EnableIV),
.DelayedWB( 1'b0),
.FEDWidth( FEDWidth),
.BEDWidth( BEDWidth))
back_end ( .Clock( Clock),
.AESClock( AESClock),
.Reset( Reset),
.Command( BEnd_Cmd),
.PAddr( BEnd_PAddr),
.CurrentLeaf( CurrentLeaf),
.RemappedLeaf( RemappedLeaf),
.CommandValid( BEnd_CmdValid),
.CommandReady( BEnd_CmdReady),
.LoadData( LoadData),
.LoadValid( LoadValid),
.LoadReady( LoadReady),
.StoreData( StoreData),
.StoreValid( StoreValid),
.StoreReady( StoreReady),
.DRAMCommandAddress( DRAMAddress),
.DRAMCommand( DRAMCommand),
.DRAMCommandValid( DRAMCommandValid),
.DRAMCommandReady( DRAMCommandReady),
.DRAMReadData( DRAMReadData),
.DRAMReadDataValid( DRAMReadDataValid),
.DRAMWriteData( DRAMWriteData),
.DRAMWriteDataValid( DRAMWriteDataValid),
.DRAMWriteDataReady( DRAMWriteDataReady),
.Mode_DummyGen( Mode_DummyGen),
.JTAG_AES( JTAG_AES),
.JTAG_StashCore( JTAG_StashCore),
.JTAG_Stash( JTAG_Stash),
.JTAG_StashTop( JTAG_StashTop),
.JTAG_BackendCore( JTAG_BackendCore),
.JTAG_Backend( JTAG_Backend));
//--------------------------------------------------------------------------
endmodule
//------------------------------------------------------------------------------