@@ -40,11 +40,21 @@ input wire dataslot_requestread_ok,
40
40
41
41
output reg dataslot_requestwrite,
42
42
output reg [15 :0 ] dataslot_requestwrite_id,
43
+ output reg [31 :0 ] dataslot_requestwrite_size,
43
44
input wire dataslot_requestwrite_ack,
44
45
input wire dataslot_requestwrite_ok,
45
46
47
+ output reg dataslot_update,
48
+ output reg [15 :0 ] dataslot_update_id,
49
+ output reg [31 :0 ] dataslot_update_size,
50
+
46
51
output reg dataslot_allcomplete,
47
52
53
+ output reg [31 :0 ] rtc_epoch_seconds,
54
+ output reg [31 :0 ] rtc_date_bcd,
55
+ output reg [31 :0 ] rtc_time_bcd,
56
+ output reg rtc_valid,
57
+
48
58
input wire savestate_supported,
49
59
input wire [31 :0 ] savestate_addr,
50
60
input wire [31 :0 ] savestate_size,
@@ -64,6 +74,18 @@ input wire savestate_load_busy,
64
74
input wire savestate_load_ok,
65
75
input wire savestate_load_err,
66
76
77
+ input wire target_dataslot_read, // rising edge triggered
78
+ input wire target_dataslot_write,
79
+
80
+ output reg target_dataslot_ack, // asserted upon command start until completion
81
+ output reg target_dataslot_done, // asserted upon command finish until next command is issued
82
+ output reg [2 :0 ] target_dataslot_err, // contains result of command execution. zero is OK
83
+
84
+ input wire [15 :0 ] target_dataslot_id, // parameters for each of the read/reload/write commands
85
+ input wire [31 :0 ] target_dataslot_slotoffset,
86
+ input wire [31 :0 ] target_dataslot_bridgeaddr,
87
+ input wire [31 :0 ] target_dataslot_length,
88
+
67
89
input wire [9 :0 ] datatable_addr,
68
90
input wire datatable_wren,
69
91
input wire [31 :0 ] datatable_data,
@@ -146,37 +168,53 @@ localparam [3:0] ST_DONE_ERR = 'd15;
146
168
147
169
localparam [3 :0 ] TARG_ST_IDLE = 'd0;
148
170
localparam [3 :0 ] TARG_ST_READYTORUN = 'd1;
149
- localparam [3 :0 ] TARG_ST_DISPMSG = 'd2;
150
- localparam [3 :0 ] TARG_ST_SLOTREAD = 'd3;
151
- localparam [3 :0 ] TARG_ST_SLOTRELOAD = 'd4;
152
- localparam [3 :0 ] TARG_ST_SLOTWRITE = 'd5;
153
- localparam [3 :0 ] TARG_ST_SLOTFLUSH = 'd6;
154
- localparam [3 :0 ] TARG_ST_WAITRESULT = 'd15;
171
+ localparam [3 :0 ] TARG_ST_DATASLOTOP = 'd2;
172
+ localparam [3 :0 ] TARG_ST_WAITRESULT_RTR = 'd14;
173
+ localparam [3 :0 ] TARG_ST_WAITRESULT_DSO = 'd15;
155
174
reg [3 :0 ] tstate;
156
175
157
- reg status_setup_done_1;
158
- reg status_setup_done_queue;
176
+ reg status_setup_done_1, status_setup_done_queue;
177
+ reg target_dataslot_read_1, target_dataslot_read_queue;
178
+ reg target_dataslot_write_1, target_dataslot_write_queue;
159
179
160
180
161
181
initial begin
162
182
reset_n <= 0 ;
163
183
dataslot_requestread <= 0 ;
164
184
dataslot_requestwrite <= 0 ;
185
+ dataslot_update <= 0 ;
165
186
dataslot_allcomplete <= 0 ;
187
+ rtc_valid <= 0 ;
166
188
savestate_start <= 0 ;
167
189
savestate_load <= 0 ;
168
190
osnotify_inmenu <= 0 ;
191
+
169
192
status_setup_done_queue <= 0 ;
193
+ target_dataslot_read_queue <= 0 ;
194
+ target_dataslot_write_queue <= 0 ;
195
+ target_dataslot_ack <= 0 ;
196
+ target_dataslot_done <= 0 ;
197
+ target_dataslot_err <= 0 ;
170
198
end
171
199
172
200
always @(posedge clk) begin
173
201
174
202
// detect a rising edge on the input signal
175
203
// and flag a queue that will be cleared later
176
204
status_setup_done_1 <= status_setup_done;
205
+ target_dataslot_read_1 <= target_dataslot_read;
206
+ target_dataslot_write_1 <= target_dataslot_write;
207
+
177
208
if (status_setup_done & ~ status_setup_done_1) begin
178
209
status_setup_done_queue <= 1 ;
179
210
end
211
+ if (target_dataslot_read & ~ target_dataslot_read_1) begin
212
+ target_dataslot_read_queue <= 1 ;
213
+ end
214
+ if (target_dataslot_write & ~ target_dataslot_write_1) begin
215
+ target_dataslot_write_queue <= 1 ;
216
+ end
217
+
180
218
181
219
b_datatable_wren <= 0 ;
182
220
b_datatable_addr <= bridge_addr >> 2 ;
@@ -257,6 +295,7 @@ always @(posedge clk) begin
257
295
258
296
dataslot_requestread <= 0 ;
259
297
dataslot_requestwrite <= 0 ;
298
+ dataslot_update <= 0 ;
260
299
savestate_start <= 0 ;
261
300
savestate_load <= 0 ;
262
301
@@ -314,17 +353,34 @@ always @(posedge clk) begin
314
353
dataslot_allcomplete <= 0 ;
315
354
dataslot_requestwrite <= 1 ;
316
355
dataslot_requestwrite_id <= host_20[15 :0 ];
356
+ dataslot_requestwrite_size <= host_24;
317
357
if (dataslot_requestwrite_ack) begin
318
358
host_resultcode <= 0 ;
319
359
if (! dataslot_requestwrite_ok) host_resultcode <= 2 ;
320
360
hstate <= ST_DONE_CODE;
321
361
end
322
362
end
363
+ 16'h008A : begin
364
+ // Data slot update (sent on deferload marked slots only)
365
+ dataslot_update <= 1 ;
366
+ dataslot_update_id <= host_20[15 :0 ];
367
+ dataslot_update_size <= host_24;
368
+ hstate <= ST_DONE_OK;
369
+ end
323
370
16'h008F : begin
324
371
// Data slot access all complete
325
372
dataslot_allcomplete <= 1 ;
326
373
hstate <= ST_DONE_OK;
327
374
end
375
+ 16'h0090 : begin
376
+ // Real-time Clock Data
377
+ // user logic should detect rising edge, it is not continuously updated
378
+ rtc_valid <= 1 ;
379
+ rtc_epoch_seconds <= host_20;
380
+ rtc_date_bcd <= host_24;
381
+ rtc_time_bcd <= host_28;
382
+ hstate <= ST_DONE_OK;
383
+ end
328
384
16'h00A0 : begin
329
385
// Savestate: Start/Query
330
386
host_40 <= savestate_supported;
@@ -397,22 +453,63 @@ always @(posedge clk) begin
397
453
endcase
398
454
399
455
400
-
401
-
402
456
// target > host command executer
403
457
case (tstate)
404
458
TARG_ST_IDLE: begin
459
+
460
+ target_dataslot_ack <= 0 ;
461
+
405
462
if (status_setup_done_queue) begin
406
463
status_setup_done_queue <= 0 ;
407
464
tstate <= TARG_ST_READYTORUN;
408
- end
409
-
465
+
466
+ end else if (target_dataslot_read_queue) begin
467
+ target_dataslot_read_queue <= 0 ;
468
+ target_0[15 :0 ] <= 16'h0180 ;
469
+
470
+ target_20 <= target_dataslot_id;
471
+ target_24 <= target_dataslot_slotoffset;
472
+ target_28 <= target_dataslot_bridgeaddr;
473
+ target_2C <= target_dataslot_length;
474
+
475
+ tstate <= TARG_ST_DATASLOTOP;
476
+
477
+ end else if (target_dataslot_write_queue) begin
478
+ target_dataslot_write_queue <= 0 ;
479
+ target_0[15 :0 ] <= 16'h0184 ;
480
+
481
+ target_20 <= target_dataslot_id;
482
+ target_24 <= target_dataslot_slotoffset;
483
+ target_28 <= target_dataslot_bridgeaddr;
484
+ target_2C <= target_dataslot_length;
485
+
486
+ tstate <= TARG_ST_DATASLOTOP;
487
+ end
410
488
end
411
489
TARG_ST_READYTORUN: begin
412
490
target_0 <= 32'h636D_0140 ;
413
- tstate <= TARG_ST_WAITRESULT;
491
+ tstate <= TARG_ST_WAITRESULT_RTR;
492
+ end
493
+ TARG_ST_DATASLOTOP: begin
494
+ target_0[31 :16 ] <= 16'h636D ;
495
+
496
+ target_dataslot_done <= 0 ;
497
+ tstate <= TARG_ST_WAITRESULT_DSO;
498
+ end
499
+ TARG_ST_WAITRESULT_DSO: begin
500
+ if (target_0[31 :16 ] == 16'h6275 ) begin
501
+ target_dataslot_ack <= 1 ;
502
+ end
503
+ if (target_0[31 :16 ] == 16'h6F6B ) begin
504
+ // done
505
+ // save result code
506
+ target_dataslot_err <= target_0[2 :0 ];
507
+ // assert done
508
+ target_dataslot_done <= 1 ;
509
+ tstate <= TARG_ST_IDLE;
510
+ end
414
511
end
415
- TARG_ST_WAITRESULT : begin
512
+ TARG_ST_WAITRESULT_RTR : begin
416
513
if (target_0[31 :16 ] == 16'h6F6B ) begin
417
514
// done
418
515
tstate <= TARG_ST_IDLE;
0 commit comments