Bitvis VIP UART
Quick Access
BFM
BFM functionality is implemented in uart_bfm_pkg.vhd
Configuration Record
t_uart_bfm_config
Default value for the record is C_UART_BFM_CONFIG_DEFAULT.
Record element |
Type |
Default |
Description |
---|---|---|---|
bit_time |
time |
-1 ns |
The time it takes to transfer one bit. Will raise an error if not set. |
num_data_bits |
natural range 7 to 8 |
8 |
Number of data bits to send per transmission |
idle_state |
std_logic |
‘1’ |
Bit value when line is idle |
num_stop_bits |
STOP_BITS_ONE |
Number of stop-bits to use per transmission |
|
parity |
PARITY_ODD |
Transmission parity bit |
|
timeout |
time |
0 ns |
The maximum time to wait for the UART start bit on the RX line before timeout |
timeout_severity |
ERROR |
The above timeout will have this severity |
|
num_bytes_to_log_before_expected_data |
natural |
10 |
Maximum number of bytes to save ahead of the expected data in the receive buffer. The bytes in the receive buffer will be logged. |
match_strictness |
MATCH_EXACT |
Matching strictness for std_logic values in check procedures. MATCH_EXACT requires both values to be the same. Note that the expected value can contain the don’t care operator ‘-‘. MATCH_STD allows comparisons between ‘H’ and ‘1’, ‘L’ and ‘0’ and ‘-’ in both values. |
|
id_for_bfm |
t_msg_id |
ID_BFM |
Message ID used for logging general messages in the BFM |
id_for_bfm_wait |
t_msg_id |
ID_BFM_WAIT |
Message ID used for logging waits in the BFM |
id_for_bfm_poll |
t_msg_id |
ID_BFM_POLL |
DEPRECATED |
id_for_bfm_poll_summary |
t_msg_id |
ID_BFM_POLL_SUMMARY |
Message ID used for logging polling summary in the BFM |
error_injection |
t_bfm_error_injection |
C_BFM_ERROR_INJECTION_INACTIVE |
Record to set up error injection in the BFM procedure calls |
t_bfm_error_injection
Default value for the record is C_BFM_ERROR_INJECTION_INACTIVE.
Record element |
Type |
Default |
Description |
---|---|---|---|
parity_bit_error |
boolean |
false |
Will invert the parity bit in a transmission if TRUE, and thus generate a parity error. |
stop_bit_error |
boolean |
false |
Will invert the first stop bit in a transmission if TRUE. Note that the following UART frame may be misinterpreted if there is no Idle period or additional stop bits after the error injection. Hence a stop_bit_error may lead to multiple following UART frame errors. |
For more information on error injection, please see Protocol Aware Error Injection.
Methods
All signals are active high.
All parameters in brackets are optional.
Note
The BFM configuration has to be defined and used when calling the UART BFM procedures. See Local BFM configuration for an example of how to define a local BFM config.
uart_transmit()
Transmits data to the DUT using the UART protocol. For protocol details, see the UART specification.
The start bit, stop bit, parity, number of stop bits and number of data bits per transmission is defined in the ‘config’ parameter.
Errors may be injected depending on the ‘config.error_injection’ sub-record.
uart_transmit(data_value, msg, tx, [config, [scope, [msg_id_panel]]])
Object |
Name |
Dir. |
Type |
Description |
---|---|---|---|---|
constant |
data_value |
in |
std_logic_vector |
The data value to be transmitted to the DUT |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
signal |
tx |
inout |
std_logic |
The UART BFM transmission signal. Must be connected to the UART DUT ‘rx’ port. |
constant |
config |
in |
Configuration of BFM behavior and restrictions. Default value is C_UART_BFM_CONFIG_DEFAULT. |
|
constant |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_BFM_SCOPE (“UART BFM”). |
constant |
msg_id_panel |
in |
t_msg_id_panel |
Controls verbosity within a specified scope. Default value is shared_msg_id_panel. |
-- Examples:
uart_transmit(x"AA", "Transmitting data to DUT UART", tx);
uart_transmit(x"AA", "Transmitting data to DUT UART", tx, C_UART_BFM_CONFIG_DEFAULT, C_SCOPE, shared_msg_id_panel);
-- Suggested usage (requires local overload, see 'Local BFM overloads' section):
uart_transmit(C_ASCII_A, "Transmitting ASCII A to DUT UART");
uart_receive()
Receives data from the DUT using the UART protocol. For protocol details, see the UART specification.
When called, the procedure will wait for the start bit to be present on the rx line. The initial wait for the start bit will be terminated if one of the following occurs:
The start bit is present on the rx line.
The terminate_loop flag is set to ‘1’.
The number of clock cycles waited for the start bit exceeds ‘config.max_wait_cycles’ clock cycles.
Once all the bits have been received according to the UART specification, the parity and stop bit are checked. If correct, the read data is placed on the output ‘data_value’ and the procedure returns.
The procedure reports an alert if:
Timeout occurs, i.e. start bit does not occur within ‘config.max_wait_cycles’ clock cycles (alert level: ‘config.max_wait_cycles_severity’)
terminate_loop is set to ‘1’ (alert level: WARNING)
Expected stop_bit does not match received stop bit(s) (alert level: ERROR)
Calculated parity ‘config.parity’ does not match received parity (alert level: ERROR)
uart_receive(data_value, msg, rx, terminate_loop, [config, [scope, [msg_id_panel]]])
Object |
Name |
Dir. |
Type |
Description |
---|---|---|---|---|
variable |
data_value |
out |
std_logic_vector |
The data value received from the DUT |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
signal |
rx |
in |
std_logic |
The UART BFM reception signal. Must be connected to the UART DUT ‘tx’ port. |
signal |
terminate_loop |
in |
std_logic |
External control of loop termination to e.g. stop expect procedure prematurely |
constant |
config |
in |
Configuration of BFM behavior and restrictions. Default value is C_UART_BFM_CONFIG_DEFAULT. |
|
constant |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_BFM_SCOPE (“UART BFM”). |
constant |
msg_id_panel |
in |
t_msg_id_panel |
Controls verbosity within a specified scope. Default value is shared_msg_id_panel. |
-- Examples:
uart_receive(v_data_out, "Receive from DUT UART", rx, terminate_signal);
uart_receive(v_data_out, "Receive from DUT UART", rx, terminate_signal, C_UART_BFM_CONFIG_DEFAULT, C_SCOPE, shared_msg_id_panel);
-- Suggested usage (requires local overload, see 'Local BFM overloads' section):
uart_receive(v_data_out, "Receive from DUT UART");
uart_expect()
Receives data from the DUT using the UART protocol described under uart_receive(). After receiving data from the DUT, the received data is compared with the expected data. If the received data does not match the expected data, another uart_receive() procedure will be initiated. This process will repeat until one of the following occurs:
The received data matches the expected data.
A timeout occurs.
The process has repeated ‘max_receptions’ number of times.
The ‘terminate_loop’ signal is set to ‘1’.
‘max_receptions’ and ‘timeout’ are set to 0, which will result in a possible infinite loop (alert_level: ERROR)
The expected data is not received within the time set in ‘timeout’ (alert_level: ‘alert_level’)
The expected data is not received within the number of received packets set in ‘max_receptions’ (alert_level: ‘alert_level’)
‘terminate_loop’ is set to ‘1’ (alert_level: WARNING)
The same alert conditions as the uart_receive() procedure.
uart_expect(data_exp, msg, rx, terminate_loop, [max_receptions, [timeout, [alert_level, [config, [scope, [msg_id_panel]]]]])
Object |
Name |
Dir. |
Type |
Description |
---|---|---|---|---|
constant |
data_exp |
in |
std_logic_vector |
The data value to expect when receiving the data. A mismatch results in an alert with severity ‘alert_level’ |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
signal |
rx |
in |
std_logic |
The UART BFM reception signal. Must be connected to the UART DUT ‘tx’ port. |
signal |
terminate_loop |
in |
std_logic |
External control of loop termination to e.g. stop expect procedure prematurely |
constant |
max_receptions |
in |
natural |
The maximum number of bytes received before the expected data must be received. Exceeding this limit results in an alert with severity ‘alert_level’. Setting this value to 0 will be interpreted as no limit. Default value is 1 |
constant |
timeout |
in |
time |
The maximum time to pass before the expected data must be received. Exceeding this limit results in an alert with severity ‘alert_level’. Setting this value to 0 will be interpreted as no timeout. Default value is the BFM config timeout. |
constant |
alert_level |
in |
Sets the severity for the alert. Default value is ERROR. |
|
constant |
config |
in |
Configuration of BFM behavior and restrictions. Default value is C_UART_BFM_CONFIG_DEFAULT. |
|
constant |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_BFM_SCOPE (“UART BFM”). |
constant |
msg_id_panel |
in |
t_msg_id_panel |
Controls verbosity within a specified scope. Default value is shared_msg_id_panel. |
-- Examples:
uart_expect(x"3B", "Expect data on UART RX", rx, terminate_signal, 1, 0 ns);
uart_expect(x"3B", "Expect data on UART RX", rx, terminate_signal, 1, 0 ns, ERROR, C_UART_BFM_CONFIG_DEFAULT, C_SCOPE, shared_msg_id_panel);
-- Suggested usage (requires local overload, see 'Local BFM overloads' section):
uart_expect(C_CR_BYTE, "Expecting carriage return");
uart_expect(C_CR_BYTE, "Expecting carriage return", C_TIMEOUT, C_MAX_RECEPTIONS);
Local BFM overloads
A good approach for better readability and maintainability is to make simple, local overloads for the BFM procedures in the TB process. This allows calling the BFM procedures with the key parameters only, e.g.
uart_transmit(C_ASCII_A, "Transmitting ASCII A");
rather than
uart_transmit(C_ASCII_A, "Transmitting ASCII A", tx, C_UART_CONFIG_LOCAL, C_SCOPE, shared_msg_id_panel);
By defining the local overload as e.g.
procedure uart_transmit(
constant data_value : in std_logic_vector;
constant msg : in string) is
begin
uart_transmit(data_value, -- Keep as is
msg, -- Keep as is
tx, -- Signal must be visible in local process scope
C_UART_CONFIG_LOCAL, -- Use locally defined configuration or C_UART_CONFIG_DEFAULT
C_SCOPE, -- Use the default
shared_msg_id_panel); -- Use global, shared msg_id_panel
end procedure;
Using a local overload like this also allows the following – if wanted:
Set up defaults for constants. May be different for two overloads of the same BFM
Apply dedicated message ID panel to allow dedicated verbosity control
Local BFM configuration
The UART BFM requires that a local configuration is declared in the testbench and used in the BFM procedure calls. The default BFM configuration is defined with a clock period of -1 ns so that the BFM can detect and alert the user that the configuration has not been set.
Defining a local UART BFM configuration::
constant C_UART_CONFIG_LOCAL : t_uart_bfm_config := (
bit_time => C_UART_BIT_TIME,
num_data_bits => 8,
idle_state => '1',
num_stop_bits => STOP_BITS_ONE,
parity => PARITY_ODD,
timeout => 0 ns,
timeout_severity => error,
num_bytes_to_log_before_expected_data => 10,
match_strictness => MATCH_EXACT,
id_for_bfm => ID_BFM,
id_for_bfm_wait => ID_BFM_WAIT,
id_for_bfm_poll => ID_BFM_POLL,
id_for_bfm_poll_summary => ID_BFM_POLL_SUMMARY,
error_injection => C_BFM_ERROR_INJECTION_INACTIVE
);
Compilation
This BFM package may only be compiled with VHDL-2008 or newer. It is dependent on the Utility Library, which is only compatible with VHDL-2008 or newer.
After UVVM-Util has been compiled, the BFM package can be compiled into any desired library.
See Essential Mechanisms - Compile Scripts for information about compile scripts.
Simulator compatibility and setup
See Prerequisites for a list of supported simulators.
For required simulator setup see UVVM-Util Simulator compatibility and setup.
Additional Documentation
For additional documentation on the UART protocol, please see the UART specification.
Important
This is a simplified Bus Functional Model (BFM) for UART TX and RX.
The given BFM complies with the basic UART protocol and thus allows a normal access towards a UART interface.
This BFM is not a UART protocol checker.
For a more advanced BFM please contact UVVM support at info@uvvm.org
VVC
VVC functionality is implemented in uart_vvc.vhd
For general information see VVC Framework - Essential Mechanisms.
Entity
Generics
Name |
Type |
Default |
Description |
---|---|---|---|
GC_DATA_WIDTH |
natural |
8 |
Bits in the UART byte. Note that this will initialize num_data_bits in the BFM configuration and override the setting in GC_UART_CONFIG. |
GC_INSTANCE_IDX |
natural |
1 |
Instance number to assign the VVC |
GC_UART_CONFIG |
C_UART_BFM_CONFIG_DEFAULT |
Configuration for the UART BFM |
|
GC_CMD_QUEUE_COUNT_MAX |
natural |
C_CMD_QUEUE_COUNT_MAX |
Absolute maximum number of commands in the VVC command queue |
GC_CMD_QUEUE_COUNT_THRESHOLD |
natural |
C_CMD_QUEUE_COUNT_THRESHOLD |
An alert will be generated when reaching this threshold to indicate that the command queue is almost full. The queue will still accept new commands until it reaches GC_CMD_QUEUE_COUNT_MAX. |
GC_CMD_QUEUE_COUNT_THRESHOLD_SEVERITY |
C_CMD_QUEUE_COUNT_THRESHOLD_SEVERITY |
Alert severity which will be used when command queue reaches GC_CMD_QUEUE_COUNT_THRESHOLD |
|
GC_RESULT_QUEUE_COUNT_MAX |
natural |
C_RESULT_QUEUE_COUNT_MAX |
Maximum number of unfetched results before result_queue is full |
GC_RESULT_QUEUE_COUNT_THRESHOLD |
natural |
C_RESULT_QUEUE_COUNT_THRESHOLD |
An alert will be issued if result queue exceeds this count. Used for early warning if result queue is almost full. Will be ignored if set to 0. |
GC_RESULT_QUEUE_COUNT_THRESHOLD_SEVERITY |
C_RESULT_QUEUE _COUNT_THRESHOLD_SEVERITY |
Severity of alert to be initiated if exceeding GC_RESULT_QUEUE_COUNT_THRESHOLD |
Signals
Object |
Name |
Dir. |
Type |
Description |
---|---|---|---|---|
signal |
uart_vvc_rx |
in |
std_logic |
UART VVC RX signal |
signal |
uart_vvc_tx |
inout |
std_logic |
UART VVC TX signal |
Configuration Record
vvc_config accessible via shared_uart_vvc_config
Record element |
Type |
Default |
Description |
---|---|---|---|
inter_bfm_delay |
C_UART_INTER_BFM_DELAY_DEFAULT |
Delay between any requested BFM accesses towards the DUT. TIME_START2START: Time from a BFM start to the next BFM start (a TB_WARNING will be issued if access takes longer than TIME_START2START). TIME_FINISH2START: Time from a BFM end to the next BFM start. Any insert_delay() command will add to the above minimum delays, giving for instance the ability to skew the BFM starting time. |
|
cmd_queue_count_max |
natural |
C_CMD_QUEUE_COUNT_MAX |
Maximum pending number in command queue before queue is full. Adding additional commands will result in an ERROR. |
cmd_queue_count_threshold |
natural |
C_CMD_QUEUE_COUNT_THRESHOLD |
An alert will be issued if command queue exceeds this count. Used for early warning if command queue is almost full. Will be ignored if set to 0. |
cmd_queue_count_threshold_severity |
C_CMD_QUEUE_COUNT_THRESHOLD_SEERITY |
Severity of alert to be initiated if exceeding cmd_queue_count_threshold |
|
result_queue_count_max |
natural |
C_RESULT_QUEUE_COUNT_MAX |
Maximum number of unfetched results before result_queue is full |
result_queue_count_threshold |
natural |
C_RESULT_QUEUE_COUNT_THRESHOLD |
An alert will be issued if result queue exceeds this count. Used for early warning if result queue is almost full. Will be ignored if set to 0. |
result_queue_count_threshold_severity |
C_RESULT_QUEUE_COUNT_THRESHOLD_SEVERITY |
Severity of alert to be initiated if exceeding result_queue_count_threshold |
|
bfm_config |
C_UART_BFM_CONFIG_DEFAULT |
Configuration for the UART BFM |
|
msg_id_panel |
t_msg_id_panel |
C_VVC_MSG_ID_PANEL_DEFAULT |
VVC dedicated message ID panel. See Scope of Verbosity Control for how to use verbosity control. |
error_injection |
t_vvc_error_injection |
C_VVC_ERROR_INJECTION_INACTIVE |
Record to set up the error injection policy in the BFM procedure calls |
bit_rate_checker |
t_bit_rate_checker |
C_BIT_RATE_CHECKER_DEFAULT |
Configure the UART property checker behavior |
unwanted_activity_severity |
C_UNWANTED_ACTIVITY_SEVERITY |
Severity of alert to be issued if unwanted activity on the DUT outputs is detected. It is enabled with ERROR severity by default. |
Note
cmd/result queue parameters in the configuration record are unused and will be removed in v3.0, use instead the entity generic constants.
The configuration record can be accessed from the Central Testbench Sequencer through the shared variable array, e.g.
shared_uart_vvc_config(RX, C_VVC_IDX).inter_bfm_delay.delay_in_time := 10 ms;
shared_uart_vvc_config(TX, C_VVC_IDX).bfm_config.num_data_bits := 8;
t_vvc_error_injection
Default value for the record is C_VVC_ERROR_INJECTION_INACTIVE.
Record element |
Type |
Default |
Description |
---|---|---|---|
parity_bit_error_prob |
real |
-1.0 |
The probability that the VVC will request a parity_bit_error when calling a BFM transmission procedure. (See t_uart_bfm_config) |
stop_bit_error_prob |
real |
-1.0 |
The probability that the VVC will request a stop_bit_error when calling a BFM transmission procedure. (See t_uart_bfm_config) |
Note
A value of 1.0 means every transmission should have this error injection, whereas 0.0 means error injection is turned off. Anything in between means randomization with the given probability.
The error_injection config in the VVC config will override any error injection specified in the BFM config, unless set to -1.0 (default) in which case the BFM config error injection setting will be used.
For more information on error injection, please see Protocol Aware Error Injection.
t_bit_rate_checker
Default value for the record is C_BIT_RATE_CHECKER_DEFAULT.
Record element |
Type |
Default |
Description |
---|---|---|---|
enable |
boolean |
false |
Enables or disables the complete bit rate checker |
min_period |
time |
0.0 |
The minimum allowed bit period for any bit (any bit level change to the next) |
alert_level |
ERROR |
Alert generated if min_period is violated |
For more information on property checking, please see Controlling Property Checkers.
Status Record
vvc_status accessible via shared_uart_vvc_status
The current status of the VVC can be retrieved during simulation. This is achieved by reading from the shared variable from the test sequencer. The record contents can be seen below:
Record element |
Type |
Description |
---|---|---|
current_cmd_idx |
natural |
Command index currently running |
previous_cmd_idx |
natural |
Previous command index to run |
pending_cmd_idx |
natural |
Pending number of commands in the command queue |
Methods
All VVC procedures are defined in vvc_methods_pkg.vhd (dedicated to this VVC).
See Common VVC Methods for procedures which are common to all VVCs.
It is also possible to send a multicast to all instances of a VVC with ALL_INSTANCES as parameter for vvc_instance_idx.
All parameters in brackets are optional.
uart_transmit()
uart_transmit(VVCT, vvc_instance_idx, channel, data, msg, [scope])
uart_transmit(VVCT, vvc_instance_idx, channel, num_words, randomisation, msg, [scope])
Object |
Name |
Dir. |
Type |
Description |
---|---|---|---|---|
signal |
VVCT |
inout |
t_vvc_target_record |
VVC target type compiled into each VVC in order to differentiate between VVCs |
constant |
vvc_instance_idx |
in |
integer |
Instance number of the VVC |
constant |
channel |
in |
t_channel |
The VVC channel of the VVC instance |
constant |
data |
in |
std_logic_vector |
The data value to be transmitted |
constant |
num_words |
in |
natural |
Number of times the procedure is called to send new random data words |
constant |
randomisation |
in |
t_randomisation |
Randomization profile |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
constant |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_VVC_CMD_SCOPE_DEFAULT. |
-- Examples:
uart_transmit(UART_VVCT, 0, TX, x"AF", "Sending data to DUT UART instance 0", C_SCOPE);
uart_transmit(UART_VVCT, 0, TX, 5, RANDOM, "Sending 5 random bytes to DUT UART instance 0");
uart_receive()
Adds a receive command to the UART RX VVC executor queue, which will run as soon as all preceding commands have completed. When the command is scheduled to run, the executor calls the BFM uart_receive() procedure.
The received data from DUT will not be returned in this procedure call since it is non-blocking for the sequencer/caller, but the received data will be stored in the VVC for a potential future fetch (see example with fetch_result below). This procedure can only be called using the UART RX channel, i.e. setting ‘channel’ to ‘RX’. If the data_routing is set to TO_SB, the received data will be sent to the UART VVC dedicated scoreboard where it will be checked against the expected value (provided by the testbench).
uart_receive(VVCT, vvc_instance_idx, channel, [data_routing,] msg, [alert_level, [scope]])
Object |
Name |
Dir. |
Type |
Description |
---|---|---|---|---|
signal |
VVCT |
inout |
t_vvc_target_record |
VVC target type compiled into each VVC in order to differentiate between VVCs |
constant |
vvc_instance_idx |
in |
integer |
Instance number of the VVC |
constant |
channel |
in |
t_channel |
The VVC channel of the VVC instance |
constant |
data_routing |
in |
Selects the destination of the read data |
|
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
constant |
alert_level |
in |
Unused. DEPRECATED |
|
constant |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_VVC_CMD_SCOPE_DEFAULT. |
-- Examples:
uart_receive(UART_VVCT, 0, RX, "Receiving from DUT UART instance 0");
uart_receive(UART_VVCT, 0, RX, TO_SB, "Receiving data from DUT UART instance 0 and passing on to Scoreboard", ERROR, C_SCOPE);
-- Example with fetch_result() call: Result is placed in v_result
variable v_cmd_idx : natural; -- Command index for the last receive
variable v_result : work.vvc_cmd_pkg.t_vvc_result; -- Result from receive.
...
uart_receive(UART_VVCT, 0, RX, "Receiving from DUT UART instance 0");
v_cmd_idx := get_last_received_cmd_idx(UART_VVCT, 0, RX);
await_completion(UART_VVCT, 0, RX, v_cmd_idx, 1 us, "Wait for receive to finish");
fetch_result(UART_VVCT, 0, RX, v_cmd_idx, v_result, "Fetching result from receive operation");
Hint
t_vvc_result is defined in the corresponding vvc_cmd_pkg.vhd for the VIP.
uart_expect()
Adds an expect command to the UART RX VVC executor queue, which will run as soon as all preceding commands have completed. When the command is scheduled to run, the executor calls BFM uart_expect() procedure. The uart_expect() procedure will perform a receive operation, then check if the received data is equal to the expected data in the data parameter. If the received data is not equal to the expected data parameter, an alert with severity ‘alert_level’ will be issued. The received data will not be stored in this procedure. This procedure can only be called using the UART RX channel, i.e. setting ‘channel’ to ‘RX’.
uart_expect(VVCT, vvc_instance_idx, channel, data, msg, [max_receptions, [timeout, [alert_level, [scope]]]])
Object |
Name |
Dir. |
Type |
Description |
---|---|---|---|---|
signal |
VVCT |
inout |
t_vvc_target_record |
VVC target type compiled into each VVC in order to differentiate between VVCs |
constant |
vvc_instance_idx |
in |
integer |
Instance number of the VVC |
constant |
channel |
in |
t_channel |
The VVC channel of the VVC instance |
constant |
data |
in |
std_logic_vector |
The expected data value to be received |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
constant |
max_receptions |
in |
natural |
The maximum number of bytes received before the expected data must be received. Exceeding this limit results in an alert with severity ‘alert_level’. Setting this value to 0 will be interpreted as no limit. Default value is 1 |
constant |
timeout |
in |
time |
The maximum time to pass before the expected data must be received. Exceeding this limit results in an alert with severity ‘alert_level’. Setting this value to 0 will be interpreted as no timeout. Default value is the BFM config timeout. |
constant |
alert_level |
in |
Sets the severity for the alert. Default value is ERROR. |
|
constant |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_VVC_CMD_SCOPE_DEFAULT. |
-- Examples:
uart_expect(UART_VVCT, 0, RX, x"0D", "Expecting carriage return from DUT UART instance 0");
uart_expect(UART_VVCT, 0, RX, C_CR_BYTE, "Expecting carriage return from DUT UART instance 0", 5, 10 ms, ERROR, C_SCOPE);
Activity Watchdog
The VVCs support a centralized VVC activity register which the activity watchdog uses to monitor the VVC activities. The VVCs will register their presence to the VVC activity register at start-up, and report when ACTIVE and INACTIVE, using dedicated VVC activity register methods, and trigger the global_trigger_vvc_activity_register signal during simulations. The activity watchdog is continuously monitoring the VVC activity register for VVC inactivity and raises an alert if no VVC activity is registered within the specified timeout period.
Include activity_watchdog(num_exp_vvc, timeout, [alert_level, [msg]])
in the testbench to start using the activity watchdog.
Note that setting the exact number of expected VVCs in the VVC activity register can be omitted by setting num_exp_vvc = 0.
More information can be found in Essential Mechanisms - Activity Watchdog.
Transaction Info
This VVC supports transaction info, a UVVM concept for distributing transaction information in a controlled manner within the complete testbench environment. The transaction info may be used in many different ways, but the main purpose is to share information directly from the VVC to a DUT model.
Info field |
Type |
Default |
Description |
---|---|---|---|
operation |
t_operation |
NO_OPERATION |
Current VVC operation, e.g. INSERT_DELAY, POLL_UNTIL, READ, WRITE |
data |
std_logic_vector(7 downto 0) |
0x0 |
Data for UART receive or transmit transaction |
vvc_meta |
t_vvc_meta |
C_VVC_META_DEFAULT |
VVC meta data of the executing VVC command |
-> msg |
string |
“” |
Message of executing VVC command |
-> cmd_idx |
integer |
-1 |
Command index of executing VVC command |
transaction_status |
t_transaction_status |
INACTIVE |
Set to INACTIVE, IN_PROGRESS, FAILED or SUCCEEDED during a transaction |
error_info |
t_error_info |
C_ERROR_INFO_DEFAULT |
Error injection status |
-> parity_bit_error |
boolean |
false |
Status of the parity bit error injection |
-> stop_bit_error |
boolean |
false |
Status of the stop bit error injection |
More information can be found in Essential Mechanisms - Distribution of Transaction Info.
Scoreboard
This VVC has built in Scoreboard functionality where data can be routed by setting the TO_SB parameter in supported method calls, i.e. uart_receive(). Note that the data is only stored in the scoreboard and not accessible with the fetch_result() method when the TO_SB parameter is applied. The UART scoreboard is accessible from the testbench as a shared variable UART_VVC_SB, located in the vvc_methods_pkg.vhd, e.g.
UART_VVC_SB.add_expected(C_UART_VVC_IDX, v_expected, "Adding expected");
See the Bitvis VIP Scoreboard for a complete list of available commands and additional information. All of the listed Generic Scoreboard commands are available for the UART VVC scoreboard using the UART_VVC_SB.
Unwanted Activity Detection
This VVC supports detection of unwanted activity from the DUT. This mechanism will give an alert if the DUT generates any unexpected bus activity. It assures that no data is output from the DUT when it is not expected, i.e. read/receive/check/expect VVC methods are not called. Once the VVC is inactive, it starts to monitor continuously on the DUT outputs. When unwanted activity is detected, the VVC issues an alert.
The unwanted activity detection can be configured from the central testbench sequencer, where the severity of alert can be changed to a different value. To disable this feature in the testbench, e.g.
shared_uart_vvc_config(RX, C_VVC_INDEX).unwanted_activity_severity := NO_ALERT;
For UART VVC, the unwanted activity detection is enabled by default with severity ERROR.
Note
This feature is only implemented on uart_rx_vvc.
More information can be found in Essential Mechanisms - Unwanted Activity Detection.
Compilation
The UART VVC must be compiled with VHDL-2008 or newer. It is dependent on the following libraries:
UVVM Utility Library (UVVM-Util)
UVVM VVC Framework
Bitvis VIP Scoreboard
UART BFM
Before compiling the UART VVC, assure that uvvm_util, uvvm_vvc_framework and bitvis_vip_scoreboard have been compiled.
See Essential Mechanisms - Compile Scripts for information about compile scripts.
Compile to library |
File |
Comment |
---|---|---|
bitvis_vip_uart |
uart_bfm_pkg.vhd |
UART BFM |
bitvis_vip_uart |
transaction_pkg.vhd |
UART transaction package with DTT types, constants, etc. |
bitvis_vip_uart |
vvc_cmd_pkg.vhd |
UART VVC command types and operations |
bitvis_vip_uart |
monitor_cmd_pkg.vhd |
UART Monitor package. Only include this file if you intend to use Monitor. |
bitvis_vip_uart |
../uvvm_vvc_framework/src_target_dependent/td_target_support_pkg.vhd |
UVVM VVC target support package, compiled into this VVC library |
bitvis_vip_uart |
../uvvm_vvc_framework/src_target_dependent/td_vvc_framework_common_methods_pkg.vhd |
Common UVVM framework methods compiled into the this VVC library |
bitvis_vip_uart |
vvc_sb_pkg.vhd |
UART VVC scoreboard |
bitvis_vip_uart |
vvc_methods_pkg.vhd |
UART VVC methods |
bitvis_vip_uart |
../uvvm_vvc_framework/src_target_dependent/td_queue_pkg.vhd |
UVVM queue package for this VVC |
bitvis_vip_uart |
../uvvm_vvc_framework/src_target_dependent/td_vvc_entity_support_pkg.vhd |
UVVM VVC entity support compiled into this VVC library |
bitvis_vip_uart |
uart_rx_vvc.vhd |
UART RX VVC |
bitvis_vip_uart |
uart_tx_vvc.vhd |
UART TX VVC |
bitvis_vip_uart |
uart_vvc.vhd |
UART VVC wrapper for the TX and RX VVCs |
bitvis_vip_uart |
uart_monitor.vhd |
UART Monitor. Only include this file if you intend to use Monitor. |
bitvis_vip_uart |
vvc_context.vhd |
UART VVC context file |
Simulator compatibility and setup
See Prerequisites for a list of supported simulators.
For required simulator setup see UVVM-Util Simulator compatibility and setup.
Additional Documentation
For additional documentation on the UART protocol, please see the UART specification.
Important
This is a simplified Verification IP (VIP) for UART TX and RX.
The given VIP complies with the basic UART protocol and thus allows a normal access towards a UART interface.
This VIP is not a UART protocol checker.
For a more advanced VIP please contact UVVM support at info@uvvm.org
Monitor
Entity
Generics
Name |
Type |
Default |
Description |
---|---|---|---|
GC_INSTANCE_IDX |
natural |
1 |
Instance number to assign the VVC |
GC_MONITOR_CONFIG |
C_UART_MONITOR_CONFIG_DEFAULT |
Configuration of the UART monitor, both channels get initiated with this configuration |
Signals
Object |
Name |
Dir. |
Type |
Description |
---|---|---|---|---|
signal |
uart_dut_rx |
in |
std_logic |
Input of DUTs UART RX signal. |
signal |
uart_dut_tx |
in |
std_logic |
Input of DUTs UART TX signal. |
Configuration Record
t_uart_monitor_config accessible via shared_uart_monitor_config
Default value for the record is C_UART_MONITOR_CONFIG_DEFAULT.
Record element |
Type |
Default |
Description |
---|---|---|---|
scope_name |
string |
“set scope name” |
Describes the scope from which the log/alert originates. |
msg_id_panel |
t_msg_id_panel |
C_UART_MONITOR_MSG_ID_PANEL_DEFAULT |
Monitor dedicated message ID panel. See Scope of Verbosity Control for how to use verbosity control. |
interface_config |
t_uart_interface_config |
C_UART_MONITOR_INTERFACE_CONFIG_DEFAULT |
The configuration for the interface |
transaction_display_time |
time |
0 ns |
After this amount of time operation is set to NO_OPERATION and transaction_status is set to INACTIVE if a new transaction is not received. If set to 0 ns, operation and transaction_status will be unchanged until the next transfer is started. |
The configuration record can be accessed from the Central Testbench Sequencer through the shared variable array, e.g.
shared_uart_monitor_config(TX, C_MONITOR_IDX).msg_id_panel := new_msg_id_panel;
shared_uart_monitor_config(TX, C_MONITOR_IDX).interface_config.num_data_bits := 8;
t_uart_interface_config
Default value for the record is C_UART_MONITOR_INTERFACE_CONFIG_DEFAULT.
Record element |
Type |
Default |
Description |
---|---|---|---|
bit_time |
time |
0 ns |
The time it takes to transfer one bit |
num_data_bits |
natural range 7 to 8 |
8 |
Number of data bits to send per transmission |
parity |
PARITY_ODD |
Transmission parity bit |
|
num_stop_bits |
STOP_BITS_ONE |
Number of stop-bits to use per transmission |
Transaction info
An example of use of the global_uart_monitor_transaction and shared_uart_monitor_transaction_info is seen below. A process extracts the transaction info from the shared variable when the global signal is triggered.
p_monitor_tx : process
variable v_transaction : t_uart_transaction;
begin
wait until global_uart_monitor_transaction_trigger(TX, 1) = '1';
if (shared_uart_monitor_transaction_info(TX, 1).bt.transaction_status = SUCCEEDED or
shared_uart_monitor_transaction_info(TX, 1).bt.transaction_status = FAILED) then
v_transaction := shared_uart_monitor_transaction_info(TX, 1).bt;
end if;
-- Processing received transaction
...
end process p_monitor_tx;
For more information on the type, please see VVC Transaction Info.
Message IDs
ID_FRAME_INITIATE: Logs start of UART frame
ID_MONITOR: Logs information about monitored transaction
Compilation
The UART Monitor must be compiled with VHDL-2008 or newer. It is dependent on the following libraries:
UVVM Utility Library (UVVM-Util)
UVVM VVC Framework
Bitvis VIP Scoreboard
UART BFM
Before compiling the UART Monitor, assure that uvvm_util, uvvm_vvc_framework and bitvis_vip_scoreboard have been compiled.
See Essential Mechanisms - Compile Scripts for information about compile scripts.
Compile to library |
File |
Comment |
---|---|---|
bitvis_vip_uart |
uart_bfm_pkg.vhd |
UART BFM |
bitvis_vip_uart |
transaction_pkg.vhd |
UART transaction package with DTT types, constants, etc. |
bitvis_vip_uart |
vvc_cmd_pkg.vhd |
UART VVC command types and operations |
bitvis_vip_uart |
monitor_cmd_pkg.vhd |
UART Monitor package |
bitvis_vip_uart |
../uvvm_vvc_framework/src_target_dependent/td_target_support_pkg.vhd |
UVVM VVC target support package, compiled into this VVC library |
bitvis_vip_uart |
vvc_sb_pkg.vhd |
UART VVC scoreboard |
bitvis_vip_uart |
vvc_methods_pkg.vhd |
UART VVC methods |
bitvis_vip_uart |
uart_monitor.vhd |
UART Monitor |
Simulator compatibility and setup
See Prerequisites for a list of supported simulators.
For required simulator setup see UVVM-Util Simulator compatibility and setup.
Additional Documentation
For additional documentation on the UART protocol, please see the UART specification.
Note
Disclaimer: This IP and any part thereof are provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with this IP.