@@ -115,6 +115,7 @@ module ccc
115
115
input logic bus_rx_done_i,
116
116
output logic bus_rx_req_bit_o,
117
117
output logic bus_rx_req_byte_o,
118
+ input logic arbitration_lost_i,
118
119
119
120
// Addr match interface
120
121
input logic [6 : 0 ] target_sta_address_i,
@@ -334,6 +335,29 @@ module ccc
334
335
end
335
336
end
336
337
338
+ // Mux TX access between regular CCC and ENTDAA
339
+ logic entdaa_tx_req_bit;
340
+ logic entdaa_tx_req_byte;
341
+ logic entdaa_tx_req_value;
342
+ logic entdaa_tx_sel_od_pp;
343
+ logic entdaa_rx_req_bit;
344
+ logic entdaa_rx_req_byte;
345
+ logic ccc_tx_req_bit;
346
+ logic ccc_tx_req_byte;
347
+ logic ccc_tx_req_value;
348
+ logic ccc_tx_sel_od_pp;
349
+ logic ccc_rx_req_bit;
350
+ logic ccc_rx_req_byte;
351
+
352
+ always_comb begin : mux_bus_access
353
+ bus_tx_req_bit_o = entdaa_o ? entdaa_tx_req_bit : ccc_tx_req_bit;
354
+ bus_tx_req_byte_o = entdaa_o ? entdaa_tx_req_byte : ccc_tx_req_byte;
355
+ bus_tx_req_value_o = entdaa_o ? entdaa_tx_req_value : ccc_tx_req_value;
356
+ bus_tx_sel_od_pp_o = entdaa_o ? entdaa_tx_sel_od_pp : ccc_tx_sel_od_pp;
357
+ bus_rx_req_bit_o = entdaa_o ? entdaa_rx_req_bit : ccc_rx_req_bit;
358
+ bus_rx_req_byte_o = entdaa_o ? entdaa_rx_req_byte : ccc_rx_req_byte;
359
+ end
360
+
337
361
logic have_defining_byte;
338
362
always_comb begin : defining_byte_ccc
339
363
case (command_code)
@@ -346,7 +370,6 @@ module ccc
346
370
endcase
347
371
end
348
372
349
- // TODO: Handle Bcast CCCs
350
373
typedef enum logic [7 : 0 ] {
351
374
Idle,
352
375
WaitCCC,
@@ -364,12 +387,14 @@ module ccc
364
387
TxDataTbit,
365
388
WaitForBusCond,
366
389
WaitForStop,
367
- DoneCCC
390
+ DoneCCC,
391
+ HandleENTDAA
368
392
} state_e ;
369
393
370
394
state_e state_q, state_d;
371
395
372
396
assign last_tbit_valid = (state_q == RxTbit || state_q == RxDataTbit) && bus_rx_done_i;
397
+ assign entdaa_o = (state_q == HandleENTDAA);
373
398
374
399
always_ff @ (posedge clk_i or negedge rst_ni) begin : register_tbit
375
400
if (~ rst_ni) begin
@@ -400,6 +425,8 @@ module ccc
400
425
401
426
logic [7 : 0 ] rx_data_count;
402
427
428
+ logic entdaa_start, entdaa_done;
429
+
403
430
always_comb begin : addr_matching
404
431
if (target_dyn_address_valid_i) begin
405
432
is_byte_our_addr = command_addr == target_dyn_address_i;
@@ -461,7 +488,7 @@ module ccc
461
488
if (have_defining_byte) state_d = RxDefByte;
462
489
else begin
463
490
// ENTDAA is special
464
- if (command_code == ENTDAA ) state_d = HandleENTDAA;
491
+ if (command_code == `I3C_BCAST_ENTDAA ) state_d = HandleENTDAA;
465
492
// broadcast CCCs
466
493
else if (~ is_direct_cmd) state_d = RxData;
467
494
// direct CCCs
@@ -470,6 +497,9 @@ module ccc
470
497
end
471
498
end
472
499
end
500
+ HandleENTDAA: begin
501
+ if (entdaa_done) state_d = Idle;
502
+ end
473
503
RxDefByte: begin
474
504
if (bus_rx_done_i) state_d = RxDefByteTbit;
475
505
end
@@ -545,13 +575,13 @@ module ccc
545
575
546
576
547
577
always_comb begin : state_outputs
548
- bus_rx_req_bit_o = '0 ;
549
- bus_rx_req_byte_o = '0 ;
578
+ ccc_rx_req_bit = '0 ;
579
+ ccc_rx_req_byte = '0 ;
550
580
551
- bus_tx_req_byte_o = '0 ;
552
- bus_tx_req_bit_o = '0 ;
553
- bus_tx_req_value_o = '0 ;
554
- bus_tx_sel_od_pp_o = '0 ;
581
+ ccc_tx_req_byte = '0 ;
582
+ ccc_tx_req_bit = '0 ;
583
+ ccc_tx_req_value = '0 ;
584
+ ccc_tx_sel_od_pp = '0 ;
555
585
556
586
done_fsm_o = '0 ;
557
587
unique case (state_q)
@@ -562,57 +592,57 @@ module ccc
562
592
563
593
end
564
594
RxTbit: begin
565
- bus_rx_req_bit_o = '1 ;
566
- bus_rx_req_byte_o = '0 ;
595
+ ccc_rx_req_bit = '1 ;
596
+ ccc_rx_req_byte = '0 ;
567
597
end
568
598
RxDefByte: begin
569
- bus_rx_req_bit_o = '0 ;
570
- bus_rx_req_byte_o = '1 ;
599
+ ccc_rx_req_bit = '0 ;
600
+ ccc_rx_req_byte = '1 ;
571
601
end
572
602
RxDefByteTbit: begin
573
- bus_rx_req_bit_o = '1 ;
574
- bus_rx_req_byte_o = '0 ;
603
+ ccc_rx_req_bit = '1 ;
604
+ ccc_rx_req_byte = '0 ;
575
605
end
576
606
RxByte: begin
577
- bus_rx_req_bit_o = '0 ;
578
- bus_rx_req_byte_o = '1 ;
579
- if (bus_rstart_det_i) bus_rx_req_byte_o = '0 ;
607
+ ccc_rx_req_bit = '0 ;
608
+ ccc_rx_req_byte = '1 ;
609
+ if (bus_rstart_det_i) ccc_rx_req_byte = '0 ;
580
610
end
581
611
RxDirectDefByteTbit: begin
582
- bus_rx_req_bit_o = '1 ;
583
- bus_rx_req_byte_o = '0 ;
612
+ ccc_rx_req_bit = '1 ;
613
+ ccc_rx_req_byte = '0 ;
584
614
end
585
615
RxDirectAddr: begin
586
- bus_rx_req_bit_o = '0 ;
587
- bus_rx_req_byte_o = '1 ;
616
+ ccc_rx_req_bit = '0 ;
617
+ ccc_rx_req_byte = '1 ;
588
618
end
589
619
TxDirectAddrAck: begin
590
- bus_tx_req_byte_o = '0 ;
591
- bus_tx_req_bit_o = '1 ;
592
- bus_tx_req_value_o = { 7'h00 , ~ (is_byte_our_addr | is_byte_rsvd_addr | is_byte_virtual_addr)} ;
620
+ ccc_tx_req_byte = '0 ;
621
+ ccc_tx_req_bit = '1 ;
622
+ ccc_tx_req_value = { 7'h00 , ~ (is_byte_our_addr | is_byte_rsvd_addr | is_byte_virtual_addr)} ;
593
623
end
594
624
RxSubCmdByte: begin
595
625
end
596
626
RxData: begin
597
- bus_rx_req_bit_o = '0 ;
598
- bus_rx_req_byte_o = '1 ;
599
- if (bus_rstart_det_i) bus_rx_req_byte_o = '0 ;
627
+ ccc_rx_req_bit = '0 ;
628
+ ccc_rx_req_byte = '1 ;
629
+ if (bus_rstart_det_i) ccc_rx_req_byte = '0 ;
600
630
end
601
631
RxDataTbit: begin
602
- bus_rx_req_bit_o = '1 ;
603
- bus_rx_req_byte_o = '0 ;
632
+ ccc_rx_req_bit = '1 ;
633
+ ccc_rx_req_byte = '0 ;
604
634
end
605
635
TxData: begin
606
- bus_tx_req_byte_o = '1 ;
607
- bus_tx_req_bit_o = '0 ;
608
- bus_tx_req_value_o = tx_data;
609
- bus_tx_sel_od_pp_o = '1 ;
636
+ ccc_tx_req_byte = '1 ;
637
+ ccc_tx_req_bit = '0 ;
638
+ ccc_tx_req_value = tx_data;
639
+ ccc_tx_sel_od_pp = '1 ;
610
640
end
611
641
TxDataTbit: begin
612
- bus_tx_req_byte_o = '0 ;
613
- bus_tx_req_bit_o = '1 ;
614
- bus_tx_req_value_o = { 7'h00 , ~ tx_data_done} ;
615
- bus_tx_sel_od_pp_o = '1 ;
642
+ ccc_tx_req_byte = '0 ;
643
+ ccc_tx_req_bit = '1 ;
644
+ ccc_tx_req_value = { 7'h00 , ~ tx_data_done} ;
645
+ ccc_tx_sel_od_pp = '1 ;
616
646
end
617
647
DoneCCC: begin
618
648
done_fsm_o = '1 ;
@@ -947,7 +977,38 @@ module ccc
947
977
assign ent_hdr_5_o = '0 ;
948
978
assign ent_hdr_6_o = '0 ;
949
979
assign ent_hdr_7_o = '0 ;
950
- assign set_newda_o = '0 ;
951
- assign newda_o = '0 ;
952
980
981
+
982
+ ccc_entdaa xccc_entdaa (
983
+ .clk_i, // Clock
984
+ .rst_ni, // Async reset, active low
985
+ .id_i,
986
+
987
+ .start_daa_i (entdaa_start),
988
+ .done_daa_o (entdaa_done),
989
+
990
+ // Bus RX interface
991
+ .bus_rx_data_i,
992
+ .bus_rx_done_i,
993
+ .bus_rx_req_bit_o (entdaa_rx_req_bit),
994
+ .bus_rx_req_byte_o (entdaa_rx_req_byte),
995
+
996
+ // Bus TX interface
997
+ .bus_tx_done_i,
998
+ .bus_tx_req_byte_o (entdaa_tx_req_byte),
999
+ .bus_tx_req_bit_o (entdaa_tx_req_bit),
1000
+ .bus_tx_req_value_o (entdaa_tx_req_value),
1001
+ .bus_tx_sel_od_pp_o (entdaa_tx_sel_od_pp),
1002
+
1003
+ // Bus Monitor interface
1004
+ .bus_rstart_det_i,
1005
+ .bus_stop_det_i,
1006
+
1007
+ // bus access
1008
+ .arbitration_lost_i,
1009
+
1010
+ // addr
1011
+ .address_o (newda_o),
1012
+ .address_valid_o (set_newda_o)
1013
+ );
953
1014
endmodule
0 commit comments