NVC code coverage report

File:  /__w/ctu-can-regression/ctu-can-regression/test/main_tb/agents/reference_test_agent/reference_test_agent.vhd

     0:   -------------------------------------------------------------------------------- 
     1:   -- 
     2:   -- CTU CAN FD IP Core 
     3:   -- Copyright (C) 2021-2023 Ondrej Ille 
     4:   -- Copyright (C) 2023-     Logic Design Services Ltd.s 
     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:   -- non-commercial purposes. Using the Component for commercial purposes is 
    10:   -- forbidden unless previously agreed with Copyright holder. 
    11:   -- 
    12:   -- The above copyright notice and this permission notice shall be included in 
    13:   -- all copies or substantial portions of the Component. 
    14:   -- 
    15:   -- THE COMPONENT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    16:   -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    17:   -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    18:   -- AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    19:   -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
    20:   -- FROM, OUT OF OR IN CONNECTION WITH THE COMPONENT OR THE USE OR OTHER DEALINGS 
    21:   -- IN THE COMPONENT. 
    22:   -- 
    23:   -- The CAN protocol is developed by Robert Bosch GmbH and protected by patents. 
    24:   -- Anybody who wants to implement this IP core on silicon has to obtain a CAN 
    25:   -- protocol license from Bosch. 
    26:   -- 
    27:   -- ------------------------------------------------------------------------------- 
    28:   -- 
    29:   -- CTU CAN FD IP Core 
    30:   -- Copyright (C) 2015-2020 MIT License 
    31:   -- 
    32:   -- Authors: 
    33:   --     Ondrej Ille <ondrej.ille@gmail.com> 
    34:   --     Martin Jerabek <martin.jerabek01@gmail.com> 
    35:   -- 
    36:   -- Project advisors: 
    37:   -- 	Jiri Novak <jnovak@fel.cvut.cz> 
    38:   -- 	Pavel Pisa <pisa@cmp.felk.cvut.cz> 
    39:   -- 
    40:   -- Department of Measurement         (http://meas.fel.cvut.cz/) 
    41:   -- Faculty of Electrical Engineering (http://www.fel.cvut.cz) 
    42:   -- Czech Technical University        (http://www.cvut.cz/) 
    43:   -- 
    44:   -- Permission is hereby granted, free of charge, to any person obtaining a copy 
    45:   -- of this VHDL component and associated documentation files (the "Component"), 
    46:   -- to deal in the Component without restriction, including without limitation 
    47:   -- the rights to use, copy, modify, merge, publish, distribute, sublicense, 
    48:   -- and/or sell copies of the Component, and to permit persons to whom the 
    49:   -- Component is furnished to do so, subject to the following conditions: 
    50:   -- 
    51:   -- The above copyright notice and this permission notice shall be included in 
    52:   -- all copies or substantial portions of the Component. 
    53:   -- 
    54:   -- THE COMPONENT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
    55:   -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
    56:   -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
    57:   -- AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
    58:   -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
    59:   -- FROM, OUT OF OR IN CONNECTION WITH THE COMPONENT OR THE USE OR OTHER DEALINGS 
    60:   -- IN THE COMPONENT. 
    61:   -- 
    62:   -- The CAN protocol is developed by Robert Bosch GmbH and protected by patents. 
    63:   -- Anybody who wants to implement this IP core on silicon has to obtain a CAN 
    64:   -- protocol license from Bosch. 
    65:   -- 
    66:   -------------------------------------------------------------------------------- 
    67:    
    68:   -------------------------------------------------------------------------------- 
    69:   --  @Purpose: 
    70:   --    Reference test agent. Executes reference tests. 
    71:   -- 
    72:   --    Reference test agent is started by test controller agent, when test_type 
    73:   --    is configured to "reference". Reference test agent resets DUT, configures 
    74:   --    it, enables it and runs reference test sequence based on selected data 
    75:   --    set. 
    76:   -- 
    77:   --    Reference test agent uses CAN agent to apply reference test sequence to 
    78:   --    DUT and Memory bus agent to access DUT. 
    79:   -- 
    80:   --    Reference tests are ALWAYS run on 2 MBit/500 KBit with 80 % sample point! 
    81:   -- 
    82:   -------------------------------------------------------------------------------- 
    83:   -- Revision History: 
    84:   --    09.4.2021   Created file 
    85:   -------------------------------------------------------------------------------- 
    86:    
    87:   Library ctu_can_fd_tb; 
    88:   context ctu_can_fd_tb.ieee_context; 
    89:   context ctu_can_fd_tb.tb_common_context; 
    90:   context ctu_can_fd_tb.rtl_context; 
    91:   context ctu_can_fd_tb.tb_agents_context; 
    92:    
    93:   use ctu_can_fd_tb.reference_data_set_1.all; 
    94:   use ctu_can_fd_tb.reference_data_set_2.all; 
    95:   use ctu_can_fd_tb.reference_data_set_3.all; 
    96:   use ctu_can_fd_tb.reference_data_set_4.all; 
    97:   use ctu_can_fd_tb.reference_data_set_5.all; 
    98:   use ctu_can_fd_tb.reference_data_set_6.all; 
    99:   use ctu_can_fd_tb.reference_data_set_7.all; 
   100:   use ctu_can_fd_tb.reference_data_set_8.all; 
   101:   use ctu_can_fd_tb.reference_data_set_9.all; 
   102:   use ctu_can_fd_tb.reference_data_set_10.all; 
   103:    
   104:   use ctu_can_fd_tb.tb_shared_vars_pkg.all; 
   105:    
   106:   entity reference_test_agent is 
   107:       generic( 
   108:           -- Test details 
   109:           test_name               : string; 
   110:           test_type               : string; 
   111:           reference_iterations    : natural range 1 to 1000 
   112:       ); 
   113:   end entity; 
   114:    
   115:    
   116:   architecture tb of reference_test_agent is 
   117:    
   118:   begin 
   119:    
   120:       --------------------------------------------------------------------------- 
   121:       --------------------------------------------------------------------------- 
   122:       -- Test control process 
   123:       -- 
   124:       -- Waits on start request from Test controller agent and runs a test. 
   125:       --------------------------------------------------------------------------- 
   126:       --------------------------------------------------------------------------- 
   127:       test_process : process 
   128:           -- 2 Mbit / 500 Kbit, 80 % sample point 
   129:           variable bus_timing     : t_ctu_bit_time_cfg := 
   130:               (2, 1, 40, 39, 20, 10, 20, 14, 15, 10); 
   131:           variable data_set : t_reference_data_set; 
   132:           variable driver_item : t_can_driver_entry := 
   133:               ('0', 0 ns, false, (OTHERS => '0')); 
   134:           variable rx_frame : t_ctu_frame; 
   135:           variable result : boolean; 
   136:           variable reference_offset : natural; 
   137:       begin 
   138:           wait until reference_start = '1'; 
   139:    
   140:           -- Pre-set test to be "passed", any error will make it fail 
   141:           ctu_vip_test_result.set_result(true); 
   142:    
   143:           -- Configure bit timing 
   144:           ctu_set_bit_time_cfg(bus_timing, DUT_NODE, default_channel); 
   145:    
   146:           -- Enable CAN controllers 
   147:           ctu_turn(true, DUT_NODE, default_channel); 
   148:           info_m("DUT is ON"); 
   149:    
   150:           -- Wait till integration is over in both nodes 
   151:           ctu_wait_err_active(DUT_NODE, default_channel); 
   152:           info_m("Bus integration finished"); 
   153:    
   154:           if (test_name = "data_set_1") then 
   155:               data_set := C_reference_data_set_1; 
   156:           elsif (test_name = "data_set_2") then 
   157:               data_set := C_reference_data_set_2; 
   158:           elsif (test_name = "data_set_3") then 
   159:               data_set := C_reference_data_set_3; 
   160:           elsif (test_name = "data_set_4") then 
   161:               data_set := C_reference_data_set_4; 
   162:           elsif (test_name = "data_set_5") then 
   163:               data_set := C_reference_data_set_5; 
   164:           elsif (test_name = "data_set_6") then 
   165:               data_set := C_reference_data_set_6; 
   166:           elsif (test_name = "data_set_7") then 
   167:               data_set := C_reference_data_set_7; 
   168:           elsif (test_name = "data_set_8") then 
   169:               data_set := C_reference_data_set_8; 
   170:           elsif (test_name = "data_set_9") then 
   171:               data_set := C_reference_data_set_9; 
   172:           elsif (test_name = "data_set_10") then 
   173:               data_set := C_reference_data_set_10; 
   174:           else 
   175:               error_m("Invalid reference test data set"); 
   176:           end if; 
   177:    
   178:           ----------------------------------------------------------------------- 
   179:           -- Test sequence itself 
   180:           ----------------------------------------------------------------------- 
   181:           rand_int_v(898, reference_offset); 
   182:           reference_offset := reference_offset + 1; 
   183:    
   184:           for frame_index in reference_offset to reference_offset + reference_iterations loop 
   185:    
   186:               info_m("Testing frame nr: " & integer'image(frame_index - reference_offset)); 
   187:               info_m("Frame position in dataset: " & integer'image(frame_index)); 
   188:    
   189:               info_m("Pushing frame to CAN agent..."); 
   190:               can_agent_driver_flush(default_channel); 
   191:               for seq_ind in 1 to data_set(frame_index).seq_len loop 
   192:    
   193:                   driver_item.value := data_set(frame_index).seq(seq_ind).value; 
   194:                   driver_item.drive_time := data_set(frame_index).seq(seq_ind).drive_time; 
   195:                   can_agent_driver_push_item(default_channel, driver_item); 
   196:               end loop; 
   197:    
   198:               info_m("Running CAN Agent driver..."); 
   199:               can_agent_driver_start(default_channel); 
   200:               can_agent_driver_wait_finish(default_channel); 
   201:    
   202:               info_m("Reading out CAN frame..."); 
   203:               ctu_read_frame(rx_frame, DUT_NODE, default_channel); 
   204:    
   205:               info_m("Comparing received vs golden frame..."); 
   206:               -- Pre-calculate RWCNT of TX frame 
   207:               dlc_to_rwcnt(data_set(frame_index).frame.dlc, data_set(frame_index).frame.rwcnt); 
   208:               compare_can_frames(rx_frame, data_set(frame_index).frame, false, result); 
   209:    
   210:               check_m(result, "Frames equal"); 
   211:           end loop; 
   212:    
   213:           -- Signal test is done. 
   214:           reference_result <= ctu_vip_test_result.get_result; 
   215:           wait for 0 ns; 
   216:           reference_done <= '1'; 
   217:           wait until reference_start = '0'; 
   218:           reference_done <= '0'; 
   219:           wait for 0 ns; 
   220:    
   221:       end process; 
   222:    
   223:   end architecture;