forked from pulp-platform/axi_spi_slave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspi_slave_cmd_parser.sv
160 lines (156 loc) · 4.44 KB
/
spi_slave_cmd_parser.sv
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
// Copyright 2017 ETH Zurich and University of Bologna.
// Copyright and related rights are licensed under the Solderpad Hardware
// License, Version 0.51 (the “License”); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
// or agreed to in writing, software, hardware and materials distributed under
// this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
module spi_slave_cmd_parser(
input logic [7:0] cmd,
output logic get_addr,
output logic get_mode,
output logic get_data,
output logic send_data,
output logic enable_cont,
output logic enable_regs,
output logic wait_dummy,
output logic error,
output logic [1:0] reg_sel
);
always_comb
begin
get_addr = 0;
get_mode = 0;
get_data = 0;
send_data = 0;
enable_cont = 0;
enable_regs = 1'b0;
wait_dummy = 0;
reg_sel = 2'b00;
error = 1'b1;
case(cmd)
8'h1: //write reg0
begin
get_addr = 0;
get_mode = 0;
get_data = 1;
send_data = 0;
enable_cont = 0;
enable_regs = 1'b1;
error = 1'b0;
wait_dummy = 0;
reg_sel = 2'b00;
end
8'h2: //write mem
begin
get_addr = 1;
get_mode = 0;
get_data = 1;
send_data = 0;
enable_cont = 1'b1;
enable_regs = 1'b0;
error = 1'b0;
wait_dummy = 0;
reg_sel = 2'b00;
end
8'h5: //read reg0
begin
get_addr = 0;
get_mode = 0;
get_data = 0;
send_data = 1;
enable_cont = 0;
enable_regs = 1'b1;
error = 1'b0;
wait_dummy = 0;
reg_sel = 2'b00;
end
8'h7: //read reg1
begin
get_addr = 0;
get_mode = 0;
get_data = 0;
send_data = 1;
enable_cont = 0;
enable_regs = 1'b1;
error = 1'b0;
wait_dummy = 0;
reg_sel = 2'b01;
end
8'hB: //read mem
begin
get_addr = 1;
get_mode = 0;
get_data = 0;
send_data = 1;
enable_cont = 1'b1;
enable_regs = 1'b0;
error = 1'b0;
wait_dummy = 1;
reg_sel = 2'b00;
end
8'h11: //write reg1
begin
get_addr = 1'b0;
get_mode = 1'b0;
get_data = 1'b1;
send_data = 1'b0;
enable_cont = 1'b0;
enable_regs = 1'b1;
error = 1'b0;
wait_dummy = 1'b0;
reg_sel = 2'b01;
end
8'h20: // write reg2
begin
get_addr = 1'b0;
get_mode = 1'b0;
get_data = 1'b1;
send_data = 1'b0;
enable_cont = 1'b0;
enable_regs = 1'b1;
error = 1'b0;
wait_dummy = 1'b0;
reg_sel = 2'b10;
end
8'h21: // read reg2
begin
get_addr = 1'b0;
get_mode = 1'b0;
get_data = 1'b0;
send_data = 1'b1;
enable_cont = 1'b0;
enable_regs = 1'b1;
error = 1'b0;
wait_dummy = 1'b0;
reg_sel = 2'b10;
end
8'h30: // write reg3
begin
get_addr = 1'b0;
get_mode = 1'b0;
get_data = 1'b1;
send_data = 1'b0;
enable_cont = 1'b0;
enable_regs = 1'b1;
error = 1'b0;
wait_dummy = 1'b0;
reg_sel = 2'b11;
end
8'h31: // read reg3
begin
get_addr = 1'b0;
get_mode = 1'b0;
get_data = 1'b0;
send_data = 1'b1;
enable_cont = 1'b0;
enable_regs = 1'b1;
error = 1'b0;
wait_dummy = 1'b0;
reg_sel = 2'b11;
end
endcase
end
endmodule