Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CTU CAN FD IP Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
canbus
CTU CAN FD IP Core
Commits
3e8e8e64
Commit
3e8e8e64
authored
Jun 15, 2018
by
Martin Jeřábek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testwf: feature tests: wip
parent
e5c26452
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
482 additions
and
625 deletions
+482
-625
test/feature/abort_transmittion_feature_tb.vhd
test/feature/abort_transmittion_feature_tb.vhd
+26
-33
test/feature/arbitration_feature_tb.vhd
test/feature/arbitration_feature_tb.vhd
+44
-55
test/feature/fault_confinement_feature_tb.vhd
test/feature/fault_confinement_feature_tb.vhd
+22
-32
test/feature/forbid_fd_feature_tb.vhd
test/feature/forbid_fd_feature_tb.vhd
+29
-38
test/feature/interrupt_feature_tb.vhd
test/feature/interrupt_feature_tb.vhd
+75
-89
test/feature/invalid_configs_feature_tb.vhd
test/feature/invalid_configs_feature_tb.vhd
+23
-32
test/feature/overload_feature_tb.vhd
test/feature/overload_feature_tb.vhd
+35
-49
test/feature/pkg_feature_exec_dispatch.vhd
test/feature/pkg_feature_exec_dispatch.vhd
+30
-14
test/feature/retr_limit_feature_tb.vhd
test/feature/retr_limit_feature_tb.vhd
+26
-36
test/feature/rtr_pref_feature.vhd
test/feature/rtr_pref_feature.vhd
+5
-2
test/feature/rx_status_feature_tb.vhd
test/feature/rx_status_feature_tb.vhd
+27
-37
test/feature/spec_mode_feature_tb.vhd
test/feature/spec_mode_feature_tb.vhd
+39
-49
test/feature/tb_feature.vhd
test/feature/tb_feature.vhd
+15
-46
test/feature/traf_meas_feature_tb.vhd
test/feature/traf_meas_feature_tb.vhd
+20
-29
test/feature/tran_delay_feature_tb.vhd
test/feature/tran_delay_feature_tb.vhd
+16
-25
test/feature/tx_arb_time_tran_feature_tb.vhd
test/feature/tx_arb_time_tran_feature_tb.vhd
+27
-37
test/testfw/data/pkg_feature_exec_dispath-body.vhd
test/testfw/data/pkg_feature_exec_dispath-body.vhd
+20
-18
test/tests_fast.yml
test/tests_fast.yml
+3
-4
No files found.
test/feature/abort_transmittion_feature_tb.vhd
View file @
3e8e8e64
...
...
@@ -64,21 +64,18 @@ USE ieee.math_real.ALL;
use
work
.
CANconstants
.
all
;
USE
work
.
CANtestLib
.
All
;
USE
work
.
randomLib
.
All
;
use
work
.
pkg_feature_exec_dispath
.
all
;
use
work
.
CAN_FD_register_map
.
all
;
package
abort_transmittion_feature
is
procedure
abort_transmittion_feature_exec
(
variable
o
utcome
:
inout
boolean
;
variable
o
:
out
feature_outputs_t
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
mem_bus_1
:
inout
Avalon_mem_type
;
signal
mem_bus_2
:
inout
Avalon_mem_type
;
signal
bus_level
:
in
std_logic
;
signal
drv_bus_1
:
in
std_logic_vector
(
1023
downto
0
);
signal
drv_bus_2
:
in
std_logic_vector
(
1023
downto
0
);
signal
stat_bus_1
:
in
std_logic_vector
(
511
downto
0
);
signal
stat_bus_2
:
in
std_logic_vector
(
511
downto
0
)
signal
iout
:
in
instance_inputs_arr_t
;
signal
mem_bus
:
inout
mem_bus_arr_t
;
signal
bus_level
:
in
std_logic
);
end
package
;
...
...
@@ -87,15 +84,11 @@ end package;
package
body
abort_transmittion_feature
is
procedure
abort_transmittion_feature_exec
(
variable
o
utcome
:
inout
boolean
;
variable
o
:
out
feature_outputs_t
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
mem_bus_1
:
inout
Avalon_mem_type
;
signal
mem_bus_2
:
inout
Avalon_mem_type
;
signal
bus_level
:
in
std_logic
;
signal
drv_bus_1
:
in
std_logic_vector
(
1023
downto
0
);
signal
drv_bus_2
:
in
std_logic_vector
(
1023
downto
0
);
signal
stat_bus_1
:
in
std_logic_vector
(
511
downto
0
);
signal
stat_bus_2
:
in
std_logic_vector
(
511
downto
0
)
signal
iout
:
in
instance_inputs_arr_t
;
signal
mem_bus
:
inout
mem_bus_arr_t
;
signal
bus_level
:
in
std_logic
)
is
variable
r_data
:
std_logic_vector
(
31
downto
0
)
:
=
(
OTHERS
=>
'0'
);
...
...
@@ -115,7 +108,7 @@ package body abort_transmittion_feature is
variable
command
:
SW_command
:
=
(
false
,
false
,
false
);
variable
status
:
SW_status
;
begin
outcome
:
=
true
;
o
.
o
utcome
:
=
true
;
------------------------------------------------------------------------
-- Generate CAN frame
...
...
@@ -125,13 +118,13 @@ package body abort_transmittion_feature is
------------------------------------------------------------------------
-- Insert the frame for transmittion
------------------------------------------------------------------------
CAN_send_frame
(
CAN_frame
,
1
,
ID_1
,
mem_bus
_1
,
frame_sent
);
CAN_send_frame
(
CAN_frame
,
1
,
ID_1
,
mem_bus
(
1
)
,
frame_sent
);
------------------------------------------------------------------------
-- Wait until unit turns transmitter
------------------------------------------------------------------------
loop
get_controller_status
(
status
,
ID_1
,
mem_bus
_1
);
get_controller_status
(
status
,
ID_1
,
mem_bus
(
1
)
);
if
(
status
.
transmitter
)
then
exit
;
end
if
;
...
...
@@ -143,7 +136,7 @@ package body abort_transmittion_feature is
-- aborts immediately after the frame was commited and SOF was not
-- yet sent!
------------------------------------------------------------------------
wait_rand_cycles
(
rand_ctr
,
mem_bus
_1
.
clk_sys
,
200
,
25000
);
wait_rand_cycles
(
rand_ctr
,
mem_bus
(
1
)
.
clk_sys
,
200
,
25000
);
------------------------------------------------------------------------
-- Check that unit is not transciever anymore, unit should be now as if
...
...
@@ -151,7 +144,7 @@ package body abort_transmittion_feature is
-- space. So we check the PC_State from status bus explicitly.
------------------------------------------------------------------------
PC_State
:
=
protocol_type
'VAL
(
to_integer
(
unsigned
(
stat_bus_1
(
STAT_PC_STATE_HIGH
downto
STAT_PC_STATE_LOW
))));
iout
(
1
)
.
stat_bus
(
STAT_PC_STATE_HIGH
downto
STAT_PC_STATE_LOW
))));
report
"PC State: "
&
protocol_type
'Image
(
PC_State
);
if
(
PC_State
=
sof
or
PC_State
=
arbitration
or
PC_State
=
control
or
...
...
@@ -169,18 +162,18 @@ package body abort_transmittion_feature is
-- Now send the command to abort the transmittion
--------------------------------------------------------------------
command
.
abort_transmission
:
=
true
;
give_controller_command
(
command
,
ID_1
,
mem_bus
_1
);
give_controller_command
(
command
,
ID_1
,
mem_bus
(
1
)
);
--------------------------------------------------------------------
-- Now wait for few clock cycles until Node aborts the transmittion
--------------------------------------------------------------------
for
i
in
0
to
5
loop
wait
until
rising_edge
(
mem_bus
_1
.
clk_sys
);
wait
until
rising_edge
(
mem_bus
(
1
)
.
clk_sys
);
end
loop
;
get_controller_status
(
status
,
ID_1
,
mem_bus
_1
);
get_controller_status
(
status
,
ID_1
,
mem_bus
(
1
)
);
if
(
status
.
transmitter
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
--------------------------------------------------------------------
...
...
@@ -191,28 +184,28 @@ package body abort_transmittion_feature is
-- frame. It stays idle since it recieves recessive error passive
-- error frame from 2!
--------------------------------------------------------------------
CAN_wait_error_transmitted
(
ID_2
,
mem_bus
_2
);
CAN_wait_error_transmitted
(
ID_2
,
mem_bus
(
2
)
);
--------------------------------------------------------------------
-- Now wait until bus is idle in both units
--------------------------------------------------------------------
CAN_wait_bus_idle
(
ID_2
,
mem_bus
_2
);
CAN_wait_bus_idle
(
ID_1
,
mem_bus
_1
);
CAN_wait_bus_idle
(
ID_2
,
mem_bus
(
2
)
);
CAN_wait_bus_idle
(
ID_1
,
mem_bus
(
1
)
);
else
--------------------------------------------------------------------
-- Now wait until bus is idle in both units
--------------------------------------------------------------------
CAN_wait_bus_idle
(
ID_2
,
mem_bus
_2
);
CAN_wait_bus_idle
(
ID_1
,
mem_bus
_1
);
CAN_wait_bus_idle
(
ID_2
,
mem_bus
(
2
)
);
CAN_wait_bus_idle
(
ID_1
,
mem_bus
(
1
)
);
--------------------------------------------------------------------
-- Check that unit is now idle since it is after transmittion already
--------------------------------------------------------------------
get_controller_status
(
status
,
ID_1
,
mem_bus
_1
);
get_controller_status
(
status
,
ID_1
,
mem_bus
(
1
)
);
if
(
not
status
.
bus_status
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
end
if
;
...
...
@@ -228,7 +221,7 @@ package body abort_transmittion_feature is
err_counters
.
err_fd
:
=
0
;
err_counters
.
rx_counter
:
=
0
;
err_counters
.
tx_counter
:
=
0
;
set_error_counters
(
err_counters
,
ID_1
,
mem_bus
_1
);
set_error_counters
(
err_counters
,
ID_1
,
mem_bus
(
1
)
);
end
procedure
;
...
...
test/feature/arbitration_feature_tb.vhd
View file @
3e8e8e64
...
...
@@ -57,7 +57,7 @@
-- 5. Insert frames for transmission and give "set_ready" command.
-- 6. Wait until units start transmission.
-- 7. Wait until one of the units turn receiver or collision appears.
-- 8. Compare expected o
utcome with actual
outcome.
-- 8. Compare expected o
.outcome with actual o.
outcome.
-- 9. Wait until bus is idle.
--
--------------------------------------------------------------------------------
...
...
@@ -76,75 +76,64 @@ USE ieee.math_real.ALL;
use
work
.
CANconstants
.
all
;
USE
work
.
CANtestLib
.
All
;
USE
work
.
randomLib
.
All
;
use
work
.
pkg_feature_exec_dispath
.
all
;
use
work
.
CAN_FD_register_map
.
all
;
use
work
.
CAN_FD_frame_format
.
all
;
package
arbitration_feature
is
procedure
arbitration_feature_exec
(
variable
outcome
:
inout
boolean
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
mem_bus_1
:
inout
Avalon_mem_type
;
signal
mem_bus_2
:
inout
Avalon_mem_type
;
signal
bus_level
:
in
std_logic
;
signal
drv_bus_1
:
in
std_logic_vector
(
1023
downto
0
);
signal
drv_bus_2
:
in
std_logic_vector
(
1023
downto
0
);
signal
stat_bus_1
:
in
std_logic_vector
(
511
downto
0
);
signal
stat_bus_2
:
in
std_logic_vector
(
511
downto
0
)
variable
o
:
out
feature_outputs_t
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
iout
:
in
instance_inputs_arr_t
;
signal
mem_bus
:
inout
mem_bus_arr_t
;
signal
bus_level
:
in
std_logic
);
end
package
;
package
body
Arbitration_feature
is
procedure
arbitration_feature_exec
(
variable
outcome
:
inout
boolean
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
mem_bus_1
:
inout
Avalon_mem_type
;
signal
mem_bus_2
:
inout
Avalon_mem_type
;
signal
bus_level
:
in
std_logic
;
signal
drv_bus_1
:
in
std_logic_vector
(
1023
downto
0
);
signal
drv_bus_2
:
in
std_logic_vector
(
1023
downto
0
);
signal
stat_bus_1
:
in
std_logic_vector
(
511
downto
0
);
signal
stat_bus_2
:
in
std_logic_vector
(
511
downto
0
)
variable
o
:
out
feature_outputs_t
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
iout
:
in
instance_inputs_arr_t
;
signal
mem_bus
:
inout
mem_bus_arr_t
;
signal
bus_level
:
in
std_logic
)
is
variable
rand_value
:
real
;
variable
alc
:
natural
;
variable
rand_value
:
real
;
variable
alc
:
natural
;
-- 0-Node 1; 1-Node 2; 2-Collision
variable
exp_winner
:
natural
:
=
0
;
variable
exp_winner
:
natural
:
=
0
;
-- Some unit lost the arbitration...
-- 0 - initial , 1-Node 1 turned rec, 2 - Node 2 turned rec
variable
unit_rec
:
natural
:
=
0
;
variable
unit_rec
:
natural
:
=
0
;
variable
ID_1
:
natural
:
=
1
;
variable
ID_2
:
natural
:
=
2
;
variable
r_data
:
std_logic_vector
(
31
downto
0
)
:
=
(
OTHERS
=>
'0'
);
variable
ID_1
:
natural
:
=
1
;
variable
ID_2
:
natural
:
=
2
;
variable
r_data
:
std_logic_vector
(
31
downto
0
)
:
=
(
OTHERS
=>
'0'
);
-- Generated frames
variable
frame_1
:
SW_CAN_frame_type
;
variable
frame_2
:
SW_CAN_frame_type
;
variable
frame_1
:
SW_CAN_frame_type
;
variable
frame_2
:
SW_CAN_frame_type
;
-- Node status
variable
stat_1
:
SW_status
;
variable
stat_2
:
SW_status
;
variable
stat_1
:
SW_status
;
variable
stat_2
:
SW_status
;
-- Temporary variables for IDs recalculated to decimal value with
-- identifier type taken into account
variable
ident_1
:
natural
;
variable
ident_2
:
natural
;
variable
ident_1
:
natural
;
variable
ident_2
:
natural
;
begin
outcome
:
=
true
;
o
.
o
utcome
:
=
true
;
------------------------------------------------------------------------
-- Forbid retransmitt limiting!
------------------------------------------------------------------------
CAN_enable_retr_limit
(
false
,
0
,
ID_1
,
mem_bus
_1
);
CAN_enable_retr_limit
(
false
,
0
,
ID_2
,
mem_bus
_2
);
CAN_enable_retr_limit
(
false
,
0
,
ID_1
,
mem_bus
(
1
)
);
CAN_enable_retr_limit
(
false
,
0
,
ID_2
,
mem_bus
(
2
)
);
------------------------------------------------------------------------
-- Generate Two random CAN Frames.
...
...
@@ -268,21 +257,21 @@ package body Arbitration_feature is
------------------------------------------------------------------------
-- Insert both frames to transmitt.
------------------------------------------------------------------------
CAN_insert_TX_frame
(
frame_1
,
1
,
ID_1
,
mem_bus
_1
);
CAN_insert_TX_frame
(
frame_2
,
1
,
ID_2
,
mem_bus
_2
);
CAN_insert_TX_frame
(
frame_1
,
1
,
ID_1
,
mem_bus
(
1
)
);
CAN_insert_TX_frame
(
frame_2
,
1
,
ID_2
,
mem_bus
(
2
)
);
------------------------------------------------------------------------
-- Give "set_ready" command to TXT Buffers in both CAN Nodes!
------------------------------------------------------------------------
send_TXT_buf_cmd
(
buf_set_ready
,
1
,
ID_1
,
mem_bus
_1
);
send_TXT_buf_cmd
(
buf_set_ready
,
1
,
ID_2
,
mem_bus
_2
);
send_TXT_buf_cmd
(
buf_set_ready
,
1
,
ID_1
,
mem_bus
(
1
)
);
send_TXT_buf_cmd
(
buf_set_ready
,
1
,
ID_2
,
mem_bus
(
2
)
);
------------------------------------------------------------------------
-- Now we have to wait until both units starts to transmitt!!!
------------------------------------------------------------------------
loop
get_controller_status
(
stat_1
,
ID_1
,
mem_bus
_1
);
get_controller_status
(
stat_2
,
ID_2
,
mem_bus
_2
);
get_controller_status
(
stat_1
,
ID_1
,
mem_bus
(
1
)
);
get_controller_status
(
stat_2
,
ID_2
,
mem_bus
(
2
)
);
if
(
stat_1
.
transmitter
and
stat_2
.
transmitter
)
then
exit
;
end
if
;
...
...
@@ -294,8 +283,8 @@ package body Arbitration_feature is
------------------------------------------------------------------------
while
(
unit_rec
=
0
)
loop
get_controller_status
(
stat_1
,
ID_1
,
mem_bus
_1
);
get_controller_status
(
stat_2
,
ID_2
,
mem_bus
_2
);
get_controller_status
(
stat_1
,
ID_1
,
mem_bus
(
1
)
);
get_controller_status
(
stat_2
,
ID_2
,
mem_bus
(
2
)
);
-- Unit 1 turned reciever
if
(
stat_1
.
receiver
)
then
...
...
@@ -333,25 +322,25 @@ package body Arbitration_feature is
report
"Frame 2:"
;
CAN_print_frame
(
frame_2
,
info_l
);
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
------------------------------------------------------------------------
-- Send abort transmission to both frames so that no unit will
-- attempt to retransmitt.
------------------------------------------------------------------------
send_TXT_buf_cmd
(
buf_set_abort
,
1
,
ID_1
,
mem_bus
_1
);
send_TXT_buf_cmd
(
buf_set_abort
,
1
,
ID_2
,
mem_bus
_2
);
send_TXT_buf_cmd
(
buf_set_abort
,
1
,
ID_1
,
mem_bus
(
1
)
);
send_TXT_buf_cmd
(
buf_set_abort
,
1
,
ID_2
,
mem_bus
(
2
)
);
CAN_wait_frame_sent
(
ID_1
,
mem_bus
_1
);
CAN_wait_frame_sent
(
ID_1
,
mem_bus
(
1
)
);
------------------------------------------------------------------------
-- Check what is the value in the ALC register
------------------------------------------------------------------------
if
(
unit_rec
=
1
)
then
read_alc
(
alc
,
ID_1
,
mem_bus
_1
);
read_alc
(
alc
,
ID_1
,
mem_bus
(
1
)
);
elsif
(
unit_rec
=
2
)
then
read_alc
(
alc
,
ID_2
,
mem_bus
_2
);
read_alc
(
alc
,
ID_2
,
mem_bus
(
2
)
);
end
if
;
-- TODO: Compare ALC value with expected value where node should
...
...
@@ -368,7 +357,7 @@ package body Arbitration_feature is
report
"Frame 2:"
;
CAN_print_frame
(
frame_2
,
info_l
);
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
wait
for
100000
ns
;
...
...
test/feature/fault_confinement_feature_tb.vhd
View file @
3e8e8e64
...
...
@@ -54,39 +54,29 @@ USE ieee.math_real.ALL;
use
work
.
CANconstants
.
all
;
USE
work
.
CANtestLib
.
All
;
USE
work
.
randomLib
.
All
;
use
work
.
pkg_feature_exec_dispath
.
all
;
use
work
.
CAN_FD_register_map
.
all
;
package
fault_confinement_feature
is
procedure
fault_confinement_feature_exec
(
variable
outcome
:
inout
boolean
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
mem_bus_1
:
inout
Avalon_mem_type
;
signal
mem_bus_2
:
inout
Avalon_mem_type
;
signal
bus_level
:
in
std_logic
;
signal
drv_bus_1
:
in
std_logic_vector
(
1023
downto
0
);
signal
drv_bus_2
:
in
std_logic_vector
(
1023
downto
0
);
signal
stat_bus_1
:
in
std_logic_vector
(
511
downto
0
);
signal
stat_bus_2
:
in
std_logic_vector
(
511
downto
0
)
variable
o
:
out
feature_outputs_t
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
iout
:
in
instance_inputs_arr_t
;
signal
mem_bus
:
inout
mem_bus_arr_t
;
signal
bus_level
:
in
std_logic
);
end
package
;
package
body
fault_confinement_feature
is
procedure
fault_confinement_feature_exec
(
variable
outcome
:
inout
boolean
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
mem_bus_1
:
inout
Avalon_mem_type
;
signal
mem_bus_2
:
inout
Avalon_mem_type
;
signal
bus_level
:
in
std_logic
;
signal
drv_bus_1
:
in
std_logic_vector
(
1023
downto
0
);
signal
drv_bus_2
:
in
std_logic_vector
(
1023
downto
0
);
signal
stat_bus_1
:
in
std_logic_vector
(
511
downto
0
);
signal
stat_bus_2
:
in
std_logic_vector
(
511
downto
0
)
)
is
variable
o
:
out
feature_outputs_t
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
iout
:
in
instance_inputs_arr_t
;
signal
mem_bus
:
inout
mem_bus_arr_t
;
signal
bus_level
:
in
std_logic
)
is
variable
r_data
:
std_logic_vector
(
31
downto
0
)
:
=
(
OTHERS
=>
'0'
);
variable
CAN_frame
:
SW_CAN_frame_type
;
...
...
@@ -105,7 +95,7 @@ package body fault_confinement_feature is
variable
fault_th_2
:
SW_fault_thresholds
:
=
(
0
,
0
);
variable
fault_state
:
SW_fault_state
;
begin
outcome
:
=
true
;
o
.
o
utcome
:
=
true
;
------------------------------------------------------------------------
-- Generate random setting of ERP treshold and RX counters to preset
...
...
@@ -123,43 +113,43 @@ package body fault_confinement_feature is
------------------------------------------------------------------------
-- Set the counter and tresholds
------------------------------------------------------------------------
set_error_counters
(
err_counters
,
ID_1
,
mem_bus
_1
);
set_fault_thresholds
(
fault_th
,
ID_1
,
mem_bus
_1
);
set_error_counters
(
err_counters
,
ID_1
,
mem_bus
(
1
)
);
set_fault_thresholds
(
fault_th
,
ID_1
,
mem_bus
(
1
)
);
------------------------------------------------------------------------
-- Read counters back
------------------------------------------------------------------------
get_fault_thresholds
(
fault_th_2
,
ID_1
,
mem_bus
_1
);
get_fault_thresholds
(
fault_th_2
,
ID_1
,
mem_bus
(
1
)
);
if
(
fault_th
.
ewl
/=
fault_th_2
.
ewl
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
if
(
fault_th
.
erp
/=
fault_th_2
.
erp
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
------------------------------------------------------------------------
-- Read fault confinement state
------------------------------------------------------------------------
get_fault_state
(
fault_state
,
ID_1
,
mem_bus
_1
);
get_fault_state
(
fault_state
,
ID_1
,
mem_bus
(
1
)
);
if
(
err_counters
.
tx_counter
>
255
or
err_counters
.
rx_counter
>
255
)
then
if
(
fault_state
/=
fc_bus_off
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
elsif
(
err_counters
.
tx_counter
<
fault_th
.
ewl
and
err_counters
.
rx_counter
<
fault_th
.
ewl
)
then
if
(
fault_state
/=
fc_error_active
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
else
if
(
fault_state
/=
fc_error_passive
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
end
if
;
...
...
test/feature/forbid_fd_feature_tb.vhd
View file @
3e8e8e64
...
...
@@ -67,40 +67,31 @@ USE ieee.math_real.ALL;
use
work
.
CANconstants
.
all
;
USE
work
.
CANtestLib
.
All
;
USE
work
.
randomLib
.
All
;
use
work
.
pkg_feature_exec_dispath
.
all
;
use
work
.
CAN_FD_register_map
.
all
;
use
work
.
CAN_FD_frame_format
.
all
;
package
forbid_fd_feature
is
procedure
forbid_fd_feature_exec
(
variable
o
utcome
:
inout
boolean
;
variable
o
:
out
feature_outputs_t
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
mem_bus_1
:
inout
Avalon_mem_type
;
signal
mem_bus_2
:
inout
Avalon_mem_type
;
signal
bus_level
:
in
std_logic
;
signal
drv_bus_1
:
in
std_logic_vector
(
1023
downto
0
);
signal
drv_bus_2
:
in
std_logic_vector
(
1023
downto
0
);
signal
stat_bus_1
:
in
std_logic_vector
(
511
downto
0
);
signal
stat_bus_2
:
in
std_logic_vector
(
511
downto
0
)
signal
iout
:
in
instance_inputs_arr_t
;
signal
mem_bus
:
inout
mem_bus_arr_t
;
signal
bus_level
:
in
std_logic
);
end
package
;
package
body
forbid_fd_feature
is
procedure
forbid_fd_feature_exec
(
variable
o
utcome
:
inout
boolean
;
variable
o
:
out
feature_outputs_t
;
signal
rand_ctr
:
inout
natural
range
0
to
RAND_POOL_SIZE
;
signal
mem_bus_1
:
inout
Avalon_mem_type
;
signal
mem_bus_2
:
inout
Avalon_mem_type
;
signal
bus_level
:
in
std_logic
;
signal
drv_bus_1
:
in
std_logic_vector
(
1023
downto
0
);
signal
drv_bus_2
:
in
std_logic_vector
(
1023
downto
0
);
signal
stat_bus_1
:
in
std_logic_vector
(
511
downto
0
);
signal
stat_bus_2
:
in
std_logic_vector
(
511
downto
0
)
signal
iout
:
in
instance_inputs_arr_t
;
signal
mem_bus
:
inout
mem_bus_arr_t
;
signal
bus_level
:
in
std_logic
)
is
variable
r_data
:
std_logic_vector
(
31
downto
0
)
:
=
(
OTHERS
=>
'0'
);
...
...
@@ -115,52 +106,52 @@ package body forbid_fd_feature is
variable
err_counters_1
:
SW_error_counters
;
variable
err_counters_2
:
SW_error_counters
;
begin
outcome
:
=
true
;
o
.
o
utcome
:
=
true
;
------------------------------------------------------------------------
-- First disable the FD support of both Nodes. This is done to make
-- sure that both nodes have the same ISO type set.
------------------------------------------------------------------------
mode
.
flexible_data_rate
:
=
true
;
set_core_mode
(
mode
,
ID_2
,
mem_bus
_2
);
set_core_mode
(
mode
,
ID_2
,
mem_bus
(
2
)
);
mode
.
flexible_data_rate
:
=
false
;
set_core_mode
(
mode
,
ID_1
,
mem_bus
_1
);
set_core_mode
(
mode
,
ID_1
,
mem_bus
(
1
)
);
------------------------------------------------------------------------
-- Read RX Error counter node 1
------------------------------------------------------------------------
read_error_counters
(
err_counters_1
,
ID_1
,
mem_bus
_1
);
read_error_counters
(
err_counters_1
,
ID_1
,
mem_bus
(
1
)
);
------------------------------------------------------------------------
-- Send FD frame by node 2 and wait for error frame...
------------------------------------------------------------------------
CAN_generate_frame
(
rand_ctr
,
CAN_frame
);
CAN_frame
.
frame_format
:
=
FD_CAN
;
CAN_send_frame
(
CAN_frame
,
1
,
ID_2
,
mem_bus
_2
,
frame_sent
);
CAN_wait_error_transmitted
(
ID_2
,
mem_bus
_2
);
CAN_wait_bus_idle
(
ID_2
,
mem_bus
_2
);
CAN_send_frame
(
CAN_frame
,
1
,
ID_2
,
mem_bus
(
2
)
,
frame_sent
);
CAN_wait_error_transmitted
(
ID_2
,
mem_bus
(
2
)
);
CAN_wait_bus_idle
(
ID_2
,
mem_bus
(
2
)
);
------------------------------------------------------------------------
-- Read RX Error counter node 1 again
------------------------------------------------------------------------
read_error_counters
(
err_counters_2
,
ID_1
,
mem_bus
_1
);
read_error_counters
(
err_counters_2
,
ID_1
,
mem_bus
(
1
)
);
-- Counter should be increased
if
((
err_counters_1
.
rx_counter
+
1
+
8
)
/=
err_counters_2
.
rx_counter
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
------------------------------------------------------------------------
-- Now send the same frame, but not the FD type. Wait until bus is idle
------------------------------------------------------------------------
CAN_frame
.
frame_format
:
=
NORMAL_CAN
;
CAN_send_frame
(
CAN_frame
,
1
,
ID_2
,
mem_bus
_2
,
frame_sent
);
CAN_wait_frame_sent
(
ID_2
,
mem_bus
_2
);
CAN_send_frame
(
CAN_frame
,
1
,
ID_2
,
mem_bus
(
2
)
,
frame_sent
);
CAN_wait_frame_sent
(
ID_2
,
mem_bus
(
2
)
);
------------------------------------------------------------------------
-- Read RX Error counter node 1 again
------------------------------------------------------------------------
read_error_counters
(
err_counters_2
,
ID_1
,
mem_bus
_1
);
read_error_counters
(
err_counters_2
,
ID_1
,
mem_bus
(
1
)
);
------------------------------------------------------------------------
-- Counter should be decreased by one now due to sucesfull reception.
...
...
@@ -168,34 +159,34 @@ package body forbid_fd_feature is
-- detected the error!
------------------------------------------------------------------------
if
((
err_counters_1
.
rx_counter
+
8
)
/=
err_counters_2
.
rx_counter
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
------------------------------------------------------------------------
-- Now enable the FD support of Node 1
------------------------------------------------------------------------
mode
.
flexible_data_rate
:
=
true
;
set_core_mode
(
mode
,
ID_1
,
mem_bus
_1
);
set_core_mode
(
mode
,
ID_1
,
mem_bus
(
1
)
);
------------------------------------------------------------------------
-- Now again send the same frame but FD type now unit should accept
-- the frame OK!
------------------------------------------------------------------------
CAN_frame
.
frame_format
:
=
FD_CAN
;
CAN_send_frame
(
CAN_frame
,
1
,
ID_2
,
mem_bus
_2
,
frame_sent
);
CAN_wait_frame_sent
(
ID_2
,
mem_bus
_2
);
CAN_send_frame
(
CAN_frame
,
1
,
ID_2
,
mem_bus
(
2
)
,
frame_sent
);
CAN_wait_frame_sent
(
ID_2
,
mem_bus
(
2
)
);
------------------------------------------------------------------------
-- Read RX Error counter node 1 again
------------------------------------------------------------------------
read_error_counters
(
err_counters_2
,
ID_1
,
mem_bus
_1
);
read_error_counters
(
err_counters_2
,
ID_1
,
mem_bus
(
1
)
);
------------------------------------------------------------------------
-- Counter should be less than the value read now or both should be
-- zeroes when counter cannnot already be lowered...
------------------------------------------------------------------------
if
((
err_counters_1
.
rx_counter
+
7
)
/=
err_counters_2
.
rx_counter
)
then
outcome
:
=
false
;
o
.
o
utcome
:
=
false
;
end
if
;
------------------------------------------------------------------------
...
...
@@ -207,8 +198,8 @@ package body forbid_fd_feature is