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
3470b74c
Commit
3470b74c
authored
Jun 13, 2018
by
Ille, Ondrej, Ing.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Brought up fault confinement feature test.
parent
a8e2b97d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
118 deletions
+98
-118
test/feature/fault_confinement_feature_tb.vhd
test/feature/fault_confinement_feature_tb.vhd
+98
-118
No files found.
test/feature/fault_confinement_feature_tb.vhd
View file @
3470b74c
...
...
@@ -59,130 +59,110 @@ use work.CAN_FD_register_map.all;
package
fault_conf_feature
is
procedure
fault_conf_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
;
--Additional signals for tests
--Pretty much everything can be read out of stat bus...
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
)
);
procedure
fault_conf_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
)
);
end
package
;
package
body
fault_conf_feature
is
procedure
fault_conf_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
;
--Additional signals for tests
--Pretty much everything can be read out of stat bus...
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
r_data
:
std_logic_vector
(
31
downto
0
):
=
(
OTHERS
=>
'0'
);
variable
CAN_frame
:
SW_CAN_frame_type
;
variable
frame_sent
:
boolean
:
=
false
;
variable
ctr_1
:
natural
;
variable
ctr_2
:
natural
;
variable
ID_1
:
natural
:
=
1
;
variable
ID_2
:
natural
:
=
2
;
variable
rand_val
:
real
;
variable
th_1
:
natural
:
=
0
;
variable
rxc
:
natural
:
=
0
;
variable
txc
:
natural
:
=
0
;
begin
outcome
:
=
true
;
-----------------------------------------------
-- Generate random setting of ERP treshold
-- and RX counters to preset
-----------------------------------------------
rand_real_v
(
rand_ctr
,
rand_val
);
th_1
:
=
integer
(
rand_val
*
254
.
0
);
rand_real_v
(
rand_ctr
,
rand_val
);
rxc
:
=
integer
(
rand_val
*
257
.
0
);
rand_real_v
(
rand_ctr
,
rand_val
);
txc
:
=
integer
(
rand_val
*
257
.
0
);
-----------------------------------------------
-- Set the counter and tresholds
-----------------------------------------------
r_data
:
=
(
OTHERS
=>
'0'
);
r_data
(
ERP_LIMIT_H
downto
ERP_LIMIT_L
):
=
std_logic_vector
(
to_unsigned
(
th_1
,
8
));
CAN_write
(
r_data
,
EWL_ADR
,
ID_1
,
mem_bus_1
);
r_data
:
=
(
OTHERS
=>
'0'
);
r_data
(
CTPV_H
downto
CTPV_L
):
=
std_logic_vector
(
to_unsigned
(
txc
,
9
));
r_data
(
PTX_IND
):
=
'1'
;
CAN_write
(
r_data
,
CTR_PRES_ADR
,
ID_1
,
mem_bus_1
);
r_data
:
=
(
OTHERS
=>
'0'
);
r_data
(
CTPV_H
downto
CTPV_L
):
=
std_logic_vector
(
to_unsigned
(
rxc
,
9
));
r_data
(
PRX_IND
):
=
'1'
;
CAN_write
(
r_data
,
CTR_PRES_ADR
,
ID_1
,
mem_bus_1
);
-----------------------------------------------
-- Read counters back
-----------------------------------------------
CAN_read
(
r_data
,
RXC_ADR
,
ID_1
,
mem_bus_1
);
if
(
to_integer
(
unsigned
(
r_data
(
RXC_VAL_H
downto
RXC_VAL_L
)))
/=
rxc
)
then
outcome
:
=
false
;
end
if
;
if
(
to_integer
(
unsigned
(
r_data
(
TXC_VAL_H
downto
TXC_VAL_L
)))
/=
txc
)
then
outcome
:
=
false
;
end
if
;
-----------------------------------------------
-- Read fault confinement state
-----------------------------------------------
CAN_read
(
r_data
,
EWL_ADR
,
ID_1
,
mem_bus_1
);
if
(
txc
>
255
or
rxc
>
255
)
then
if
(
r_data
(
ERA_IND
)
=
'1'
or
r_data
(
ERP_IND
)
=
'1'
or
r_data
(
BOF_IND
)
=
'0'
)
then
outcome
:
=
false
;
end
if
;
elsif
(
txc
<
th_1
and
rxc
<
th_1
)
then
if
(
r_data
(
ERA_IND
)
=
'0'
or
r_data
(
ERP_IND
)
=
'1'
or
r_data
(
BOF_IND
)
=
'1'
)
then
outcome
:
=
false
;
end
if
;
else
if
(
r_data
(
ERA_IND
)
=
'1'
or
r_data
(
ERP_IND
)
=
'0'
or
r_data
(
BOF_IND
)
=
'1'
)
then
outcome
:
=
false
;
end
if
;
end
if
;
procedure
fault_conf_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
r_data
:
std_logic_vector
(
31
downto
0
)
:
=
(
OTHERS
=>
'0'
);
variable
CAN_frame
:
SW_CAN_frame_type
;
variable
frame_sent
:
boolean
:
=
false
;
variable
ctr_1
:
natural
;
variable
ctr_2
:
natural
;
variable
ID_1
:
natural
:
=
1
;
variable
ID_2
:
natural
:
=
2
;
variable
rand_val
:
real
;
variable
th_1
:
natural
:
=
0
;
variable
rxc
:
natural
:
=
0
;
variable
txc
:
natural
:
=
0
;
variable
err_counters
:
SW_error_counters
;
variable
fault_th
:
SW_fault_thresholds
:
=
(
0
,
0
);
variable
fault_th_2
:
SW_fault_thresholds
:
=
(
0
,
0
);
variable
fault_state
:
SW_fault_state
;
begin
outcome
:
=
true
;
------------------------------------------------------------------------
-- Generate random setting of ERP treshold and RX counters to preset
------------------------------------------------------------------------
rand_real_v
(
rand_ctr
,
rand_val
);
fault_th
.
erp
:
=
integer
(
rand_val
*
254
.
0
);
rand_real_v
(
rand_ctr
,
rand_val
);
err_counters
.
rx_counter
:
=
integer
(
rand_val
*
257
.
0
);
rand_real_v
(
rand_ctr
,
rand_val
);
err_counters
.
tx_counter
:
=
integer
(
rand_val
*
257
.
0
);
------------------------------------------------------------------------
-- 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
);
------------------------------------------------------------------------
-- Read counters back
------------------------------------------------------------------------
get_fault_thresholds
(
fault_th_2
,
ID_1
,
mem_bus_1
);
if
(
fault_th
.
ewl
/=
fault_th_2
.
ewl
)
then
outcome
:
=
false
;
end
if
;
if
(
fault_th
.
erp
/=
fault_th_2
.
erp
)
then
outcome
:
=
false
;
end
if
;
end
procedure
;
------------------------------------------------------------------------
-- Read fault confinement state
------------------------------------------------------------------------
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
;
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
;
end
if
;
else
if
(
fault_state
/=
fc_error_passive
)
then
outcome
:
=
false
;
end
if
;
end
if
;
end
procedure
;
end
package
body
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment