Skip to content

Commit d12bafc

Browse files
committed
Merge branch 'additional-rx-buffer-tests' into 'master'
Additional rx buffer tests See merge request canbus/ctucanfd_ip_core!507
2 parents cd8b685 + 8b5de1e commit d12bafc

16 files changed

Lines changed: 529 additions & 15 deletions

src/can_core/protocol_control_fsm.vhd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,9 +2149,7 @@ begin
21492149
stuff_enable_clear <= '1';
21502150

21512151
if (rx_trigger = '1') then
2152-
if (is_receiver = '1') then
2153-
crc_check <= '1';
2154-
end if;
2152+
crc_check <= '1';
21552153

21562154
if (rx_data_nbs = DOMINANT) then
21572155
form_err_i <= '1';

src/common_blocks/clk_gate.vhd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ begin
108108
g_tech_asic : if (G_TECHNOLOGY = C_TECH_ASIC) generate
109109

110110
-- Latching enable - transparent in zero since we use AND gating
111-
clk_en_latch_proc : process(clk_in, clk_en)
111+
clk_en_latch_proc : process(clk_in, clk_en, scan_enable)
112112
begin
113113
if (clk_in = '0') then
114114
clk_en_q <= clk_en or scan_enable;

src/rx_buffer/rx_buffer.vhd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ begin
474474
store_data_f => store_data_f, -- IN
475475
rec_valid_f => rec_valid_f, -- IN
476476
rec_abort_f => rec_abort_f, -- IN
477-
rec_erf => rec_erf, -- IN
477+
rec_erf => rec_erf, -- OUT
478478

479479
write_raw_intent => write_raw_intent, -- OUT
480480
select_ts_wptr => select_ts_wptr, -- OUT

test/main_tb/agents/feature_test_agent/feature_test_agent_pkg.vhd

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,12 @@ package feature_test_agent_pkg is
178178
tx_buf_backup : boolean;
179179
parity_check : boolean;
180180
error_logging : boolean;
181+
self_acknowledge : boolean;
181182
end record;
182183

183184
constant SW_mode_rst_val : SW_mode := (false, false, false, false, false,
184185
true, false, false, false, true, false, false, false, true, true,
185-
false, false, false, false);
186+
false, false, false, false, false);
186187

187188
-- Controller commands
188189
type SW_command is record
@@ -3690,6 +3691,10 @@ package body feature_test_agent_pkg is
36903691
data(ERFM_IND mod 16) := '1';
36913692
end if;
36923693

3694+
if (mode.self_acknowledge) then
3695+
data(SAM_IND mod 16) := '1';
3696+
end if;
3697+
36933698
CAN_write(data, MODE_ADR, node, channel);
36943699

36953700
-- Following modes are stored in SETTINGS register
@@ -3759,6 +3764,7 @@ package body feature_test_agent_pkg is
37593764
mode.tx_buf_backup := false;
37603765
mode.parity_check := false;
37613766
mode.error_logging := false;
3767+
mode.self_acknowledge := false;
37623768

37633769
if (data(RST_IND) = '1') then
37643770
mode.reset := true;
@@ -3808,6 +3814,10 @@ package body feature_test_agent_pkg is
38083814
mode.error_logging := true;
38093815
end if;
38103816

3817+
if (data(SAM_IND) = '1') then
3818+
mode.self_acknowledge := true;
3819+
end if;
3820+
38113821
-- SETTINGs part of read data
38123822

38133823
if (data(NISOFD_IND) = '0') then

test/main_tb/agents/feature_test_agent/feature_test_list_pkg.vhd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ use ctu_can_fd_tb.mode_pex_ftest.all;
160160
use ctu_can_fd_tb.mode_restr_op_ftest.all;
161161
use ctu_can_fd_tb.mode_test_ftest.all;
162162
use ctu_can_fd_tb.mode_self_test_ftest.all;
163+
use ctu_can_fd_tb.mode_self_acknowledge_ftest.all;
163164
use ctu_can_fd_tb.mode_frame_filters_ftest.all;
164165
use ctu_can_fd_tb.mode_rst_ftest.all;
165166
use ctu_can_fd_tb.mode_rxbam_ftest.all;
@@ -204,6 +205,8 @@ use ctu_can_fd_tb.rx_err_log_4_ftest.all;
204205
use ctu_can_fd_tb.rx_err_log_5_ftest.all;
205206
use ctu_can_fd_tb.rx_err_log_6_ftest.all;
206207
use ctu_can_fd_tb.rx_err_log_7_ftest.all;
208+
use ctu_can_fd_tb.rx_err_log_8_ftest.all;
209+
use ctu_can_fd_tb.rx_err_log_timestamp_ftest.all;
207210
use ctu_can_fd_tb.rx_err_log_back_to_back_ftest.all;
208211

209212
use ctu_can_fd_tb.scan_mode_ftest.all;
@@ -406,6 +409,8 @@ package body feature_test_list_pkg is
406409
mode_test_ftest_exec(channel);
407410
elsif (test_name = "mode_self_test") then
408411
mode_self_test_ftest_exec(channel);
412+
elsif (test_name = "mode_self_acknowledge") then
413+
mode_self_acknowledge_ftest_exec(channel);
409414
elsif (test_name = "mode_frame_filters") then
410415
mode_frame_filters_ftest_exec(channel);
411416
elsif (test_name = "mode_rst") then
@@ -488,6 +493,10 @@ package body feature_test_list_pkg is
488493
rx_err_log_6_ftest_exec(channel);
489494
elsif (test_name = "rx_err_log_7") then
490495
rx_err_log_7_ftest_exec(channel);
496+
elsif (test_name = "rx_err_log_8") then
497+
rx_err_log_8_ftest_exec(channel);
498+
elsif (test_name = "rx_err_log_timestamp") then
499+
rx_err_log_timestamp_ftest_exec(channel);
491500
elsif (test_name = "rx_err_log_back_to_back") then
492501
rx_err_log_back_to_back_ftest_exec(channel);
493502

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
--------------------------------------------------------------------------------
2+
--
3+
-- CTU CAN FD IP Core
4+
-- Copyright (C) 2021-present Ondrej Ille
5+
--
6+
-- Permission is hereby granted, free of charge, to any person obtaining a copy
7+
-- of this VHDL component and associated documentation files (the "Component"),
8+
-- to use, copy, modify, merge, publish, distribute the Component for
9+
-- educational, research, evaluation, self-interest purposes. Using the
10+
-- Component for commercial purposes is forbidden unless previously agreed with
11+
-- Copyright holder.
12+
--
13+
-- The above copyright notice and this permission notice shall be included in
14+
-- all copies or substantial portions of the Component.
15+
--
16+
-- THE COMPONENT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
-- AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
-- FROM, OUT OF OR IN CONNECTION WITH THE COMPONENT OR THE USE OR OTHER DEALINGS
22+
-- IN THE COMPONENT.
23+
--
24+
-- The CAN protocol is developed by Robert Bosch GmbH and protected by patents.
25+
-- Anybody who wants to implement this IP core on silicon has to obtain a CAN
26+
-- protocol license from Bosch.
27+
--
28+
-- -------------------------------------------------------------------------------
29+
--
30+
-- CTU CAN FD IP Core
31+
-- Copyright (C) 2015-2020 MIT License
32+
--
33+
-- Authors:
34+
-- Ondrej Ille <ondrej.ille@gmail.com>
35+
-- Martin Jerabek <martin.jerabek01@gmail.com>
36+
--
37+
-- Project advisors:
38+
-- Jiri Novak <jnovak@fel.cvut.cz>
39+
-- Pavel Pisa <pisa@cmp.felk.cvut.cz>
40+
--
41+
-- Department of Measurement (http://meas.fel.cvut.cz/)
42+
-- Faculty of Electrical Engineering (http://www.fel.cvut.cz)
43+
-- Czech Technical University (http://www.cvut.cz/)
44+
--
45+
-- Permission is hereby granted, free of charge, to any person obtaining a copy
46+
-- of this VHDL component and associated documentation files (the "Component"),
47+
-- to deal in the Component without restriction, including without limitation
48+
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
49+
-- and/or sell copies of the Component, and to permit persons to whom the
50+
-- Component is furnished to do so, subject to the following conditions:
51+
--
52+
-- The above copyright notice and this permission notice shall be included in
53+
-- all copies or substantial portions of the Component.
54+
--
55+
-- THE COMPONENT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58+
-- AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
60+
-- FROM, OUT OF OR IN CONNECTION WITH THE COMPONENT OR THE USE OR OTHER DEALINGS
61+
-- IN THE COMPONENT.
62+
--
63+
-- The CAN protocol is developed by Robert Bosch GmbH and protected by patents.
64+
-- Anybody who wants to implement this IP core on silicon has to obtain a CAN
65+
-- protocol license from Bosch.
66+
--
67+
--------------------------------------------------------------------------------
68+
69+
--------------------------------------------------------------------------------
70+
-- @TestInfoStart
71+
--
72+
-- @Purpose:
73+
-- Self acknowledge mode test
74+
--
75+
-- @Verifies:
76+
-- @1. When MODE[SAM] = 1 and CTU CAN FD transmits a frame, then it will
77+
-- send dominant ACK bit.
78+
--
79+
-- @Test sequence:
80+
-- @1. Configure Self acknowledge mode in DUT Node.
81+
-- @2. Send frame by DUT. Wait till ACK field in DUT Node.
82+
-- @3. Check that DUT Node is transmitting Dominant value. Wait until bus
83+
-- is idle.
84+
--
85+
-- @TestInfoEnd
86+
--------------------------------------------------------------------------------
87+
-- Revision History:
88+
-- 8.9.2024 Created file
89+
--------------------------------------------------------------------------------
90+
91+
Library ctu_can_fd_tb;
92+
context ctu_can_fd_tb.ieee_context;
93+
context ctu_can_fd_tb.rtl_context;
94+
context ctu_can_fd_tb.tb_common_context;
95+
96+
use ctu_can_fd_tb.feature_test_agent_pkg.all;
97+
98+
package mode_self_acknowledge_ftest is
99+
procedure mode_self_acknowledge_ftest_exec(
100+
signal chn : inout t_com_channel
101+
);
102+
end package;
103+
104+
105+
package body mode_self_acknowledge_ftest is
106+
procedure mode_self_acknowledge_ftest_exec(
107+
signal chn : inout t_com_channel
108+
) is
109+
variable CAN_TX_frame : SW_CAN_frame_type;
110+
variable CAN_RX_frame : SW_CAN_frame_type;
111+
variable frame_sent : boolean := false;
112+
variable mode_1 : SW_mode := SW_mode_rst_val;
113+
variable mode_2 : SW_mode := SW_mode_rst_val;
114+
115+
variable txt_buf_state : SW_TXT_Buffer_state_type;
116+
variable rx_buf_state : SW_RX_Buffer_info;
117+
variable status : SW_status;
118+
variable frames_equal : boolean := false;
119+
variable pc_dbg : SW_PC_Debug;
120+
121+
variable can_tx : std_logic;
122+
begin
123+
124+
------------------------------------------------------------------------
125+
-- @1. Configures Self Acknowledge mode in DUT.
126+
------------------------------------------------------------------------
127+
info_m("Step 1");
128+
129+
mode_1.self_acknowledge := true;
130+
set_core_mode(mode_1, DUT_NODE, chn);
131+
132+
------------------------------------------------------------------------
133+
-- @2. Send frame by DUT. Wait till ACK field in DUT Node.
134+
------------------------------------------------------------------------
135+
info_m("Step 2");
136+
137+
CAN_generate_frame(CAN_TX_frame);
138+
CAN_send_frame(CAN_TX_frame, 1, DUT_NODE, chn, frame_sent);
139+
CAN_wait_pc_state(pc_deb_ack, DUT_NODE, chn);
140+
CAN_wait_sync_seg(DUT_NODE, chn);
141+
wait for 20 ns;
142+
143+
------------------------------------------------------------------------
144+
-- @3. Check that DUT Node is transmitting Dominant value.
145+
-- Wait until bus is idle.
146+
------------------------------------------------------------------------
147+
info_m("Step 3");
148+
149+
get_can_tx(DUT_NODE, can_tx, chn);
150+
check_m(can_tx = DOMINANT, "DUT transmits dominant ACK when MODE[SAM]=1");
151+
CAN_wait_bus_idle(DUT_NODE, chn);
152+
153+
end procedure;
154+
155+
end package body;

test/main_tb/feature_tests/rx_err_log_2_ftest.vhd

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ package body rx_err_log_2_ftest is
164164
CAN_wait_pc_state(pc_deb_crc_delim, DUT_NODE, chn);
165165
wait for 20 ns;
166166
flip_bus_level(chn);
167-
CAN_wait_sample_point(DUT_NODE, chn);
167+
CAN_wait_sample_point(DUT_NODE, chn, false);
168168
wait for 20 ns;
169169
release_bus_level(chn);
170170

@@ -188,7 +188,11 @@ package body rx_err_log_2_ftest is
188188
check_m(err_frame.erf = '1', "FRAME_FORMAT_W[ERF] = 1");
189189
check_m(err_frame.ivld = '1', "FRAME_FORMAT_W[IVLD] = 1");
190190
check_m(err_frame.erf_pos = ERC_POS_ACK, "FRAME_FORMAT_W[ERF_POS] = ERC_POS_ACK");
191-
check_m(err_frame.erf_type = ERC_FRM_ERR, "FRAME_FORMAT_W[ERF_TYPE] = ERC_FRM_ERR");
191+
192+
-- When we manage to flip just the stuff bit due to randomization, it will be stuff error
193+
-- not from error!
194+
check_m(err_frame.erf_type = ERC_FRM_ERR or err_frame.erf_type = ERC_STUF_ERR,
195+
"FRAME_FORMAT_W[ERF_TYPE] = ERC_FRM_ERR or FRAME_FORMAT_W[ERF_TYPE] = ERC_STUF_ERR");
192196

193197
CAN_wait_bus_idle(DUT_NODE, chn);
194198

test/main_tb/feature_tests/rx_err_log_3_ftest.vhd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ package body rx_err_log_3_ftest is
174174

175175
flip_bus_level(chn);
176176

177-
CAN_wait_sample_point(DUT_NODE, chn);
177+
CAN_wait_sample_point(DUT_NODE, chn, false);
178178
wait for 20 ns;
179179

180180
release_bus_level(chn);
@@ -319,7 +319,7 @@ package body rx_err_log_3_ftest is
319319
wait for 20 ns;
320320
flip_bus_level(chn);
321321

322-
CAN_wait_sample_point(DUT_NODE, chn);
322+
CAN_wait_sample_point(DUT_NODE, chn, false);
323323
wait for 20 ns;
324324

325325
release_bus_level(chn);

test/main_tb/feature_tests/rx_err_log_6_ftest.vhd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ package body rx_err_log_6_ftest is
174174

175175
CAN_wait_sync_seg(DUT_NODE, chn);
176176
flip_bus_level(chn);
177-
CAN_wait_sample_point(DUT_NODE, chn);
177+
CAN_wait_sample_point(DUT_NODE, chn, false);
178178
wait for 20 ns;
179179
release_bus_level(chn);
180180

test/main_tb/feature_tests/rx_err_log_7_ftest.vhd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ package body rx_err_log_7_ftest is
162162
CAN_generate_frame(tx_frame_2);
163163
tx_frame_2.rtr := NO_RTR_FRAME;
164164
tx_frame_2.data_length := 8;
165+
-- To avoid SSP. If error is detected in SSP, DUT Node does not react immediately, but
166+
-- delays until next regular sample point!
167+
tx_frame_2.brs := BR_NO_SHIFT;
165168
decode_length(tx_frame_2.data_length, tx_frame_2.dlc);
166169

167170
CAN_send_frame(tx_frame_2, 1, DUT_NODE, chn, frame_sent);
@@ -175,7 +178,7 @@ package body rx_err_log_7_ftest is
175178

176179
CAN_wait_sync_seg(DUT_NODE, chn);
177180
flip_bus_level(chn);
178-
CAN_wait_sample_point(DUT_NODE, chn);
181+
CAN_wait_sample_point(DUT_NODE, chn, false);
179182
wait for 20 ns;
180183
release_bus_level(chn);
181184

0 commit comments

Comments
 (0)