@@ -40,11 +40,21 @@ input wire dataslot_requestread_ok,
4040
4141output reg dataslot_requestwrite,
4242output reg [15 :0 ] dataslot_requestwrite_id,
43+ output reg [31 :0 ] dataslot_requestwrite_size,
4344input wire dataslot_requestwrite_ack,
4445input wire dataslot_requestwrite_ok,
4546
47+ output reg dataslot_update,
48+ output reg [15 :0 ] dataslot_update_id,
49+ output reg [31 :0 ] dataslot_update_size,
50+
4651output reg dataslot_allcomplete,
4752
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+
4858input wire savestate_supported,
4959input wire [31 :0 ] savestate_addr,
5060input wire [31 :0 ] savestate_size,
@@ -64,6 +74,18 @@ input wire savestate_load_busy,
6474input wire savestate_load_ok,
6575input wire savestate_load_err,
6676
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+
6789input wire [9 :0 ] datatable_addr,
6890input wire datatable_wren,
6991input wire [31 :0 ] datatable_data,
@@ -146,37 +168,53 @@ localparam [3:0] ST_DONE_ERR = 'd15;
146168
147169localparam [3 :0 ] TARG_ST_IDLE = 'd0;
148170localparam [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;
155174 reg [3 :0 ] tstate;
156175
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;
159179
160180
161181initial begin
162182 reset_n <= 0 ;
163183 dataslot_requestread <= 0 ;
164184 dataslot_requestwrite <= 0 ;
185+ dataslot_update <= 0 ;
165186 dataslot_allcomplete <= 0 ;
187+ rtc_valid <= 0 ;
166188 savestate_start <= 0 ;
167189 savestate_load <= 0 ;
168190 osnotify_inmenu <= 0 ;
191+
169192 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 ;
170198end
171199
172200always @(posedge clk) begin
173201
174202 // detect a rising edge on the input signal
175203 // and flag a queue that will be cleared later
176204 status_setup_done_1 <= status_setup_done;
205+ target_dataslot_read_1 <= target_dataslot_read;
206+ target_dataslot_write_1 <= target_dataslot_write;
207+
177208 if (status_setup_done & ~ status_setup_done_1) begin
178209 status_setup_done_queue <= 1 ;
179210 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+
180218
181219 b_datatable_wren <= 0 ;
182220 b_datatable_addr <= bridge_addr >> 2 ;
@@ -257,6 +295,7 @@ always @(posedge clk) begin
257295
258296 dataslot_requestread <= 0 ;
259297 dataslot_requestwrite <= 0 ;
298+ dataslot_update <= 0 ;
260299 savestate_start <= 0 ;
261300 savestate_load <= 0 ;
262301
@@ -314,17 +353,34 @@ always @(posedge clk) begin
314353 dataslot_allcomplete <= 0 ;
315354 dataslot_requestwrite <= 1 ;
316355 dataslot_requestwrite_id <= host_20[15 :0 ];
356+ dataslot_requestwrite_size <= host_24;
317357 if (dataslot_requestwrite_ack) begin
318358 host_resultcode <= 0 ;
319359 if (! dataslot_requestwrite_ok) host_resultcode <= 2 ;
320360 hstate <= ST_DONE_CODE;
321361 end
322362 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
323370 16'h008F : begin
324371 // Data slot access all complete
325372 dataslot_allcomplete <= 1 ;
326373 hstate <= ST_DONE_OK;
327374 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
328384 16'h00A0 : begin
329385 // Savestate: Start/Query
330386 host_40 <= savestate_supported;
@@ -397,22 +453,63 @@ always @(posedge clk) begin
397453 endcase
398454
399455
400-
401-
402456 // target > host command executer
403457 case (tstate)
404458 TARG_ST_IDLE: begin
459+
460+ target_dataslot_ack <= 0 ;
461+
405462 if (status_setup_done_queue) begin
406463 status_setup_done_queue <= 0 ;
407464 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
410488 end
411489 TARG_ST_READYTORUN: begin
412490 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
414511 end
415- TARG_ST_WAITRESULT : begin
512+ TARG_ST_WAITRESULT_RTR : begin
416513 if (target_0[31 :16 ] == 16'h6F6B ) begin
417514 // done
418515 tstate <= TARG_ST_IDLE;
0 commit comments