Bosch - Users Manual VHDL Reference Can
Bosch - Users Manual VHDL Reference Can
Reference CAN
User’s Manual
Revision 2.2
K8/EIS
1999
VHDL Reference CAN User’s Manual Revision 2.2
Disclaimer
ROBERT BOSCH GMBH, MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
ROBERT BOSCH GMBH, RESERVES THE RIGHT TO MAKE CHANGES WITHOUT FURTHER
NOTICE TO THE PRODUCTS DESCRIBED HEREIN. ROBERT BOSCH GMBH DOES NOT
ASSUME ANY LIABILITY ARISING OUT OF THE APPLICATION OR USE OF ANY PRODUCT
OR CIRCUIT DESCRIBED HEREIN.
i K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Conventions
The following conventions are used in this User’s Manual:
COURIER BOLD Names of entities, architectures, configurations, processes, functions,
types, signals, and variables
courier bold File names, shell commands
<courier bold> Should be replaced by a specific name
E = <name of entity>
P = <name of process>
A = <name of architecture>
ii K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Contents
1 Introduction ....................................................................................................... 1
2 Installation.......................................................................................................... 2
3 Compilation and Simulation............................................................................. 3
3.1 Starting the Simulation..................................................................................................... 4
3.1.1 Simulating the User’s Implementation................................................................. 4
3.1.2 Simulating the Example of an Implementation.................................................... 5
3.1.3 Simulating the Example of a Buggy Implementation .......................................... 5
3.2 Test programs................................................................................................................... 6
3.2.1 baudrate ................................................................................................................ 6
3.2.2 biterror.................................................................................................................. 6
3.2.3 btl.......................................................................................................................... 9
3.2.4 crc ....................................................................................................................... 10
3.2.5 dlc ....................................................................................................................... 11
3.2.6 emlcount ............................................................................................................. 12
3.2.7 extd_id................................................................................................................ 17
3.2.8 formerr................................................................................................................ 18
3.2.9 idle...................................................................................................................... 20
3.2.10 overload.............................................................................................................. 21
3.2.11 stuff bit ............................................................................................................... 22
3.2.12 stufferr ................................................................................................................ 22
3.2.13 txarb.................................................................................................................... 24
4 Model Description............................................................................................ 27
4.1 PROTOCOL_TESTBENCH ......................................................................................... 29
4.2 CAN_SYSTEM ............................................................................................................. 30
4.2.1 configuration SYS_I of CAN_SYSTEM ........................................................... 31
4.2.2 configuration SYS_E of CAN_SYSTEM .......................................................... 31
4.2.3 configuration SYS_B of CAN_SYSTEM.......................................................... 31
4.2.4 configuration SYS_R of CAN_SYSTEM.......................................................... 31
4.3 BUS_INTERFACE ........................................................................................................ 32
4.4 CAN_INTERFACE ....................................................................................................... 33
4.4.1 architecture COMPARE..................................................................................... 34
4.4.1.1 CHECKER ........................................................................................... 35
4.4.2 architecture REFERENCE ................................................................................. 38
4.4.2.1 process OSCILLATOR........................................................................ 39
4.4.2.2 process PRESCALER .......................................................................... 39
4.4.2.3 process BIT_TIMING.......................................................................... 39
4.4.2.3.1 Overview ............................................................................. 39
4.4.2.3.2 Structure of process BIT_TIMING ..................................... 40
4.4.2.3.3 Synchronization ................................................................... 41
4.4.2.4 process BIT_STREAM_PROCESSOR ............................................... 46
4.4.2.4.1 Overview ............................................................................. 46
4.4.2.4.2 Frame Format ...................................................................... 47
4.4.2.4.3 Structure of process BIT_STREAM_PROCESSOR........... 48
4.4.2.5 Output to the Trace File ....................................................................... 54
4.4.2.6 CAN Specification and Reference CAN Model .................................. 56
4.4.2.7 Special Features of architecture REFERENCE for Protocol Check.... 57
iii K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
iv K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
1 Introduction
The VHDL Reference CAN Model is intended for semiconductor designers/manufacturers who want to
build their own implementation of a CAN device using VHDL as hardware description language. It is
provided in addition to the existing C Reference CAN Model.
The user of this model is expected to be familiar with the CAN Specification Revision 2.0 Part A and B.
The model is supplied together with a testbench supporting the following features:
• CAN Protocol Version 2.0 Part A, B
• Flexible testbench environment
• Simulates entire CAN bus system (number of nodes defined by user)
• Easy inclusion of user-defined implementations
• Test program set can be extended by user
• Run time information stored in trace files
• Generation of pattern files supported
The following support is provided to assist the user in working with the model and in understanding its
functionality:
• Detailed User Manual
• Example of a correct implementation for fast start-up
• Example of a buggy implementation for the demonstration of the testbench’s functionality
• Well documented source code
This model was developed and verified with Synopsys VSS v3.4b, Mentor Graphics QuickHDL
v8.5_4.6f and with Mentor Graphics ModelSim 5.2b. A portation to other VHDL Simulators will require
an adaption of the ‘make’ files.
Typically a CAN implementation consists of three major parts:
• Interface to the CPU
• CAN Protocol Controller
• Message Memory
Using the test programs supplied with this VHDL Reference CAN Model only assures the conformity of
the CAN Protocol Controller part of an implementation with CAN Protocol Version 2.0 Part A, B. In
order to verify the correct function of the CPU interface and of the message memory, the user has to write
additional test programs.
-1- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
2 Installation
To install the VHDL Reference CAN Model from the CD-ROM please proceed the following way:
1) Create a directory where you want to install the database by typing:
mkdir <path_to_model>/Bosch_CAN
Example: mkdir /projects/Bosch_CAN
2) Copy the TAR file RefCAN_Revision_2.2.tar to this directory.
3) Untar the database:
tar xvf RefCAN_Revision_2.2.tar
The setting of the environment variable BOSCH_CAN_ROOT should be done by your project setup
procedure. Please check also that your VHDL simulator is set up correctly before proceeding.
Please check README_RefCAN.txt in your Bosch_CAN directory for additional information about
your release of the VHDL Reference CAN model.
In appendix A-1 of this document you find a list of the files and directories together with a short
description.
The VHDL Reference CAN model was developed and tested on a Sun workstation running Solaris 2.5.
If you have another hardware or operating system please contact your system manager or check the
documentation of your hardware/operating system. Up to now, the model is available for UNIX systems
only.
Simulations were done with Synopsys VSS v3.4b, Mentor Graphics QuickHDL v8.5_4.6f and Mentor
Graphics ModelSim 5.2b.
-2- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
-3- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
After the simulation of program <test> there will be a file <test>.trace in the directory
$BOSCH_CAN_ROOT/tests/<test>. This file contains the complete trace information of the
simulation run. It can be regarded as protocol and documentation of the simulation. To check whether
the installation of the model and the setup of the simulator are correct, compare the file <test>.trace,
which is generated by the simulation, with the file <test>.trace.sav, which is distributed with the
model.
The two files have to be, with one restriction, identical. The files may not be absolutely identical because
in any VHDL simulation, when several processes are triggered by the same event, the sequence of
evaluation is not predictable. For this reason the sequence of trace statements with the same time stamp
may be different when simulated with different simulation-software or -hardware. The comparison of
two trace files generated by different tools can be automated when the lines of both trace files are sorted
alphabetically. The files <test>.trace.sav have been generated by the tool Synopsys VSS v3.4b.
If you are simulating with Synopsys VSS, and if the simulation runs without a problem, you will see the
following messages on the screen:
vhdlsim -nc -i $BOSCH_CAN_ROOT/simulate/synopsys_sim.inc \
CAN_LIBRARY.cfg_baudrate ;
VSS_GATE_MODEL=sim_gs - for gate level simulation
"Set stop on FAILURE"
"Start simulation"
955680 NS
Assertion NOTE at 955680 NS in design unit CHECKER(BEHAVIOUR) from process \
/PROTOCOL_TESTBENCH/SYSTEM/CHECK1/PROTOCOL_CHECK/COMPARE_RX_MESSAGE:
"Received Message checked ok"
-4- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
1447710 NS
Assertion NOTE at 1447710 NS in design unit CHECKER(BEHAVIOUR) from process \
/PROTOCOL_TESTBENCH/SYSTEM/CHECK1/PROTOCOL_CHECK/COMPARE_RX_MESSAGE:
"Received Message checked ok"
3285128 NS
Assertion FAILURE at 3285128 NS in design unit TEST_PROGRAM(BAUDRATE) from \
process /PROTOCOL_TESTBENCH/WAVEFORM/STIMULI:
"End of Test Program reached: Stop Simulation !"
"Quit simulator"
mv -f trace $BOSCH_CAN_ROOT/tests/baudrate/baudrate.trace ;
if [ -s pattern ] ; then mv -f pattern $BOSCH_CAN_ROOT/tests/baudrate/. ; fi ;
The last statement of the test program is an assertion with a certain FAILURE to terminate the simulation
because this is the only way to stop a simulation that was not started with an explicit run time.
The user’s implementation model which is used here is a copy of the CAN reference model.
During the simulation there will appear some messages on the screen like the one below:
3493250 NS
Assertion ERROR at 3493250 NS in design unit CHECKER(BEHAVIOUR) \
from process /PROTOCOL_TESTBENCH/SYSTEM/CHECK1/PROTOCOL_CHECK/CMP_RX:
“Protocol Error: Invalid BUSMON”
These messages will give you a hint where the problem may be located. The trace information of the
simulation run can be found in file btl.b_trace
-5- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
3.2.1 baudrate
Test of Prescaler and Oscillator Tolerance
NUMBER_OF_CANS: 3
Bit Timing: Different Bit Timing for each Node
This architecture uses a system configuration with three CAN nodes. The first CAN node consists of one
implementation CAN model and one Reference CAN Model node working in parallel, the other two
nodes consist of Reference CAN Model nodes. Each node gets a different timing configuration,
depending on different clock periods. The resulting minimum and maximum bit time are in an area of
1.7% around the average bit time. In three cycles, the three nodes start the transmission of a message. In
the first cycle, the third node wins the arbitration, in the second cycle, the second node, and in the third
cycle, the first node wins the arbitration. As additional handicap, the messages transmitted are designed
to contain a maximum of stuff bits, reducing the number of edges that can be used for resynchronisation.
Those nodes losing arbitration do that immediately next to a stuff bit.
After the last transmission, when the bus is idle, the position of the sample point in the scaled bit time is
checked by applying a spike to dominant at the RECEIVE_DATA inputs of the implementation CAN
model and of the Reference CAN Model node which is running in parallel to the implementation.
As long as the spike is not longer than the sum of Propagation Delay Segment and Phase Buffer
Segment 1, the dominant bus level is not sampled. Note: Even if the spike is not sampled, it is used for
synchronisation.
3.2.2 biterror
Confinement of Bit Errors
NUMBER_OF_CANS: 2
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
-6- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
-7- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4) Dominant bit at first bit of Intermission, recessive bit at first bit of Overload Flag.
The first bit of Intermission is forced to dominant to create an Overload Flag. Then the first bit of
this Overload Flag is forced to recessive. The transmitter detects a bit error and sends an Active
Error Flag. The transmit error counter is increased by 8.
5) Dominant bit at first bit of Intermission, recessive bit at last bit of Overload Flag.
The first bit of Intermission is forced to dominant to create an Overload Flag. Then the last bit of
this Overload Flag is forced to recessive. The transmitter detects a bit error and sends an Active
Error Flag. The transmit error counter is increased by 8.
6) Dominant bit at first bit of Data Length Code.
A recessive bit of Data Length Code is forced to dominant. The transmitter detects a bit error and
sends an Active Error Flag. The transmit error counter is increased by 8.
7) Recessive bit at last bit of Data Length Code.
A dominant bit of Data Length Code is forced to recessive. The transmitter detects a bit error and
sends an Active Error Flag. The transmit error counter is increased by 8.
8) Dominant bit at first bit of Data Field.
A recessive bit of Data Field is forced to dominant. The transmitter detects a bit error and sends an
Active Error Flag. The transmit error counter is increased by 8.
9) Recessive bit at 8th bit of Data Field.
A dominant bit of Data Field is forced to recessive. The transmitter detects a bit error and sends an
Active Error Flag. The transmit error counter is increased by 8.
10) Dominant bit at first bit of CRC Field.
A recessive bit of CRC Field is forced to dominant. The transmitter detects a bit error and sends an
Active Error Flag. The transmit error counter is increased by 8.
11) Recessive bit at last bit of CRC Field.
A dominant bit of CRC Field is forced to recessive. The transmitter detects a bit error and sends an
Active Error Flag. The transmit error counter is increased by 8.
12) Create Active Error Flags until transmitter is Error Passive.
When sending an Active Error Flag the RECEIVE_DATA input of the transmitter is forced to
recessive for 3 bit times. The transmitter detects bit errors at every bit and starts Active Error Flags.
With every bit error the transmit error counter is increased by 8. Then the last Active Error Flag is
sent and the transmitter becomes Error Passive, but it continues sending the Active Error Flag.
13) Recessive bit at Start of Frame.
The dominant Start of Frame bit is forced to recessive. The transmitter detects a bit error and sends
a Passive Error Flag. The transmit error counter is increased by 8.
14) Recessive bit at reserved bit, dominant bit at first bit of Passive Error Flag.
A dominant reserved bit is forced to recessive. The transmitter detects a bit error and sends a Passive
Error Flag. The transmit error counter is increased by 8.
The first bit of the passive Transmitter Error Flag is forced to dominant. The transmitter detects a
bit error and starts sending a Passive Error Flag again. The transmit error counter is not changed.
15) Dominant bit at last bit of Passive Error Flag.
The last bit of a Passive Error Flag is forced to dominant. The transmitter detects a bit error and starts
sending a Passive Error Flag again. The receive error counter is not changed.
-8- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
16) Dominant bit at first bit of Intermission, recessive bit at first bit of Overload Flag.
The first bit of Intermission is forced to dominant to create an Overload Flag. Then the first bit of
this Overload Flag is forced to recessive. The transmitter detects a bit error and sends a Passive Error
Flag. The transmit error counter is increased by 8.
17) Dominant bit at first bit of Intermission, recessive bit at last bit of Overload Flag.
The first bit of Intermission is forced to dominant to create an Overload Flag. Then the last bit of
this Overload Flag is forced to recessive. The transmitter detects a bit error and sends a Passive Error
Flag. The transmit error counter is increased by 8.
18) Dominant bit at first bit of Data Length Code.
A recessive bit of Data Length Code is forced to dominant. The transmitter detects a bit error and
sends a Passive Error Flag. The transmit error counter is increased by 8.
19) Recessive bit at last bit of Data Length Code.
A dominant bit of Data Length Code is forced to recessive. The transmitter detects a bit error and
sends a Passive Error Flag. The transmit error counter is increased by 8.
20) Dominant bit at first bit of Data Field.
A recessive bit of Data Field is forced to dominant. The transmitter detects a bit error and sends a
Passive Error Flag. The transmit error counter is increased by 8.
21) Recessive bit at 8th bit of Data Field.
A dominant bit of Data Field is forced to recessive. The transmitter detects a bit error and sends a
Passive Error Flag. The transmit error counter is increased by 8.
22) Dominant bit at first bit of CRC Field.
A recessive bit of CRC Field is forced to dominant. The transmitter detects a bit error and sends a
Passive Error Flag. The transmit error counter is increased by 8.
23) Recessive bit at last bit of CRC Field.
A dominant bit of CRC Field is forced to recessive. The transmitter detects a bit error and sends a
Passive Error Flag. The transmit error counter is increased by 8.
3.2.3 btl
Bit Timing
NUMBER_OF_CANS: 1
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
To test Hard Synchronization and Resynchronization, an edge from recessive to dominant is generated
for each time quanta of a bit time. The case of an edge immediately before the sample point is excluded.
The program runs three configurations of the bit timing:
1) Large Phase Buffer, Large Synchronization Jump Width
NTQ = 10, SAMPLE = 6, RESYCHRONIZATION_JUMP_WIDDTH = 4
2) Large Phase Buffer, Small Synchronization Jump Width
NTQ = 25, SAMPLE = 17, RESYCHRONIZATION_JUMP_WIDDTH = 1
3) Small Phase Buffer, Small Synchronization Jump Width
NTQ = 10, SAMPLE = 8, RESYCHRONIZATION_JUMP_WIDDTH = 1
-9- K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
With each configuration of the bit timing the following tests are performed:
a) Hard Synchronization, TX_DATA = Recessive, not Transmitter, not Receiver
b) Resychronization, TX_DATA = Recessive, Receiver
c) Resychronization, TX_DATA = Dominant, Receiver
d) Resychronization, TX_DATA = Dominant, Transmitter
e) Resychronization, TX_DATA = Recessive, Transmitter
f) Hard Synchronization, TX_DATA = Dominant, Transmitter
Note: The edges from recessive to dominant on the RECEIVE_DATA input which are used for Hard
Synchronization and Resynchronization appear with the falling edge of TIME_QUANTA_CLOCK while
synchronization is started with the rising edge of TIME_QUANTA_CLOCK.
3.2.4 crc
Cyclic Redundancy Check and Acknowledge
NUMBER_OF_CANS: 2
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 10 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
With every bit error the transmit error counter is increased by 8. Then the last Active Error Flag is
sent and the transmitter becomes Error Passive (TEN 120 -> 128), but it continues sending the
Active Error Flag.
3) Recessive bit at ACK Slot, no dominant bit during Passive Error Flag, RECEIVE_DATA input of
RefCAN2 is forced to recessive.
The bus state of RefCAN2 is idle, because the RECEIVE_DATA input is forced to recessive. The
transmitter (RefCAN1) detects an ACK error and sends a Passive Error Flag. During the Passive
Error Flag no dominant bit appears on the bus. The transmit error counter is not changed.
4) Transmitting a frame successful, transmitter is Error Active.
The transmitter transmits a frame without errors. The transmit error counter is decreased by 1
(TEC = 127).
5) Recessive bit at 2nd bit of Identifier.
The dominant bit of Identifier is forced to recessive. The transmitter detects a bit error and sends an
Active Error Flag. The transmit error counter is increased by 8. Transmitter is Error Passive.
6) Recessive bit at ACK Slot, dominant bits after Passive Error Flag, RECEIVE_DATA input of
RefCAN2 is forced to recessive.
The bus state of RefCAN2 is Idle, because the RECEIVE_DATA input is forced to recessive. The
transmitter (RefCAN1) detects an ACK error and sends a Passive Error Flag. During the Passive
Error Flag no dominant bit appears on the bus. The transmit error counter is not changed. After
Passive Error Flag the RECEIVE_DATA input of RefCAN1 is forced to dominant for 113 bit times.
The transmitter detects form errors at every 8th bit and increases its error counter by 8 (TEC = 247).
7) Recessive bit at ACK Slot, dominant bit at the 2nd bit of Passive Error Flag, RECEIVE_DATA input
of RefCAN2 is forced to recessive.
The bus state of RefCAN2 is Idle, because the RECEIVE_DATA input is forced to recessive. The
transmitter (RefCAN1) detects an ACK error and sends a Passive Error Flag. During the Passive
Error Flag a dominant bit appears on the bus. The transmit error counter is increased by 8
(TEC = 255).
8) Recessive bit at ACK Slot, dominant bit at the 6th bit of Passive Error Flag, RECEIVE_DATA input
of RefCAN2 is forced to recessive.
The bus state of RefCAN2 is Idle, because the RECEIVE_DATA input is forced to recessive. The
transmitter (RefCAN1) detects an ACK error and sends a Passive Error Flag. During the Passive
Error Flag a dominant bit appears on the bus. The transmit error counter is increased by 8
(TEC = 263) and the transmitter becomes Bus Off.
3.2.5 dlc
Data Field Length
NUMBER_OF_CANS: 2
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 11 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
3.2.6 emlcount
Function of Error Management Logic, -Counters, and -States
NUMBER_OF_CANS: 2
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 12 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 13 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Test of transmitter
1) Error Passive Transmitter with TEC < 128 sees Bit Error at dominant Identifier bit.
Node sends Passive Error Flag and adds Suspend to Interframe Space.
2) Error Passive Transmitter sees 104 consecutive dominant bits after Passive Error Flag.
Transmit error counter is incremented to 120.
3) Receive error counter is decremented by reception of correct messages.
Node is Error Active.
4) transmit error counter is incremented to 128.
Node is Error Passive.
5) Receiver sees Stuff Error and 16 consecutive dominant bits after Error Flag.
Receive error counter is incremented to 135.
6) One Successful transmission, then Bit Error at dominant Identifier bit.
Transmit error counter is decremented to 127, then Passive Error Flag.
A hardware reset is performed, both error counters are reset to 0.
7) Recessive bit at Start of Frame.
The dominant Start of Frame bit is forced to recessive. The transmitter detects a bit error and sends
an Active Error Flag. The transmit error counter is increased by 8.
8) Dominant bit at ACK Delimiter.
The recessive ACK Delimiter bit is forced to dominant. The transmitter detects a bit error and sends
an Active Error Flag. The transmit error counter is increased by 8.
9) Dominant bit at the first bit of End of Frame.
The recessive bit of End of Frame is forced to dominant. The transmitter detects a bit error and sends
an Active Error Flag. The transmit error counter is increased by 8.
10) Dominant bit at the last bit of End of Frame.
The recessive bit of End of Frame is forced to dominant. The transmitter detects a bit error and sends
an Active Error Flag. The transmit error counter is increased by 8
11) Dominant bit at last bit of Error Delimiter, 7 dominant bits after Overload Flag.
The last recessive bit of Error Delimiter is forced to dominant. The transmitter detects an overload
condition and sends an Overload Frame. After sending the Overload Frame the transmitter detects
7 consecutive dominant bits before sending the Overload Delimiter. The transmit error counter is
not changed.
12) Dominant bit at last bit of Overload Delimiter, 8 dominant bits after Overload Flag.
The recessive bit of Overload Delimiter is forced to dominant. The transmitter detects an overload
condition and sends an Overload Frame. After sending the Overload Frame the transmitter detects
8 consecutive dominant bits before sending the Overload Delimiter. The transmit error counter is
increased by 8.
13) Dominant bit at the 2nd bit of Overload Delimiter.
The recessive bit of Overload Delimiter is forced to dominant. The transmitter detects a bit error and
sends an Active Error Flag. The transmit error counter is increased by 8.
14) Dominant bit at the 2nd bit of Error Delimiter.
The recessive bit of Error Delimiter is forced to dominant. The transmitter detects a bit error and
sends an Active Error Flag. The transmit error counter is increased by 8.
- 14 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
15) Recessive bit at ACK Slot, 8 * 4 dominant bits after Error Flag
The dominant ACK bit is forced to recessive. The transmitter detects an ACK error and sends an
Active Error Flag. The transmit error counter is increased by 8. After the Error Flag the
RECEIVE_DATA input is forced to dominant for another 32 bits. After each sequence of additional
eight consecutive dominant bits the transmitter detects a form error and increases the error counter
by 8.
16) Dominant bit at 2nd bit of Intermission, recessive bit at first bit of Overload and Error Flag.
The recessive bit of Intermission is forced to dominant. The transmitter detects an overload
condition and sends an Overload Frame. Then the first bit of the Overload Flag is forced to
dominant. The transmitter detects a bit error and sends an Active Error Flag. The transmit error
counter is increased by 8.
During sending an Active Error Flag the RECEIVE_DATA input of the transmitter is forced to
recessive for 3 bit times. The transmitter detects bit errors at every bit and starts Active Error Flags.
With every bit error the transmit error counter is increased by 8. Then at the beginning of the last
Active Error Flag the transmitter becomes Error Passive, but it continues sending the Active Error
Flag.
17) Send 7 messages decrementing TEC to 128.
The transmitter sends 7 messages. After the successful transmission of each message the transmit
error counter is decreased by 1.
18) Error Passive transmitter sees Stuff Error during Arbitration at recessive stuff bit.
No TEC change on arbitration stuff error
19) Send one successful message.
Node is set back to Error Active.
20) Recessive bit at Start of Frame.
The dominant Start of Frame bit is forced to recessive. The transmitter detects a bit error and sends
an Active Error Flag. The transmit error counter is increased by 8. The transmitter is now Error
Passive again.
21) Recessive bit at Start of Frame (Error Passive).
The dominant Start of Frame bit is forced to recessive. The transmitter detects a bit error and sends
a Passive Error Flag. The transmit error counter is increased by 8.
22) Dominant bit at ACK Delimiter (Error Passive).
The recessive ACK Delimiter bit is forced to dominant. The transmitter detects a bit error and sends
a Passive Error Flag. The transmit error counter is increased by 8.
23) Dominant bit at the first bit of End of Frame (Error Passive).
The recessive bit of End of Frame is forced to dominant. The RECEIVE_DATA input is forced to
dominant for another 6 bits. The transmitter detects a bit error (at End of Frame) and sends a Passive
Error Flag. The transmit error counter is increased by 8. The 6 dominant bits during the Passive
Error Flag have no effect.
24) Dominant bit at the last bit of End of Frame (Error Passive), bit error during Passive Error Flag.
The recessive bit of End of Frame is forced to dominant. The transmitter detects a bit error and sends
a Passive Error Flag. The transmit error counter is increased by 8. Then the 3rd bit of Passive Error
Flag is forced to dominant. The transmitter continues sending Passive Error Flag and waits again
for 6 consecutive bits without changing the error counter.
- 15 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
25) Dominant bit at last bit of Error Delimiter (Error Passive), 7 dominant bits after Overload Flag.
The last recessive bit of Error Delimiter is forced to dominant. The transmitter detects an overload
condition and sends an Overload Frame. After sending the Overload Frame the transmitter detects
7 consecutive dominant bits before sending the Overload Delimiter. The transmit error counter is
not changed.
26) Dominant bit at last bit of Overload Delimiter (Error Passive), 8 dominant bits after Overload Flag.
The recessive bit of Overload Delimiter is forced to dominant. The transmitter detects an overload
condition and sends an Overload Frame. After sending the Overload Frame the transmitter detects
8 consecutive dominant bits before sending the Overload Delimiter. The transmit error counter is
increased by 8.
27) Dominant bit at the 2nd bit of Overload Delimiter (Error Passive).
The recessive bit of Overload Delimiter is forced to dominant. The transmitter detects a bit error and
sends a Passive Error Flag. The transmit error counter is increased by 8.
28) Recessive bit at ACK Slot (Error Passive)
The dominant ACK bit is forced to recessive. The transmitter detects an ACK error and sends a
Passive Error Flag. The transmit error counter is not changed because it does not detect a dominant
bit while sending its Passive Error Flag.
29) 2nd bit of Error Delimiter forced dominant (Error Passive), 64 dominant bits after Passive Error
Flag.
The recessive bit of Error Delimiter is forced to dominant. The transmitter detects a bit error and
sends a Passive Error Flag. The transmit error counter is increased by 8.
After the Error Flag the RECEIVE_DATA input is forced to dominant for another 64 bits. After each
sequence of additional eight consecutive dominant bits the transmitter detects a form error and
increases the error counter by 8.
30) Dominant bit at last bit of Error Delimiter (Error Passive).
The last recessive bit of Error Delimiter is forced to dominant. The transmitter detects an overload
condition and sends an Overload Frame.
31) Dominant bit at 3rd bit of Intermission (Error Passive).
The last bit of Intermission is forced to dominant. The node is Error Passive and becomes receiver.
The next 5 bits are also forced to dominant. The receiver detects a stuff error and sends a Passive
Error Flag. The receive error counter is incremented by 1.
32) Dominant bit at the first bit after receiver’s Passive Error Flag.
The first bit after the Passive Error Flag is forced to dominant. The receiver increments the receive
error counter by 8.
33) Dominant bit at receiver’s Error Delimiter (Error Passive).
The 4th bit of Error Delimiter is forced to dominant. The receiver detects a form error and
increments the receive error counter by 1.
34) Dominant bit at the first bit after receiver’s Passive Error Flag.
The first bit after 6 consecutive recessive Passive Error Flag bits is forced to dominant. The receiver
increments the receive error counter by 8.
35) Dominant bit at receiver's Error Delimiter. Dominant bit after Passive Error Flag seen as dominant.
The recessive bit of Error Delimiter is forced to dominant. The receiver detects a form error and
increments the receive error counter by 1. After the 6 consecutive dominant Passive Error Flag bits
the receiver sees another dominant bit and increments the receive error counter by 8. A new
transmission is started.
- 16 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
3.2.7 extd_id
Test of proper recognition of IDE bit at all stuff conditions and test of losing arbitration at IDE bit.
NUMBER_OF_CANS: 2
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 17 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
2) IDE = dominant, standard frame: Lost arbitration at RTR (extended data frame with illegal SRR =
dominant).
3) IDE = recessive, extended frame: Lost arbitration at SRR (standard data frame).
4) IDE = recessive, extended frame: Lost arbitration at IDE (standard remote frame).
5) IDE = recessive, extended frame: Lost arbitration at extended Identifier.
6) IDE = recessive, extended frame: Lost arbitration at RTR (extended data frame).
7) IDE = recessive, extended frame: Lost arbitration at SRR (extended data frame with illegal SRR =
dominant).
3.2.8 formerr
Confinement of Form Errors
NUMBER_OF_CANS: 2
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 18 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 19 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
3.2.9 idle
Reset and BusOff Recovery Sequences
NUMBER_OF_CANS: 1
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 20 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
8) Abort transmission.
The reset_transmission_request is set to abort the transmission. The node waits now for 128 * 11
consecutive recessive bits.
9) Dominant bit at the 9th position of Bus Off recovery sequence.
The recessive 9th bit of Bus Off recovery is forced to dominant. The recovery sequence starts again.
10) Dominant bit at the 11th position of Bus Off recovery sequence.
The recessive 11th bit of Bus Off recovery is forced to dominant. The recovery sequence starts
again.
11) Dominant bit at the first position of Bus Off recovery sequence.
The recessive 1st bit of Bus Off recovery is forced to dominant. The recovery sequence starts again.
The recovery counter is unchanged.
12) Dominant bit at the (10 + (126 * 11) ) position of Bus Off recovery.
The recessive bit of Bus Off recovery is forced to dominant. The recovery sequence starts again.
The recovery counter is unchanged. After the next 11 recessive bits the node becomes Bus Idle and
Error Active.
13) Dominant bit at the 12th position of Bus_Idle.
A recessive 12th bit during Bus Idle is forced to dominant. The node interprets this as Start of Frame
and becomes receiver. After the 6th bit of Identifier the receiver detects a stuff error and sends an
Active Error Flag. The receive error counter is increased by 1.
3.2.10 overload
Overload Confinement
NUMBER_OF_CANS: 2
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 21 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Test of transmitter
1) Dominant bit at 1st bit of Intermission, 8th bit of Overload Delimiter, 2nd bit of Intermission.
In a test loop the bits described above are forced to dominant. At each dominant bit the transmitter
detects an overload condition and sends an Overload Flag.
2) Dominant bit at 3rd bit of Intermission.
The recessive 3rd bit of Intermission is forced to dominant. The transmitter interprets this as Start
of Frame and starts a message.
3) Recessive bit at the 4th bit of Identifier.
The dominant 4th bit of Identifier is forced to recessive. The transmitter detects a bit error and sends
an Active Error Flag. The transmit error counter is increased by 8.
4) Dominant bit at the 8th bit of Error Delimiter.
The recessive 8th bit at Error Delimiter is forced to dominant. The transmitter detects an overload
condition and sends an Overload Flag.
3.2.12 stufferr
Confinement of Stuff Errors
NUMBER_OF_CANS: 2
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 22 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
2) Dominant stuff error at stuff bit after the 4th Identifier position.
A recessive stuff bit is forced to dominant. The transmitter sends an Active Error Flag. The transmit
error counter is not changed because the error occurred during arbitration. The receiver sends an
Active Error Flag and increases the receive error counter by 1.
3) Dominant stuff error at stuff bit after RTR bit.
A recessive stuff bit is forced to dominant. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1. No arbitration is possible after the RTR bit of an extended Identifier.
4) Recessive stuff error at stuff bit after RTR bit.
A dominant stuff bit is forced to recessive. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
5) Recessive stuff error at stuff bit after the 2nd Data Length Code position.
A dominant stuff bit is forced to recessive. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
6) Dominant stuff error at stuff bit after the 2nd Data Length Code position.
A recessive stuff bit is forced to dominant. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
7) Dominant stuff error at stuff bit after the 4th Data Length Code position.
A recessive stuff bit is forced to dominant. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
8) Recessive stuff error at stuff bit after the 4th Data Length Code position.
A dominant stuff bit is forced to recessive. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
9) Recessive stuff error at stuff bit after the 8th Data Field position.
A dominant stuff bit is forced to recessive. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
10) Dominant stuff error at stuff bit after the 12th Data Field position.
A recessive stuff bit is forced to dominant. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
11) Dominant stuff error at stuff bit after the 64th Data Field position.
A recessive stuff bit is forced to dominant. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
12) Recessive stuff error at stuff bit after the 8th Data Field position.
A dominant stuff bit is forced to recessive. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
- 23 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
13) Recessive stuff error at stuff bit after the 8th CRC Field position.
A dominant stuff bit is forced to recessive. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
14) Dominant stuff error at stuff bit after the 1st CRC Field position.
A recessive stuff bit is forced to dominant. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
15) Dominant stuff error at stuff bit after the 15th CRC Field position.
A recessive stuff bit is forced to dominant. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
16) Recessive stuff error at stuff bit after the 15th CRC Field position.
A dominant stuff bit is forced to recessive. The transmitter sends an Active Error Flag and increases
the transmit error counter by 8. The receiver sends an Active Error Flag and increases the receive
error counter by 1.
3.2.13 txarb
Arbitration
NUMBER_OF_CANS: 1
Bit Timing: CLOCK_PERIOD = 100 ns, PRESCALER = 1,
- 24 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 25 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 26 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4 Model Description
The top level of the Reference CAN Model design is the testbench, consisting of a simulation
environment and a set of test programs as described in section 3.2. This chapter describes the model
structure and the functionality implemented in the architectures used in the components of the model.
The testbench PROTOCOL_TESTBENCH, shown in figure 1, can be configured to run the different test
programs for different CAN models by assigning dedicated architectures and configurations to the
components WAVEFORM (entity TEST_PROGRAM, architecture <test>) and SYSTEM (entity
CAN_SYSTEM, architecture FLEXIBLE). The components are interconnected by a set of Interface Signals
as described in section 4.1.
E = PROTOCOL_TESTBENCH
E = CAN_SYSTEM
CAN_BUS
A = FLEXIBLE
Interface Signals
E = TEST_PROGRAM
A = <test>
A = STRUCTURAL
The test programs control the simulation by driving the inputs and strobing the outputs of CAN_SYSTEM.
Each test program is represented by one dedicated architecture of TEST_PROGRAM and by three
dedicated configurations of PROTOCOL_TESTBENCH, one configuration for each of the three CAN
implementation models (CONFIGURATION_IMPLEMENTATION, CONFIGURATION_EXAMPLE, and
CONFIGURATION_BUGGY) that are provided with the Reference CAN Model. The configurations are
described in subsections 4.2.1 and 4.2.2.
- 27 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
To check special features of an user-defined implementation, like a message memory or a bus interface,
additional test programs can be included in the testbench. The file template.vpp defines an
architecture TEMPLATE of TEST_PROGRAM. This architecture can be used as a template when writing
additional test programs for the verification of an implementation (see section 5.3).
The architecture FLEXIBLE of CAN_SYSTEM is structural and connects the CAN model to be verified
(component CHECK1) with a flexible number of Reference CAN Model nodes, interacting via the CAN
bus. Which CAN model is used as component CHECK1 is defined by a configuration of CAN_SYSTEM,
the actual number of Reference CAN Nodes is defined by a configuration of PROTOCOL_TESTBENCH.
- 28 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4.1 PROTOCOL_TESTBENCH
The protocol testbench, as shown in figure 1, is the top level entity. It has neither inputs nor outputs and
is described by only one architecture, STRUCTURAL. STRUCTURAL consists of the two components
WAVEFORM and SYSTEM. These two components are connected by a set of interface signals.
• The interface (record-) signals driven by TEST_PROGRAM :
RESET
BIT_TIMING_CONFIGURATION(1 to MAXIMUM_NUMBER_OF_CANS)
.PRESCALER
.PROPAGATION_SEGMENT
.PHASE_BUFFER_SEGMENT_1
.RESYNCHRONISATION_JUMP_WIDTH
.INFORMATION_PROCESSING_TIME
BUS_INTERFERENCE(1 to MAXIMUM_NUMBER_OF_CANS)
TRANSMIT_MESSAGE(1 to MAXIMUM_NUMBER_OF_CANS)
.FRAME_KIND
.MESSAGE.IDENTIFIER_KIND
.MESSAGE.IDENTIFIER
.MESSAGE.NBYTES
.MESSAGE.DATA(0…8)
TRANSMISSION_REQUEST(1 to MAXIMUM_NUMBER_OF_CANS)
• The interface signals driven by CAN_SYSTEM :
TRANSMISSION_REQUEST_STATUS(1 to MAXIMUM_NUMBER_OF_CANS)
RECEIVED_MESSAGE(1 to MAXIMUM_NUMBER_OF_CANS)
.FRAME_KIND
.MESSAGE.IDENTIFIER_KIND
.MESSAGE.IDENTIFIER
.MESSAGE.NBYTES
.MESSAGE.DATA(0…8)
These signals (elements of the arrays referencing the CAN nodes in CAN_SYSTEM) implement the
following functionality:
• RESET is the system reset.
• BIT_TIMING_CONFIGURATION defines the CAN bit time.
• BUS_INTERFERENCE can force the RECEIVE_DATA output of an instance of BUS_INTERFACE to a
certain state.
• TRANSMIT_MESSAGE defines a message to be transmitted by the labelled CAN node.
• If TRANSMISSION_REQUEST is true, the labelled CAN node is requested to transmit a message.
• TRANSMISSION_REQUEST_STATUS shows the processing of a requested transmission.
• RECEIVED_MESSAGE is the contents of the last message received by the labelled CAN node.
• The generic parameter MODEL_LABEL distinguishes the different instances of CAN_INTERFACE in-
side CAN_SYSTEM. Valid values for MODEL_LABEL are 0 to MAXIMUM_NUMBER_OF_CANS.
MODEL_LABEL = 0 is always used for that instance of the implementation that is to be verified by
comparing its function with the function of the reference model working in parallel. That implemen-
tation’s input is a copy of the input of the compared reference model.
For details of the constants and of the type declarations see packages definitions.vhd and
trace_package.vhd.
- 29 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4.2 CAN_SYSTEM
CAN_SYSTEM comprises the complete CAN environment to be simulated, its function is described by
the architecture FLEXIBLE (see figure 2). This is a structural architecture, connecting the CAN model
to be verified with a flexible number of Reference CAN Model nodes, interacting via the CAN bus. It is
used, in different configurations, for all protocol test programs. The ports of the entity CAN_SYSTEM are
described in section 4.1.
The architecture FLEXIBLE of CAN_SYSTEM instantiates components defined by the following entities :
BUS_INTERFACE
CAN_INTERFACE
These entities and their architectures are described in section 4.3 and section 4.4.
E = CAN_SYSTEM
CAN_BUS
E = BUS_INTERFACE E = BUS_INTERFACE
BUS_INTERFERENCE
E = CAN_INTERFACE E = CAN_INTERFACE
*n
MODEL_LABEL = 1 MODEL_LABEL = n + 1
A = COMPARE A = REFERENCE
A = FLEXIBLE
Interface Signals
The generic parameter MODEL_LABEL of CAN_INTERFACE is used to distinguish between the different
instances of CAN_INTERFACE. The generic parameters CLOCK_PERIOD and RX_DELAY (associated with
their actual values in the testbench’s configuration) define the timing of the instantiated components. For
each instance of CAN_INTERFACE, there is one instance of BUS_INTERFACE (component DRIVER) and
one element of the array of interface signals.
In the architecture FLEXIBLE, CAN_SYSTEM contains at least one instance of CAN_INTERFACE
(component CHECK1) and a flexible number of additional instances of CAN_INTERFACE (component
REFERENCE_MODEL). The actual number of nodes connected to the CAN bus is determined by the
generic parameter NUMBER_OF_CAN_NODES of CAN_SYSTEM (n = NUMBER_OF_CAN_NODES - 1). This
generic parameter is defined by a configuration of PROTOCOL_TESTBENCH.
- 30 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
The following architectures are available for CAN_INTERFACE : COMPARE, REFERENCE, EXAMPLE, and
BAD_EXAMPLE. Which CAN model architecture or configuration is associated with component CHECK1
or with the components REFERENCE_MODEL is defined by a configuration of CAN_SYSTEM.
Only one architecture is available for BUS_INTERFACE : BEHAVIOUR (see section 4.3).
For other applications beyond the CAN protocol verification, additional CAN_SYSTEM architectures and
configurations can be defined.
NUMBER_OF_CAN_NODES = 3: baudrate
The architectures and configurations of CAN_INTERFACE, which are used here, are described in section
4.4.1 (architecture COMPARE), in section 4.4.2 (architecture REFERENCE), and in section 4.4.3
(configuration IMPLEMENTATION).
- 31 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4.3 BUS_INTERFACE
BUS_INTERFACE is used to connect an instance of CAN_INTERFACE to the CAN_BUS.
The entity has the following ports :
generic TX_DOMINANT_DELAY delay when driving a dominant bit to the CAN bus
generic TX_RECESSIVE_DELAY delay when driving a recessive bit to the CAN bus
generic RX_DELAY delay when receiving a bit from the CAN bus
in RESET
inout CAN_BUS model of a CAN bus, may be dominant or recessive
in BUS_INTERFERENCE forces RECEIVE_DATA to specific values
out RECEIVE_DATA output to CAN_INTERFACE
in TRANSMIT_DATA input from CAN_INTERFACE
In the CAN_SYSTEM, the physical layer of the CAN bus is represented by a single bus line which can be
driven to the values RECESSIVE and DOMINANT by each of the instances of BUS_INTERFACE connected
to CAN_BUS. The resolution function used for CAN_BUS ensures that a single dominant level will
override all recessive levels.
Only one architecture exists for BUS_INTERFACE, named BEHAVIOUR.
In BEHAVIOUR, the state of signal TRANSMIT_DATA is converted to a dominant level (if it is ‘0’) or a
recessive level (if it is ‘1’) on the CAN_BUS. An assertion of severity error checks whether
TRANSMIT_DATA has a value different from ‘0’ or ‘1’.
- 32 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4.4 CAN_INTERFACE
The entity CAN_INTERFACE is designed as a CAN Protocol Controller, which is connected to the CAN
bus by a BUS_INTERFACE and to the message memory by the signals RECEIVED_MESSAGE and
TRANSMIT_MESSAGE.
The entity has the following ports :
generic MODEL_LABEL Each component of this entity has a particular name
generic CLOCK_PERIOD is an array of the base time units of the CAN_SYSTEM
generic RX_DELAY used to synchronize Reference and Implementation
generic GET_RECEIVE_ERROR_COUNTER_FROM_MODEL_0 optional, only for protocol check
in RESET restores the initial state of the entity
in RECEIVE_DATA is the data input from BUS_INTERFACE
out TRANSMIT_DATA is the data output to BUS_INTERFACE
in BIT_TIMING_CONFIGURATION is the definition for the CAN bus bit time
out RECEIVED_MESSAGE is the last received message
in TRANSMISSION_REQUEST if true, the CAN node is required to transmit
in TRANSMIT_MESSAGE is the message to be transmitted
out TRANSMISSION_REQUEST_STATUS shows the processing of a requested transmission
The architectures COMPARE and REFERENCE are fundamental parts of the CAN protocol testbench and
should not be modified.
The architecture IMPLEMENTATION is a proxy for the user’s implementation model that is to be verified
by the Reference CAN Model node. Since IMPLEMENTATION is not part of the Reference CAN Model,
the configuration CONFIGURATION_IMPLEMENTATION currently associates the architecture
REFERENCE whenever the IMPLEMENTATION is instantiated.
The architecture EXAMPLE describes an entire CAN module, including CAN Protocol Controller,
message memory, and CPU interface, linked together in CONFIGURATION_EXAMPLE. It is intended as
an example how to integrate the user’s implementation model into the Reference CAN Model.
The architecture BAD_EXAMPLE describes a buggy CAN Protocol Controller. The configuration
CONFIGURATION_BUGGY links this buggy CAN Protocol Controller into the architecture EXAMPLE,
resulting in a buggy CAN module. The simulation of this buggy module, running in parallel to the
architecture REFERENCE inside the architecture COMPARE shows how the test programs of the Reference
CAN Model detect CAN protocol errors.
Besides the entity’s port signals, the protocol check requires additional internal information on internal
signals of the architectures of CAN_INTERFACE. These internal signals cannot be accessed directely.
Therefore, the architectures are provided with a set of global signals BOND_OUT of the record type
BOND_OUT_TYPE, as defined in package trace_package.vhd. BOND_OUT is an array of records, each
architecture drives only elements of BOND_OUT(MODEL_LABEL). In the model of the user’s
- 33 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
implementation, the BOND_OUT signals (see section 5.1) are to be excluded from synthesis, they are
intended for the verification simulation only.
E = CAN_INTERFACE
RECEIVE_DATA
A = BEHAVIOUR
E = CAN_INTERFACE E = CAN_INTERFACE
BOND_OUT BOND_OUT
E = CHECKER
A = REFERENCE A = IMPLEMENTATION
RECEIVED_MESSAGE_R RECEIVED_MESSAGE_I
A = COMPARE
Interface Signals
The IMPLEMENTATION is running in parallel to the REFERENCE, meaning they get the same inputs and
should generate the same outputs. During a simulation, some of the BOND_OUT signals and the
TRANSMIT_DATA and RECEIVED_MESSAGE port signals of the implementation’s model and of the
Reference CAN Model node are compared by PROTOCOL_CHECK. The BOND_OUT signals are not part
of CAN_INTERFACE’s port map list, they are global signals declared in package trace_package.vhd.
Inside CAN_INTERFACE’s architectures, the values of certain internal signals or variables are assigned
to corresponding BOND_OUT signals, making that values externally visible, see also section 5.1.
In case of a difference in that signals, the checker will indicate this difference by a report of severity error
as a CAN protocol error. The functionality of CHECKER is described in section 4.4.1.1.
The TRANSMIT_DATA output of COMPARE is the TRANSMIT_DATA output of IMPLEMENTATION. The
TRANSMIT_DATA output of REFERENCE is only used by the checker and is not visible outside this
architecture.
- 34 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4.4.1.1 CHECKER
CHECKER compares BOND_OUT signals and the TRANSMIT_DATA and RECEIVED_MESSAGE port signals
of an implementation under test (IUT) with the corresponding signals of the Reference CAN Model node
simulated in parallel and notifies differences as CAN protocol errors.
Entity CHECKER is instanciated as a component of architecture COMPARE of CAN_INTERFACE. Its
functionality is implemented in the architecture BEHAVIOUR of CHECKER.
The elements of the BOND_OUT global signal record used by CHECKER are the following:
BOND_OUT(MODEL_LABEL)
.BUSMON
.TRANSMIT_ERROR_COUNTER
.RECEIVE_ERROR_COUNTER
.BUSOFF
- 35 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Case #1 Case #2
-MIN + MAX -MIN + MAX
TRANSMIT_DATA_R
TRANSMIT_DATA_R_STABLE
TRANSMIT_DATA_I
TRANSMIT_DATA_I_DELAYED
|MIN| |MIN|
Figure 4 Tolerable phase shifts between compared signals (example for TRANSMIT_DATA).
After RESET, CHECKER remains passive as long as the CAN bus remains in the recessive state. CHECKER
is activated when the IUT sampled the first dominant bit after the start of the simulation. If it detects a
difference between the relevant signals of the IUT and of the Reference CAN Model node, an assertion
will cause a report of severity error, documenting the CAN protocol error.
In order to compensate for a possible phase difference between the clocks of the IUT and the Reference
CAN Model node, the signals of the IUT and the Reference CAN Model node are compared not directly,
but with the help of some intermediate signals, so that small phase differences between the signals are
tolerated.
The IUT is required to follow the Reference CAN Model node within the time window defined by signals
MIN and MAX. This allows phase shifts to be tolerated if the edges of the compared signals lie within this
time window (see figure 4). The limits for the tolerable phase shift are MAX = (Time Quanta) / 2 = -MIN.
If an edge appears at TRANSMIT_DATA_R, the transmit data output of the Reference CAN Model node,
the TRANSMIT_DATA_R_STABLE signal is set to false for -MIN + MAX. After this time it returns to true.
If an edge appears at TRANSMIT_DATA_I, the transmit data output of the IUT, the edge of signal
TRANSMIT_DATA_I_DELAYED is generated from TRANSMIT_DATA_I by delaying it for |MIN|.
CHECKER compares the Reference CAN Model node signals with the delayed signals of the IUT while
the Reference CAN Model node signals are stable. In the example of figure 4, TRANSMIT_DATA_R is
compared with TRANSMIT_DATA_I_DELAYED while TRANSMIT_DATA_R_STABLE is true (outside the
shaded area). If the phase shift between the edges is so small that the edges of the delayed signals lie
within the shaded areas, the signals of the IUT and of the Reference CAN Model node will be regarded
as identical.
- 36 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
In Case #1 the transmit data output TRANSMIT_DATA_I of the IUT changes after the transmit data output
TRANSMIT_DATA_R of the Reference CAN Model node. In Case #2 the transmit data output
TRANSMIT_DATA_I of the IUT changes before the transmit data output TRANSMIT_DATA_R of the
Reference CAN Model node. In both cases the phase shift can be tolerated because the generated signal
TRANSMIT_DATA_I_DELAYED lies inside the shaded area.
If the phase difference of the edges of the compared signals is greater than |MIN|, an error in the
implementation is assumed. An assertion report shows which signal causes the CAN protocol error.
The same phase compensation is used for the other compared signals with the exception of the error
counters. The error counters are compared at the sample point only. If the receive error counter reaches
the error passive level, CHECKER only verifies that both receive error counters are above the error passive
limit (127), their actual values are not compared. When the receive error counters are decremented again,
finishing error passive, they are set to a value in the range of 119 to 127. The Reference CAN Model
node adjusts itself to the value of the implementation’s receive error counter (see section 4.4.2.7).
At the reception of a message, CHECKER compares the RECEIVED_MESSAGE port signals of
implementation and Reference CAN Model. The comparision is done at the implementation’s
RECEIVED_MESSAGE events rather than the reference model’s in order to allow implementations with a
hardware acceptance filtering that do not accept certain messages of the reference testbench. In case of
restricted implementations, only that part of the message that is inside the restriction is checked.
- 37 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
RECEIVE_DATA TRANSMIT_DATA
E = CAN_INTERFACE
P = OSCILLATOR
P = PRESCALER
TIME_QUANTA_CLOCK
CLOCK
P = BIT_TIMING
HARD_SYNC_ENABLE
SAMPLE_POINT
BUSMON
BUS_DRIVE
trace information
A = REFERENCE
processes
Trace Signals
writing
P = BIT_STREAM_PROCESSOR
GET_RECEIVE_ERROR_COUNTER_FROM_MODEL_0
TRANSMISSION_REQUEST_STATUS
BIT_TIMING_CONFIGURATION
BOND_OUT
TRANSMISSION_REQUEST
TRANSMIT_MESSAGE
RECEIVED_MESSAGE
CLOCK_PERIOD
MODEL_LABEL
RX_DELAY
RESET
- 38 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
The Reference CAN Model architecture shown in figure 5 consists of the following processes:
OSCILLATOR
PRESCALER
BIT_TIMING
BIT_STREAM_PROCESSOR
REQUEST_STATUS
TRACE_MESSAGE
TRACING
The functions implemented in these processes are described in the following subsections.
4.4.2.3.1 Overview
This process controls bit timing and synchronization, samples the RECEIVE_DATA input, and drives the
TRANSMIT_DATA output.
The signals below are input to process BIT_TIMING:
RESET
TIME_QUANTA_CLOCK
BIT_TIMING_CONFIGURATION
.PRESCALER
.PROPAGATION_SEGMENT
.PHASE_BUFFER_SEGMENT_1
.RESYNCHRONISATION_JUMP_WIDTH
.INFORMATION_PROCESSING_TIME
RECEIVE_DATA
HARD_SYNC_ENABLE
BUS_DRIVE
The following signals are output of process BIT_TIMING:
BUSMON
SAMPLE_POINT
TRANSMIT_DATA
BOND_OUT(MODEL_LABEL).BUSMON
BOND_OUT(MODEL_LABEL).TRANSMIT_POINT
The BOND_OUT Signals are defined in package trace_package.vhd. They are used by CHECKER as
described in section 4.4.1.1. The generic MODEL_LABEL is used to address a certain instance of
CAN_INTERFACE.
- 39 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
if RESET then
Initialize signals and variables
end if;
- 40 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
• During each bit time there is the possibility to synchronize on a recessive to dominant edge at the
RECEIVE_DATA input. This can be done by a Hard Synchronization or by a Resynchronization. Each
synchronization resets the SYNC_ENABLE flag to guarantee that only one synchronization per bit time
is performed.
• At the end of a bit time the time quanta counter is reset (COUNT = 0), TRANSMIT_POINT is set and the
TRANSMIT_DATA output gets the actual value of BUS_DRIVE.
• If the time quanta counter equals SAMPLE_I the signal SAMPLE_POINT is set to ‘1’ and the output
signal BUSMON gets the value of RECEIVE_DATA. Therefore BUSMON shows the sampled input data
stream. In addition the SYNC_ENABLE flag is set true to enable synchronization.
For details of the VHDL coding see file can_interface_reference.vhd.
PHASE_ERROR = 0
PHASE_ERROR < 0
(shorten PB2)
SAMPLE_POINT
TQ IPT
SyncSeg
PROP
PB1 PB2
Sample
Bit Time
4.4.2.3.3 Synchronization
During each bit time there is the possibility to synchronize on a recessive to dominant edge at the
RECEIVE_DATA input. This can be done by a Hard Synchronization or by Resynchronization.
Synchronization will only be done when the last sampled bus value was recessive (i.e. BUSMON = ‘1’).
This is necessary to avoid synchronizing on spikes on the bus line. The conditions for synchronization
are dependent whether the node is receiver or transmitter.
For additional information about synchronization see also CAN Specification 2.0 Part A, B.
- 41 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
SYNC_ENABLE := false;
end if;
Hard Synchronization
When the CAN node is in Bus_Idle state, the signal HARD_SYNC_ENABLE is set true by the
BIT_STREAM_PROCESSOR. Now a recessive to dominant edge on the bus will cause a Hard
Synchronization provided that the last sampled value was recessive.
When the node is receiver and a recessive to dominant edge is detected the value of the time quanta
counter is set to one (COUNT = 1) and a new bit time starts.
If the node is transmitting a dominant bit, Hard Synchronization can only occur when PHASE_ERROR < 0.
The generation of TRANSMIT_POINT is done only if the detected edge lies Information Processing Time
after the sample point (see figure 7).
- 42 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Resynchronization
When a reception or transmission is in progress there is the possibility to resynchronize on recessive to
dominant edges on the CAN bus. There are two cases for Resynchronization depending if the node is
receiver or transmitter.
Node is Receiver
If the node is receiver there will be Resynchronization on each recessive to dominant edge provided the
value of BUSMON is ‘1’.
If the edge lies between Synchronisation Segment and sample point (PHASE_ERROR > 0) the Phase
Buffer Segment 1 is lengthened by a number of time quanta less or equal the resynchronization jump
width. This is done by shifting the sample point (SAMPLE_I) and the end of bit time (NTQ_I) by DELTA
time quanta.
If the edge lies between sample point and the next Synchronization Segment (PHASE_ERROR < 0) the
Phase Buffer Segment 2 is shortened in the following way:
When the distance of the detected edge from the next Synchronization Segment is less than the
resychronization jump width, the time quanta counter is set to one (COUNT = 1) and a new bit time is
started. Else the number of time quanta for this bit time (NTQ_I) is decremented by DELTA.
The generation of TRANSMIT_POINT is done only if the detected edge lies Information Processing Time
after the sample point.
- 43 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Node is Transmitter
If the node is transmitter there will only be a Resychronization on a recessive to dominant edge if the
edge lies between the sample point and the next Synchronisation Segment (PHASE_ERROR < 0). Phase
Buffer Segment 2 is shortened by a number of time quanta less or equal the resynchronization jump
width.
If the distance of the detected edge from the next Synchronization Segment is less than the
resychronization jump width, the time quanta counter is set to one (COUNT = 1) and a new bit time is
started. Else the number of time quanta for this bit time (NTQ_I) is decremented by DELTA.
The generation of TRANSMIT_POINT is done only if the detected edge lies Information Processing Time
after the sample point.
- 44 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 45 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4.4.2.4.1 Overview
The BIT_STREAM_PROCESSOR generates and receives the bit stream.
Input signals of process BIT_STREAM_PROCESSOR:
RESET
PROCESS_BIT
RECEIVE_DATA
BIT_ERROR
TRANSMISSION_REQUEST
TRANSMIT_MESSAGE
.FRAME_KIND
.MESSAGE.IDENTIFIER_KIND
.MESSAGE.IDENTIFIER
.MESSAGE.NBYTES
.MESSAGE.DATA
ADJUST_ERROR_COUNTERS
- 46 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Overload_Frame
Overload_Flag, [1…6+]
Overload_Delimiter, [2…8] (1st bit is last bit of Error Flag)
InterFrame_Space
Intermission, [1…3]
Suspend_Transmission, [1…8]
Each of the fields Reset, Wait_For_Bus_Idle, Bus_Idle and Bus_Off implies one special STATUS. For
example Bus_Idle points to IDLE and Bus_Off points to BUS_OFF_RECOVERY. All other fields are
linked with STATUS RECEIVING or TRANSMITTING.
In process BIT_STREAM_PROCESSOR Data_Frame and Remote_Frame (and all the fields in it) are
calculated in own program sections separated in TRANSMITTING and RECEIVING. The Error_Frame,
the Overload_Frame and the InterFrame_Space are divided in the fields which are listed above, also
separated in TRANSMITTING and RECEIVING STATUS.
- 47 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
BIT_STREAM_PROCESSOR
if RESET then
INITIALIZATION
elsif PROCESS_BIT’event and PROCESS_BIT = ‘1’ then
TRACE assignments
STUFF assignments
INITIALIZATION
Local signals, variables and output signals are set to their default values.
TRACE assignments
Some trace signals PREVIOUS_XXX are set before the source signals are changed. MESSAGE_OK is set to
false. Its only true during the reception of the last bit of End of Frame. CRC_OK is set to false. It can only
be true during the reception of the recessive CRC Delimiter.
STUFF assignments
The stuff variables STUFF_BIT and STUFF_CONDITION are assigned according to the values of
DOMINANT_COUNTER, RECESSIVE_COUNTER and STUFF_ENABLE. The signals STUFF_BIT and
NEXT_IS_STUFF are only used for tracing.
- 48 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
ERROR_STATUS assignments
If TRANSMIT_ERROR_COUNTER and RECEIVE_ERROR_COUNTER are less than or equal to 127 the node
is Error Active and ERROR_PASSIVE is false.
STATUS of CAN Interface
Here the actual state of the CAN node is evaluated. STATUS is a signal of CAN_STATUS_TYPE. The five
states (without RESET) are described in the next sections.
• STATUS - BUS_OFF_RECOVERY
The node waits for 128 occurrences of 11 consecutive recessive bits on the bus, with
HARD_SYNC_ENABLE set to ‘1’. The RECEIVE_ERROR_COUNTER is used to count these 128 occur-
rences and the POSITION signal is used to count 11 consecutive bits. If a dominant bit occurs on the
bus then POSITION is reset to 1. If the RECEIVE_ERROR_COUNTER is equal to 128 then STATUS is
changed to IDLE, TRANSMIT_ERROR_COUNTER and RECEIVE_ERROR_COUNTER are cleared, PO-
SITION is set to ‘1’.
• STATUS - WAIT_FOR_BUS_IDLE
This is the first status after RESET. The node waits for 11 consecutive recessive bits which are counted
with the RECESSIVE_COUNTER, with HARD_SYNC_ENABLE set to ‘1’. If the node has monitored
these 11 bits on the bus and TRANSMISSION_REQUEST is true then STATUS is changed to TRANS-
MITTING. In the other case the status is changed to IDLE.
• STATUS - IDLE
The bus is now free and the node waits for a recessive to dominant edge on the bus which is interpreted
as Start_Of_Frame. The node becomes receiver with setting STATUS to RECEIVING and
HARD_SYNC_ENABLE to ‘0’. The FIELD of the next bit is Identifier and STUFF_ENABLE is true be-
cause Start_Of_Frame is part of the stuffed area.
If no dominant bit appears on the bus the node waits for a TRANSMISSION_REQUEST to become
transmitter. Then STATUS is changed to TRANSMITTING. The FIELD of the next bit is
Start_Of_Frame. STUFF_ENABLE becomes true. BUS_DRIVE is set to dominant (because of
Start_Of_Frame) and HARD_SYNC_ENABLE will be set to ‘0’.
- 49 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
• STATUS - RECEIVING
The status RECEIVING is divided in 7 fields.
Status is RECEIVING
case FIELD is
when Active_Error_Flag =>
- 50 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 51 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
• STATUS - TRANSMITTING
The status TRANSMITTING is divided in 8 fields.
Status is TRANSMITTING
case FIELD is
when Active_Error_Flag =>
end case
- 52 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 53 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 54 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
P B B
o Si u
s at s T
i mE D x
t pr r R
i lr i q R T
o eo v s E E
Time Node n State/Field at SamplePt dr e t C C
1800 RefCAN0 1 Wait_For_Bus_Idle 10 1 F 0 0
1801 RefCAN1 1 Wait_For_Bus_Idle 10 1 F 0 0
1802 RefCAN2 1 Wait_For_Bus_Idle 10 1 F 0 0
2050 Implementation and refCAN are synchronised
2800 RefCAN0 2 Wait_For_Bus_Idle 01 1 F 0 0
.................
13802 RefCAN2 11 Wait_For_Bus_Idle 10 1 F 0 0
14050 WAIT_FOR: STATUS, FIELD and POSITION reached !
14050 ===============================================================
14050 | Start of Test (Receive Error Counter counts up and down) |
14050 ===============================================================
14800 RefCAN0 1 Bus_Idle 01 1 F 0 0
.................
Figure 15 Start of a simulation’s trace file (e.g. test program emlcount).
.................
906800 RefCAN0 8 Tx_Identifier 00 1 T 127 120
906801 RefCAN1 8 Tx_Identifier 00 1 T 127 120
906802 RefCAN2 8 Tx_Identifier 00 0 F 12 16
907600 Tx_Rqst_Status of CAN0 changed to PENDING
907601 Tx_Rqst_Status of CAN1 changed to PENDING
907800 RefCAN0 9 Tx_Identifier 01 1 T 127 120
907801 RefCAN1 9 Tx_Identifier 01 1 T 127 120
907802 RefCAN2 9 Tx_Identifier 00 0 F 12 16
908800 RefCAN0 10 Rx_Identifier 01 1 T 127 120
908801 RefCAN1 10 Rx_Identifier 01 1 T 127 120
908802 RefCAN2 10 Tx_Identifier 00 0 F 12 16
909800 RefCAN0 11 Rx_Identifier 01 1 T 127 120
909801 RefCAN1 11 Rx_Identifier 01 1 T 127 120
909802 RefCAN2 11 Tx_Identifier 00 0 F 12 16
910800 RefCAN0 1 Rx_RTR_Bit 01 1 T 127 120
910801 RefCAN1 1 Rx_RTR_Bit 01 1 T 127 120
910802 RefCAN2 1 Tx_RTR_Bit 00 1 F 12 16
911800 RefCAN0 S Rx_RTR_Bit 10 1 T 127 120
911801 RefCAN1 S Rx_RTR_Bit 10 1 T 127 120
911802 RefCAN2 S Tx_RTR_Bit 10 0 F 12 16
912800 RefCAN0 1 Rx_IDE_Bit 01 1 T 127 120
912801 RefCAN1 1 Rx_IDE_Bit 01 1 T 127 120
912802 RefCAN2 1 Tx_IDE_Bit 00 1 F 12 16
913800 RefCAN0 1 Rx_Reserved_Bits 10 1 T 127 120
913801 RefCAN1 1 Rx_Reserved_Bits 10 1 T 127 120
913802 RefCAN2 1 Tx_Reserved_Bits 10 0 F 12 16
.................
Figure 16 Example of lost arbitration in a simulation’s trace file (e.g. test program emlcount).
- 55 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
In figure 16, RefCAN1 and the parallely simulated RefCAN0 (the implementation) lose arbitration at the
9th Identifier bit. In figure 17, RefCAN2 does not send Acknowledge because of a CRC Error, therefore
RefCAN1 and RefCAN0 see an Acknowledge Error.
.................
45800 RefCAN0 13 Rx_CRC_Sequence 01 1 F 0 0
45801 RefCAN1 13 Rx_CRC_Sequence 01 1 F 0 0
45802 RefCAN2 13 Tx_CRC_Sequence 00 0 T 0 0
46800 RefCAN0 14 Rx_CRC_Sequence 01 1 F 0 0
46801 RefCAN1 14 Rx_CRC_Sequence 01 1 F 0 0
46802 RefCAN2 14 Tx_CRC_Sequence 00 1 T 0 0
47800 RefCAN0 15 Rx_CRC_Sequence 10 1 F 0 0
47801 RefCAN1 15 Rx_CRC_Sequence 10 1 F 0 0
47802 RefCAN2 15 Tx_CRC_Sequence 10 1 T 0 0
48800 RefCAN0 1 Rx_CRC_Delimiter 10 1 F 0 0
48801 RefCAN1 1 Rx_CRC_Delimiter 10 1 F 0 0
48802 RefCAN2 1 Tx_CRC_Delimiter 10 1 T 0 0
49800 RefCAN0 1 Rx_ACK_Slot 10 1 F 0 0
49801 RefCAN1 1 Rx_ACK_Slot 10 1 F 0 0
49802 RefCAN2 1 Tx_ACK_Slot 10 0 T 0 8
50602 Tx_Rqst_Status of CAN2 changed to ERROR
50800 RefCAN0 1 Rx_ACK_Delimiter 01 0 F 1 0
50801 RefCAN1 1 Rx_ACK_Delimiter 01 0 F 1 0
50802 RefCAN2 1 Tx_Active_Error_Flag 00 0 T 0 8
51602 Tx_Rqst_Status of CAN2 changed to PENDING
51800 RefCAN0 1 Rx_Active_Error_Flag 00 0 F 1 0
51801 RefCAN1 1 Rx_Active_Error_Flag 00 0 F 1 0
51802 RefCAN2 2 Tx_Active_Error_Flag 00 0 T 0 8
52800 RefCAN0 2 Rx_Active_Error_Flag 00 0 F 1 0
52801 RefCAN1 2 Rx_Active_Error_Flag 00 0 F 1 0
.................
Figure 17 Example of CRC Error in a simulation’s trace file (e.g. test program crc).
- 56 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
In the Reference CAN Model, the RECEIVE_ERROR_COUNTER is used to count the Busoff Recovery
Sequence, a dedicated RECESSIVE_COUNTER is used to count the sequences of 11 consecutive recessive
bits. Both implementations are not obligatory; the internal structure of architecture REFERENCE is
designed to interface with the protocol check processes, it is not intended as an example for hardware
implementations of CAN protocol controllers.
- 57 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
TRANSMIT_DATA RECEIVE_DATA
E = CAN_INTERFACE
E = CPU E = CAN_MODULE
CPU_BUS
Control Signals
MODEL_LABEL = generic
RECEIVE_INTERRUPT
A = READ_WRITE A = SIMPLE
A = EXAMPLE
Interface Signals
- 58 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
TRANSMIT_DATA RECEIVE_DATA
E = CAN_MODULE
P = SYNCHRONIZE_
RECEIVED_DATA
SYNCHRONIZED_DATA
E = CAN_INTERFACE
MODEL_LABEL = generic
A = REFERENCE
E = CAN_MESSAGE E = CAN_CONTROL
A = BASIC A = TIMING
16 INTERNAL_BUS
E = CPU_INTERFACE
A = PARALLEL_16_BIT
RECEIVE_INTERRUPT
PROCESSING_TIME
REQUEST_STATUS
TRANSMISSION_
16
Control Sognals
INFORMATION_
CPU_BUS
RESET
CLK
- 59 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
This is a structural architecture of a CAN module with a basic message memory. It can be used as a
template showing how a CAN module implementation should look like to be simulated together with the
Reference CAN Model node in the CAN protocol testbench.
In the configuration CONFIGURATION_EXAMPLE, the component CAN_PROTOCOL_CONTROLLER is
associated with architecture REFERENCE, the component MESSAGE_MEMORY is associated with
architecture BASIC, the component CONTROL_REGISTER is associated with architecture TIMING, and
the component CPU_ACCESS is associated with architecture PARALLEL_16_BIT.
This structure is only an example, it is by no means a mandatory standard for all implementations; e.g.,
the control register could be part of a synthesizable protocol controller. The internal structure of the CAN
module is optional, but the user has to be aware that using the testbench and the test programs supplied
with this VHDL Reference CAN Model only assures the conformity of the CAN Protocol Controller part
of the implementation with CAN Protocol Version 2.0 Part A, B. In order to verify the correct function
of the CPU interface and of the message memory, the user has to write additional test programs.
Table 1: Address map of the CAN module’s message memory in architecture BASIC.
The messages are stored as std_logic_vectors, a bit with value ‘0’ corresponds to a dominant bit on the
CAN bus, a bit with value ‘1’ corresponds to a recessive bit. In case of standard frames, only the first 11
of the 29 Identifier bits are used, Identifier (28 downto 18) is then regarded as Identifier (10 downto 0).
In the RECEIVE_BUFFER, New_Data and Message_Lost are status bits, which can be read and written
by the CPU. Each time a message is received, the message memory sets New_Data; the CPU is expected
to reset New_Data before reading the message. When New_Data is not reset at the reception of the next
message, the message memory will set Message_Lost. Each reception of a message is signalled to the
CPU by a pulse of the interrupt line RECEIVE_INTERRUPT.
The message memory does not do any acceptance filtering, each received message is stored into the
RECEIVE_BUFFER. When a new message is stored, the previous message is lost. The reception of a
message is documented by printing the content of the message into the simulation’s trace file.
In the TRANSMIT_BUFFER, Do_Transmit and Tx_Pending are command and status bits, which can be
read and written by the CPU. The CPU sets both Do_Transmit and Tx_Pending to request the
transmission of a message. When the transmission has started, the message memory resets Tx_Pending.
- 60 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
When the transmission is successfully completed and Tx_Pending is not set again by the CPU, the
message memory resets Do_Transmit. If the CPU resets Do_Transmit before the transmission is
completed, the transmission will not be repeated in case of an error or when it lost arbitration. The
TRANSMISSION_REQUEST signal to the CAN Protocol Controller is active as long as Do_Transmit is
set. Any changes of TRANSMISSION_REQUEST are documented by printing a note into the simulation’s
trace file.
Table 2: Address map of the CAN module’s control register in architecture TIMING.
- 61 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
The CPU actions in table 3 are listed in order of priority, with writing into TIMING_REGISTER having
the highest and NOP having the lowest priority. Each action of CPU is documented by printing a note into
the simulation’s trace file.
This architecture READ_WRITE of entity CPU is specifically designed to interface between the protocol
test programs and the architecture SIMPLE of entity CAN_MODULE. Other CAN module implementations
will require a different CPU entity, interfacing the particular type of data bus of the CAN module’s
entity. Those implementation specific CPU models will have to provide the same features as
READ_WRITE.
- 62 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 63 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
4.5 TEST_PROGRAM
For the verification of CAN Protocol Controllers, the PROTOCOL_TESTBENCH (see chapter 4 at page 27)
is provided with a set of test programs. Each test program is described by a separate architecture <test>
of TEST_PROGRAM (<test> stands for the individual program’s name), it is linked by a configuration
of PROTOCOL_TESTBENCH (see section 5.2). All <test> architectures have the same structure (shown
in figure 20), consisting of the three processes STIMULI, REQUEST and SYNCHRONIZE_REQUEST. The
‘Interface Signals’ link the test program with the CAN nodes located in the architecture FLEXIBLE of
CAN_SYSTEM.
Interface Signals
E = TEST_PROGRAM
TRANSMISSION_REQUEST
TRANSMISSION_REQUEST_STATUS
SET_TRANSMISSION_REQUEST
P = SYNCHRONIZE_REQUEST
RESET_TRANSMISSION_REQUEST
HOLD_TRANSMISSION_REQUEST
P = REQUEST
START_TRANSMISSION
P = STIMULI RESET_REQUEST
DO_ARBITRATION
REQUEST_WHILE_BUSY
REQUEST_ACCEPTED
A = <test>
The test program is subdivided into three processes. REQUEST and SYNCHRONIZE_REQUEST control the
TRANSMISSION_REQUEST inputs of all CAN nodes, while STIMULI controls the RESET,
BIT_TIMING_CONFIGURATION, and the TRANSMIT_MESSAGE inputs of all CAN nodes in the
CAN_SYSTEM, as well as the BUS_INTERFERENCE inputs of all BUS_INTERFACE components. The
TRANSMISSION_REQUEST inputs are driven by a separate process, because the
TRANSMISSION_REQUEST input of one particular CAN node depends on the state transitions of the
corresponding TRANSMISSION_REQUEST_STATUS port, while the inputs RESET,
BIT_TIMING_CONFIGURATION, TRANSMIT_MESSAGE, and BUS_INTERFERENCE are driven as
required by the flow of the protocol test program.
The subdivision allows STIMULI to require REQUEST and SYNCHRONIZE_REQUEST to set the
TRANSMISSION_REQUEST inputs of several CAN nodes at the same time and to continue the program
without waiting for the proper reset conditions of the separate TRANSMISSION_REQUEST inputs.
STIMULI, REQUEST and SYNCHRONIZE_REQUEST communicate by means of internal signals of
TEST_PROGRAM (for an example of a test program see section 5.3).
- 64 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Processes REQUEST and SYNCHRONIZE_REQUEST, the internal signals of TEST_PROGRAM, and the
procedures used by STIMULI are the same for all architectures of TEST_PROGRAM. Therefore they are
extracted from the test program source code files and stored in separate *.vhi files. The core of the
source code, the STIMULI process, remains in the file <test>.vpp, referencing the *.vhi files by
“# include” statements. The internal signals of TEST_PROGRAM are defined in file
signal_definition.vhi, request_process.vhi contains the processes REQUEST and
SYNCHRONIZE_REQUEST, while the internal procedures of STIMULI are shifted into
test_routines.vhi.
‘make’ uses the C-compiler’s preprocessor cpp to process the “# include” statements, generating the file
<test>.vhd from <test>.vpp and the *.vhi files (see section 5.3).
INITIALIZE sets RESET active, disables all TRANSMISSION_REQUEST signals, assigns the actual
BIT_TIMING_CONFIGURATION as well as the internal signal BIT_TIME and sets BUS_INTERFERENCE
to NONE for all nodes in CAN_SYSTEM.
After the initialization, RESET is disabled and the CAN nodes are synchronized by applying an edge from
recessive to dominant to the RECEIVE_DATA inputs of all CAN nodes. Since the time from the end of
the hardware reset to the begin of the CAN bus activity is implementation-specific, depending e.g. on
the extent of the message memory’s initialization, INITIALIZE adapts to this time, controlled by the
generic parameters INITIALIZATION_CYCLES and INIT_SETUP of TEST_PROGRAM.
The default value of INITIALIZATION_CYCLES is 1, resulting in only one synchronisation-edge after
the hardware reset, but if a higher value is defined in a configuration of the PROTOCOL_TESTBENCH, a
sequence of dominant and recessive bits gives the necessary time for initialization. After the last
dominant bit, all CAN nodes in CAN_SYSTEM are expected to have started their CAN bus activities and
all nodes are waiting synchronously for a sequence of 11 recessive bits before starting the reception and
transmission of frames. INIT_SETUP adjusts the evaluation time of the process STIMULI of
TEST_PROGRAM with respect to the CAN bit time.
- 65 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
WAIT_FOR waits until the CAN node specified by CAN_LABEL reaches the sample point of a bit
POSITION in a CAN frame FIELD while being in a particular STATUS. After this sample point,
WAIT_FOR waits for the the end of Phase Buffer Segment 2, synchronizing the test program to the CAN
bus.
If the desired conditions are not met before a limit of MAXIMUM_WAIT_PERIODS • CLOCK_PERIOD(1)
is reached, the simulation is stopped by an assertion of severity failure. This limit is implemented to
avoid never-ending loops. The default value of the natural signal MAXIMUM_WAIT_PERIODS is 2000
(defined in signal_definition.vhi); the value may be changed in the test program.
SEND_MESSAGE assigns MESSAGE to the TRANSMIT_MESSAGE input of the CAN node specified by
CAN_LABEL and triggers the REQUEST process to set the transmission request for the labelled CAN.
Then the procedure (or the process REQUEST, see section 4.5.2) waits for the specified
COMPLETION_CONDITION.
There are four COMPLETION_CONDITIONS:
• REQUESTED: SEND_MESSAGE just requests a transmission.
• STARTED: SEND_MESSAGE waits until the requested transmission has started on the CAN bus.
• SUCCEEDED_OR_ERROR: SEND_MESSAGE waits until the requested transmission has completed
or is interrupted by an error frame.
• SUCCEDED: SEND_MESSAGE waits until the requested transmission has completed.
- 66 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
STIMULI or, to be more specific, its local procedure SEND_MESSAGE, has three options to control the
TRANSMISSION_REQUEST input of a CAN node :
• It can control TRANSMISSION_REQUEST directly by SET_TRANSMISSION_REQUEST and
RESET_TRANSMISSION_REQUEST.
• START_TRANSMISSION requires REQUEST to activate TRANSMISSION_REQUEST until
TRANSMISSION_REQUEST_STATUS changes to TRANSMITTING.
• HOLD_TRANSMISSION_REQUEST requires REQUEST to activate TRANSMISSION_REQUEST until
TRANSMISSION_REQUEST_STATUS changes to DONE.
REQUEST_WHILE_BUSY is a boolean vector, with one element for each node in the CAN_SYSTEM. Its
elements are set to true by REQUEST if STIMULI requests a transmission for a particular CAN node while
that CAN node is already busy with a transmission.
Status information about transmission requests of the CAN nodes is written to the simulation’s trace file.
- 67 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Figure 21 shows a section from baudrate.vpp where the implementation and three RefCAN’s start
arbitration synchronously.
.................
.................
- 68 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
5 Verification of an Implementation
The design of integrated protocol controllers generally has to emphasize the verification of completeness
and correctness of the protocol. For Controller Area Network (CAN), which is licensed to most major
semiconductor suppliers, it is of special importance to standardize the protocol verification by means of
a High Level Language reference environment. Due to the variety of CAN controller implementations
(see figure 22 at page 70), the reference must be limited to the modelling of the protocol itself, leaving
complete freedom to the application specific part of the component.
The Reference CAN Model environment consists of the “golden” CAN protocol model and a testbench,
consisting of test programs and a simulator kernel. In the testbench the model of a CAN controller under
development can be compared with the concurrently simulated reference model, while the test program
and other instances of the reference model provide CAN messages.
For the development of the first CAN controller implementation, the only reference was the CAN
protocol specification document. Therefore a set of test programs had to be developed to simulate all
relevant state transitions of CAN message transfer. The protocol consistency of the design was ensured
by manually checking the simulation results line for line with the protocol specification.
For the following design, the existing set of test programs was adapted to a different CPU interface and
to a different message buffer structure. Checking of simulation results was partly automated by checking
with the simulation results of the first design. The disadvantage of that method is that it is closely linked
to the structure of the CAN implementation and to the simulation tool. In view of time and cost to be
invested for designing an integrated protocol controller, this verification is insufficient and carries high
risk for costly redesign iterations.
The increasing number of CAN licensees and developments of integrated CAN components made it
necessary to standardize and to support the protocol verification for all designs. For this purpose and
motivated by the aforementioned experience, Bosch has developed the C Reference CAN Model.
While the CAN protocol specification document remains the authentic CAN norm standardized by
international organisations, the C Reference CAN Model establishes a de facto standard for CAN
verification. Distributed to the CAN licensees, it has been utilized in various designs, assuring that all
existing CAN implementations are compatible with each other and may be used in the same network.
For the success of CAN as the generally accepted protocol standard, the wide range of versatile
compatible CAN implementations of different vendors was important. This protocol consistency was
significantly supported by the availability of the Reference CAN Model.
To be independent from simulation tools and from different types of CAN implementations, the first
version of the model has been written in "C"-language (together with a simulator kernel) and is limited
to the protocol itself (the data link layer of the OSI model), leaving out the physical layer and the
application layer, which are implementation specific.
Up to now, the Reference CAN Model has been used by Robert Bosch GmbH for the verification of ten
CAN implementations and by CAN designers of the licensees, including most major semiconductor
suppliers. In this way, the compatibility of all existing CAN implementations is guaranteed.
The Reference CAN model is represented in two versions, the realisation in C (as distributed to the CAN
licensees) and its translation in VHDL (an option for the CAN licensees). While the VHDL simulator of
any designer’s CAD environment should be compatible with the VHDL version, the C version is
provided with a specific and custom simulator kernel and is not connected to a specific IC design tool.
- 69 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
The continuous spreading of VHDL (Very High Speed Hardware Description Language) as a standard
design language for IC development urged the conversion of the Reference CAN Model from the
customized C simulation environment to a VHDL environment.
Since a considerable amount of work and know-how had been invested in the C model of the CAN
Protocol Controller and into the verification test programs, that had to be taken into account when
developing the strategy for the conversion from C into VHDL.
For the understanding of the extent of the model, it is useful to split existing CAN controller
implementations in protocol related and application related sections. The CAN Protocol Controller is the
kernel of each CAN implementation, interfacing between the physical layer and the application layer.
The VHDL reference model of the protocol controller is behaviourally structured, it is not targeted for
synthesis but for the functional verification.
Different types of CAN implementations are offered by several semiconductor suppliers, realized as
stand-alone device or as module on a µC. The differences of those implementations lie in the number of
local message buffers, in the acceptance filtering, in the CAN busline input comparators and output
drivers, and in the CPU and periphery interface.
CAN Bus
Status
Receive
Message
Message
Message
Object n
Object 2
Object 1
Transmit
Buffer Port Module with
Control
Control
Buffer
(FIFO)
Digital (and Analog)
Common for all implementations is the CAN Protocol Controller whose function is defined by the CAN
protocol specification; it handles the bit timing, the frame coding, the bit stuffing, the CRC check, the
frame validation and the fault confinement. The interface to the physical layer is the serial bit stream,
- 70 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
coded as dominant or recessive bits; the interface to the application layer are the transferred messages,
consisting of identifier, data length code, and data bytes, without CRC code or stuff bits. The acceptance
filtering, based upon the identifier, is done by the application layer.
The reference model’s testbench and test programs are designed to test exclusively the implementation’s
protocol controller, independent of the other functions of the implementation. This is done by comparing
the function of the implementation’s protocol controller with the function of the reference controller
during the simulation of CAN message transfer and CAN bus errors.
Since the CPU interface and the application layer are not defined by the CAN protocol specification, an
interface is needed between the test programs of the Reference CAN Model and the models of the
implementations.
In the C version, that interface is provided by the functions called by the test programs for the
initialisation of the models and for the start of the transmission of a CAN message. When these functions
are adapted to the specific implementation, the test programs themselves, calling these functions, remain
unchanged regardless of the type of the implementation.
Other implementation specific parts of the C version are the functions called for the CAN protocol check
process, monitoring the implementation’s CAN functions and the CAN bus process, connecting the
implementation to the CAN bus. These functions have to be adapted if the signal names for the CAN
input or output signals differ from the names in the reference protocol controller model.
In the VHDL version, the interface between the protocol test programs, the Reference CAN Model and
the implementation’s model is the entity CAN_INTERFACE, associated with an architecture enclosing the
implementation’s model. All implementation specific type conversions of interface signals and
translations of test program commands are done inside this architecture, leaving the rest of the Reference
CAN Model untouched. Test programs, reference and implementation’s models and the CAN bus system
are linked together by a configuration of the PROTOCOL_TESTBENCH.
During a simulation, the Reference CAN Model produces a trace file recording all serial data on the CAN
bus and the internal activities of the CAN Protocol Controllers as well as the possible occurrence of a
protocol error. Optionally, a similar trace function for the implementation may be added for the manual
comparison of the CAN functions.
If the Reference CAN Model is used for the verification of an implementation’s model in a different
design environment, e.g. a hardware tester, the trace function can be expanded by a pattern generator,
writing test vectors in any desired format.
In order to retain the invested know-how and to reduce possible design risks, the internal structure of
model, testbench, and test program of the C model have been remodelled in the VHDL model. The
protocol test program set was translated verbatim from C to VHDL, producing the same CAN message
transfer and the same CAN bus errors, enabling the automated verification of the VHDL model by the
comparison of the simulation’s trace files.
Main issues of the actual design work have been, apart from the detailed verification, the independency
from any VHDL tool’s deviations (up to now, Synopsys VSS and Mentor QuickHDL have been
evaluated) and the self-containment of the models of the CAN Protocol Controller and of the CAN bus,
giving the possibility to combine them with other VHDL models of periphery and systems.
The Reference CAN Model supports the circuit development for CAN implementations by providing a
verification tool that can be adapted to different design environments. Furthermore, the application of
the Reference CAN Model is not limited to the test of IC implementations, its simulation environment
with CAN message transfer between several nodes can be expanded with additional processes simulating
peripheral hardware to use it as a design tool for the development of CAN based systems.
- 71 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
An architecture as described in EXAMPLE is recommended for all cases of standalone CAN controllers
and for those CAN modules on microcontrollers, whose CPU interface can be accessed from the outside
(at least in a test mode). The advantage of this solution, simulating the whole device, compared to other
- 72 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
solutions (e.g. extracting the CAN Protocol Controller from the implementation and simulating without
a CPU component in architecture IMPLEMENTATION) is that it can produce test vectors for the device’s
pins. With these test vectors, the protocol test programs can be transferred to hardware testers.
Especially for the verification of the message memory, the CPU state machine should not be restricted
to the translation of the test program’s input to the CAN module, it also should (with lower priority) read
status registers and received messages from the message memory (see architecture READ_WRITE of
CPU at page 62), making this internal information visible at the device’s pins.
For those CAN modules on µCs, whose CPU interface is only accessible by the local CPU, not from the
outside, a different structure for architecture IMPLEMENTATION is recommended (see figure 23),
providing the same features as verification of the message memory and compatibility with a hardware
tester.
TRANSMIT_DATA RECEIVE_DATA
E = CAN_INTERFACE
E = EMBEDDED_WITH_CAN
CAN_MODULE
CPU MEMORY
PERIPHERY
A = DUT
E = ROM
A = OPCODE
A = IMPLEMENTATION
Interface Signals
- 73 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
For this solution, the local CPU has to have the capability (at least in test mode) to read op-codes from
an external memory. As in EXAMPLE, the entire device should be simulated, but the other component in
the architecture, replacing the CPU state machine, is a program memory, providing op-codes to the local
CPU. This program memory translates the protocol test program’s commands into executable code,
causing the CPU in the device under test to write to the CAN module’s registers.
- 74 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
library CAN_LIBRARY;
---------------------------------------------------------------------
-- This configuration defines the following entity/architecture pairs:
-- PROTOCOL_TESTBENCH - STRUCTURAL
-- CAN_SYSTEM - FLEXIBLE (only 2 Reference Models)
-- CAN_INTERFACE - REFERENCE
-- It is used with configuration IMPLEMENTATION of CAN_INTERFACE
---------------------------------------------------------------------
configuration CFG_TEMPLATE of PROTOCOL_TESTBENCH is
for STRUCTURAL
for SYSTEM: CAN_SYSTEM
use configuration CAN_LIBRARY.CONFIGURATION_SYS_R
generic map (
NUMBER_OF_CANS => 2,
CLOCK_PERIOD => (others => 100 ns),
RX_DELAY => 0.00
);
end for;
for WAVEFORM: TEST_PROGRAM
use entity CAN_LIBRARY.TEST_PROGRAM(TEMPLATE)
generic map (
CLOCK_PERIOD => (others => 100 ns),
INFORMATION_PROCESSING_TIME => 2,
INITIALIZATION_CYCLES => 1,
INIT_SETUP => 0.80,
RX_DELAY => 0.00
);
end for;
end for;
end CFG_TEMPLATE;
Figure 24 Template for a testbench configuration.
The following generic parameters define the timing of the CAN system’s simulation :
CLOCK_PERIOD is an array of time values. It ranges from 0 to (NUMBER_OF_CANS + 1), providing each
CAN node (1 to NUMBER_OF_CANS) in the CAN system with an independent clock source.
CLOCK_PERIOD(0) is reserved for the clock of the implementation under test, with
CLOCK_PERIOD(NUMBER_OF_CANS + 1) as an option for the implementation’s local CPU. In
this configuration, all nodes use the same clock period of 100 ns
RX_DELAY is an input delay factor, to be multiplied with the implementation model’s clock period. Used
in the architecture COMPARE of CAN_INTERFACE to compensate the delay time caused by the syn-
chronization of the CAN input signal to the implementation model’s clock.
CLOCK_PERIOD and RX_DELAY have to be the same for CAN_SYSTEM and TEST_PROGRAM.
- 75 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
INITIALIZATION_CYCLES is a parameter that allows to compensate for the time needed to initialise
the implementation’s model after a hardware reset. One cycle is two CAN bit times.
INIT_SETUP is a phase shift factor. The evaluation time steps of the test program are shifted with respect
to the active (rising) clock edge of the Reference CAN Model by the amount of INIT_SETUP •
CLOCK_PERIOD(1). The phase shift provides a setup time between the edges of the interface sig-
nals driven by the test program and the internal state transitions of the Reference CAN Model.
Figure 25 shows the configuration of the PROTOCOL_TESTBENCH to simulate the test program
BAUDRATE (see file $BOSCH_CAN_ROOT/tests/baudrate/cfg_baudrate_example.vhd).
library CAN_LIBRARY;
---------------------------------------------------------------------
-- This configuration defines the following entity/architecture pairs:
-- PROTOCOL_TESTBENCH - STRUCTURAL
-- CAN_SYSTEM - FLEXIBLE (1 Example-Implementation and 3 Ref. Models)
-- CAN_INTERFACE - EXAMPLE
-- It is used with configuration EXAMPLE of CAN_INTERFACE
---------------------------------------------------------------------
configuration CFG_BAUDRATE_EXAMPLE of PROTOCOL_TESTBENCH is
for STRUCTURAL
for SYSTEM: CAN_SYSTEM
use configuration CAN_LIBRARY.CONFIGURATION_SYS_E
generic map (
NUMBER_OF_CANS => 3,
CLOCK_PERIOD => (110 ns, 110 ns, 1118 ns, 442 ns,
others => 110 ns),
RX_DELAY => 0.001
);
end for;
for WAVEFORM: TEST_PROGRAM
use entity CAN_LIBRARY.TEST_PROGRAM(BAUDRATE)
generic map (
CLOCK_PERIOD => (110 ns, 110 ns, 1118 ns, 442 ns,
others => 110 ns),
INFORMATION_PROCESSING_TIME => 0,
INITIALIZATION_CYCLES => 3,
INIT_SETUP => 0.10,
RX_DELAY => 0.001
);
end for;
end for;
end CFG_BAUDRATE_EXAMPLE;
Figure 25 Testbench configuration for test program BAUDRATE simulating architecture EXAMPLE.
In this test program, three (NUMBER_OF_CANS) CAN nodes communicate in the CAN_SYSTEM, one of
the nodes made up of the architectures EXAMPLE and REFERENCE simulated in parallel
(CONFIGURATION_SYS_E, see section 4.2.2). EXAMPLE is granted time for initialisation
(INITIALIZATION_CYCLES) after reset. EXAMPLE operates with a clock period of 110 ns, same as the
parallely simulated REFERENCE and EXAMPLE’s local CPU. The REFERENCE(2) operates with a clock
period of 1118 ns, REFERENCE(3) with a clock period of 442 ns. The CAN node’s baud rate prescaler
provide a common bit time regardless of the difference in the clock sources.
- 76 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
Each new test program requires a specific directory in $BOSCH_CAN_ROOT/tests/, with the same
name as the new architecture. The new file <test>.vpp starts as a copy of template.vpp, the
architecture’s name changed from TEMPLATE to <test> and the TIMING configuration changed to the
- 77 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
actual values. The test program code is inserted between the comments “start of test program“
and “end of test program“, additional constants (e.g. messages to be transmitted), signals, and
variables are defined at the positions shown by the appropriate comments.
For compilation and simulation of the new test programs, targets have to be defined in the Makefile.
- 78 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 79 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
doc - documentation
Users_Manual_V.pdf - Users Manual
DataSheet_V.pdf - Data Sheet
can2spec.pdf - CAN Protocol Specification Revision 2.0
- 80 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 81 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 82 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 83 - K8/EIS
VHDL Reference CAN User’s Manual Revision 2.2
- 84 - K8/EIS