Skip to content

Commit 113f4d6

Browse files
committed
entdaa: send id
1 parent 9f73798 commit 113f4d6

File tree

1 file changed

+50
-8
lines changed

1 file changed

+50
-8
lines changed

src/ctrl/ccc_entdaa.sv

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,38 @@ module ccc_entdaa
4242
AckRsvdByte = 'h3,
4343
SendNack = 'h4,
4444
SendID = 'h5,
45-
LostArbitration = 'h6,
46-
ReceiveAddr = 'h7,
47-
AckAddr = 'h8,
48-
Done = 'h9,
49-
Error = 'ha
45+
PrepareIDBit = 'h6,
46+
SendIDBit = 'h7,
47+
LostArbitration = 'h8,
48+
ReceiveAddr = 'h9,
49+
AckAddr = 'ha,
50+
Done = 'hb,
51+
Error = 'hc
5052
} state_e;
5153

5254
state_e state_q, state_d;
5355
logic [5:0] id_bit_count;
56+
logic load_id_counter, tick_id_counter;
5457
logic reserved_word_det;
5558

5659
logic parity_ok;
5760

5861
assign reserved_word_det = (bus_rx_data_i[7:1] == 7'h7e && bus_rx_data_i[0] == 1'b1);
5962

63+
always_ff @(posedge clk_i or negedge rst_ni) begin: id_bit_counter
64+
if (!rst_ni) begin
65+
id_bit_count <= '0;
66+
end else begin
67+
if (load_id_counter) begin
68+
id_bit_count <= 6'd48;
69+
end else if (tick_id_counter) begin
70+
id_bit_count <= id_bit_count - 1'b1;
71+
end else begin
72+
id_bit_count <= id_bit_count;
73+
end
74+
end
75+
end
76+
6077
always_comb begin: state_functions
6178
state_d = state_q;
6279
unique case (state_q)
@@ -78,20 +95,34 @@ module ccc_entdaa
7895
end
7996
AckRsvdByte: begin
8097
if (bus_tx_done_i) begin
81-
state_d = SendID;
82-
end
98+
state_d = SendID;
99+
end
83100
end
84101
SendNack: begin
85102
if (bus_tx_done_i) begin
86103
state_d = Error;
87-
end
104+
end
88105
end
89106
SendID: begin
107+
// load ID counter
108+
state_d = PrepareIDBit;
109+
end
110+
PrepareIDBit: begin
111+
if (id_bit_count != '0) begin
112+
state_d = SendIDBit;
113+
end
114+
end
115+
SendIDBit: begin
90116
if (bus_tx_done_i) begin
91117
// our Id was overwritten by some other device
92118
if (arbitration_lost_i) begin
93119
state_d = LostArbitration;
94120
end
121+
if (id_bit_count == '0) begin
122+
state_d = ReceiveAddr;
123+
end else begin
124+
state_d = PrepareIDBit;
125+
end
95126
end
96127
end
97128
LostArbitration: begin
@@ -120,6 +151,9 @@ module ccc_entdaa
120151
bus_tx_req_bit_o = '0;
121152
bus_tx_req_value_o = '0;
122153
bus_tx_sel_od_pp_o = '0;
154+
155+
load_id_counter = '0;
156+
tick_id_counter = '0;
123157
unique case (state_q)
124158
Idle: begin
125159
end
@@ -138,6 +172,14 @@ module ccc_entdaa
138172
bus_tx_req_value_o = '1;
139173
end
140174
SendID: begin
175+
load_id_counter = '1;
176+
end
177+
PrepareIDBit: begin
178+
tick_id_counter = '1;
179+
end
180+
SendIDBit: begin
181+
bus_tx_req_bit_o = '1;
182+
bus_tx_req_value_o = id_i[id_bit_count];
141183
end
142184
ReceiveAddr: begin
143185
bus_rx_req_byte_o = '1;

0 commit comments

Comments
 (0)