-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunpack.v
71 lines (63 loc) · 1.23 KB
/
unpack.v
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
// May 28 2015
// Nathan Pointer
module unpack(clk, rst, io, eta, phi, et, e, eout, etout, phiout, etaout);
input clk;
input rst;
input eta; // 32
input phi; // 32
input et; // 0-1000
input e;
input io;
output eout;
output etout;
output phiout;
output etaout;
reg[0:31] index;
integer i;
reg [9:0] etas [1023:0]; // 32 blocks of 32
reg [9:0] phis [1023:0]; // 32 blocks of 32
reg [9:0] ets [1023:0];
reg [9:0] es [1023:0];
reg[9:0] et_temp;
reg[9:0] e_temp;
reg[9:0] eta_temp;
reg[9:0] phi_temp;
localparam gets = 0, puts = 1;
always @(posedge clk or posedge rst) begin
if (rst) begin
index <=0;
for (i=0; i<1023; i=i+1) begin
etas[i] <= 0;
phis[i] <= 0;
ets[i] <= 0;
es[i] <= 0;
end
end
else begin
case(io)
puts:
begin
index = index + 1;
etas[index] = eta;
phis[index] = phi;
ets[index] = et;
es[index] = e;
end
gets:
begin
// In Gets mode, using eta as an integer
i = eta;
et_temp = ets[i];
e_temp = es[i];
eta_temp = etas[i];
phi_temp = phis[i];
end
endcase
end
end
// Outputs
assign etout = et_temp;
assign eout = e_temp;
assign etaout = eta_temp;
assign phiout = phi_temp;
endmodule