External VIP APB
Quick Access
BFM
BFM functionality is implemented in apb_bfm_pkg.vhd
Signal Record
t_apb_if
Record element |
Type |
|---|---|
pclk |
std_logic |
paddr |
std_logic_vector |
pprot |
std_logic_vector(2 downto 0) |
psel |
std_logic |
penable |
std_logic |
pwrite |
std_logic |
pwdata |
std_logic_vector |
pstrb |
std_logic_vector |
prdata |
std_logic_vector |
pready |
std_logic |
pslverr |
std_logic |
Note
BFM calls can also be made with listing of single signals rather than t_apb_if.
Configuration Record
t_apb_bfm_config
Default value for the record is C_APB_BFM_CONFIG_DEFAULT.
Record element |
Type |
Default |
Description |
|---|---|---|---|
max_wait_cycles |
natural |
1000 |
The maximum number of clock cycles to wait for the DUT ready signal before reporting a timeout alert |
max_wait_cycles_severity |
FAILURE |
The above timeout will have this severity |
|
clock_period |
time |
C_UNDEFINED_TIME |
Period of the clock signal |
clock_period_margin |
time |
0 ns |
Input clock period margin to specified clock_period. Will check ‘T/2’ if input clock is low when BFM is called and ‘T’ if input clock is high. |
clock_margin_severity |
TB_ERROR |
The above margin will have this severity |
|
setup_time |
time |
C_UNDEFINED_TIME |
Generated signals setup time. Suggested value is clock_period/4. An alert is reported if setup_time exceeds clock_period/2. |
hold_time |
time |
C_UNDEFINED_TIME |
Generated signals hold time. Suggested value is clock_period/4. An alert is reported if hold_time exceeds clock_period/2. |
bfm_sync |
t_bfm_sync |
SYNC_ON_CLOCK_ONLY |
When set to SYNC_ON_CLOCK_ONLY the BFM will always wait for the first falling edge of the clock. Then the interface output signals will be set up immediately. After that, the BFM will wait for the rising edge of the clock, sample or set relevant interface signals (if any), and estimate the clock period. The BFM will deactivate potential interface output signals and exit ¼ clock period after a succeeding rising edge. When set to SYNC_WITH_SETUP_AND_HOLD the BFM will always wait for the configured setup time before the first rising edge of the clock. Then the interface output signals will be set up immediately. After that, the BFM will wait for the rising edge of the clock, and sample or set relevant interface signals (if any). Note that the clock period needs to be configured in this mode. The BFM will deactivate potential interface output signals and exit after the configured hold time after a succeeding rising edge. |
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 |
ID_BFM |
Message ID used for logging general messages in the BFM |
|
id_for_bfm_wait |
ID_BFM_WAIT |
Message ID used for logging waits in the BFM |
Methods
The record t_apb_if can be replaced with the signals listed in said record.
All signals are active high.
All parameters in brackets are optional.
apb_write()
Writes the given data to the given address on the DUT, using the APB protocol:
1. During the setup phase:
a. paddr is set to addr_value
b. pwdata is set to data_value
c. pprot is set to protection
d. pstrb is set to byte_enable
e. psel is set to '1'
f. pwrite is set to '1'
g. penable is set to '0'
2. During the access phase:
a. penable is set to '1'
b. the BFM waits for pready to be '1'
3. Before exiting the procedure:
e. psel is set to '0'
g. penable is set to '0'
The procedure reports an alert if pready signal is not set to ‘1’ within ‘config.max_wait_cycles’ after penable is set to ‘1’ (alert_level: config.max_wait_cycles_severity).
apb_write(addr_value, data_value, byte_enable, protection, msg, apb_if, [scope, [msg_id_panel, [config]]])
Object |
Name |
Dir. |
Type |
Description |
|---|---|---|---|---|
constant |
addr_value |
in |
unsigned |
The memory address of the peripheral being accessed |
constant |
data_value |
in |
std_logic_vector |
The data value to be written to the memory address |
constant |
byte_enable |
in |
std_logic_vector |
Each bit indicates which byte in data_value is valid |
constant |
protection |
in |
std_logic_vector(2 downto 0) |
Indicates normal, privileged or secure protection levels and whether it’s a data or instruction access |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
signal |
apb_if |
inout |
APB signal interface record |
|
constant |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_BFM_SCOPE (“APB BFM”). |
constant |
msg_id_panel |
in |
t_msg_id_panel |
Controls verbosity within a specified scope. Default value is shared_msg_id_panel. For more information see Scope of Verbosity Control. |
constant |
config |
in |
Configuration of BFM behavior and restrictions. Default value is C_APB_BFM_CONFIG_DEFAULT. |
-- Examples:
apb_write(x"1000", x"AA55", "1111", "000", "Write data to Peripheral 1", apb_if);
apb_write(x"1000", x"AA55", "1111", "000", "Write data to Peripheral 1", apb_if, C_SCOPE, shared_msg_id_panel, C_APB_BFM_CONFIG_DEFAULT);
-- Suggested usage (requires local overload, see 'Local BFM overloads' section):
apb_write(C_ADDR_REG_1, x"AA55", "Write data to Peripheral 1");
apb_read()
Reads data from the DUT at the given address, using the APB protocol:
1. During the setup phase:
a. paddr is set to addr_value
b. pprot is set to protection
c. psel is set to '1'
d. pwrite is set to '0'
e. penable is set to '0'
2. During the access phase:
a. penable is set to '1'
b. the BFM waits for pready to be '1'
3. Before exiting the procedure:
e. psel is set to '0'
g. penable is set to '0'
The procedure reports an alert if pready signal is not set to ‘1’ within ‘config.max_wait_cycles’ after penable is set to ‘1’ (alert_level: config.max_wait_cycles_severity).
apb_read(addr_value, data_value, protection, msg, apb_if, [scope, [msg_id_panel, [config]]])
Object |
Name |
Dir. |
Type |
Description |
|---|---|---|---|---|
constant |
addr_value |
in |
unsigned |
The memory address of the peripheral being accessed |
variable |
data_value |
out |
std_logic_vector |
The data value read from the addressed register |
constant |
protection |
in |
std_logic_vector(2 downto 0) |
Indicates normal, privileged or secure protection levels and whether it’s a data or instruction access |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
signal |
apb_if |
inout |
APB signal interface record |
|
constant |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_BFM_SCOPE (“APB BFM”). |
constant |
msg_id_panel |
in |
t_msg_id_panel |
Controls verbosity within a specified scope. Default value is shared_msg_id_panel. For more information see Scope of Verbosity Control. |
constant |
config |
in |
Configuration of BFM behavior and restrictions. Default value is C_APB_BFM_CONFIG_DEFAULT. |
-- Examples:
apb_read(x"1000", v_data_out, "000", "Read from Peripheral 1", apb_if);
apb_read(x"1000", v_data_out, "000", "Read from Peripheral 1", apb_if, C_SCOPE, shared_msg_id_panel, C_APB_BFM_CONFIG_DEFAULT);
-- Suggested usage (requires local overload, see 'Local BFM overloads' section):
apb_read(C_ADDR_REG_1, v_data_out, "Read from Peripheral 1");
apb_check()
Reads data from the DUT at the given address, using the APB protocol described under apb_read(). After reading data from the APB bus, the read data is compared with the expected data.
If the check was successful, and the read data matches the expected data, a log message is written with ID ‘config.id_for_bfm’.
If the read data did not match the expected data, an alert with severity ‘alert_level’ will be reported.
The procedure will also report alerts for the same conditions as the apb_read() procedure.
apb_check(addr_value, data_exp, protection, msg, apb_if, [alert_level, [scope, [msg_id_panel, [config]]]])
Object |
Name |
Dir. |
Type |
Description |
|---|---|---|---|---|
constant |
addr_value |
in |
unsigned |
The memory address of the peripheral being accessed |
constant |
data_exp |
in |
std_logic_vector |
The data value to be expect when reading the memory address |
constant |
protection |
in |
std_logic_vector(2 downto 0) |
Indicates normal, privileged or secure protection levels and whether it’s a data or instruction access |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
signal |
apb_if |
inout |
APB signal interface record |
|
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_BFM_SCOPE (“APB BFM”). |
constant |
msg_id_panel |
in |
t_msg_id_panel |
Controls verbosity within a specified scope. Default value is shared_msg_id_panel. For more information see Scope of Verbosity Control. |
constant |
config |
in |
Configuration of BFM behavior and restrictions. Default value is C_APB_BFM_CONFIG_DEFAULT. |
-- Examples:
apb_check(x"1155", x"123B", "000", "Check data from Peripheral 1", apb_if);
apb_check(x"1155", x"123B", "000", "Check data from Peripheral 1", apb_if, ERROR, C_SCOPE, shared_msg_id_panel, C_APB_BFM_CONFIG_DEFAULT);
-- Suggested usage (requires local overload, see 'Local BFM overloads' section):
apb_check(C_ADDR_REG_1, x"123B", "Check data from Peripheral 1");
apb_poll_until()
Reads data from the DUT at the given address, using the APB protocol described under apb_read(). After reading data from the DUT, the read data is compared with the expected data. If the read data does not match the expected data, the process is repeated until one or more of the following occurs:
The read data matches the expected data
The number of read retries is equal to ‘max_polls’
The time between start of apb_poll_until procedure and now is greater than ‘timeout’
The terminate_loop signal is set to ‘1’
If the procedure exits because of 2. or 3. an alert with severity ‘alert_level’ is issued. If either ‘max_polls’ or ‘timeout’ is set to 0 (ns), this constraint will be ignored and interpreted as no limit.
If the check was successful, and the read data matches the expected data, a log message is written with ID ‘config.id_for_bfm’.
If the read data did not match the expected data, an alert with severity ‘alert_level’ will be reported.
If the procedure is terminated using ‘terminate_loop’ a log message with ID ID_TERMINATE_CMD will be issued.
The procedure will also report alerts for the same conditions as the apb_read() procedure.
apb_poll_until(addr_value, data_exp, protection, max_polls, timeout, msg, apb_if, terminate_loop, [alert_level, [scope, [msg_id_panel, [config]]]])
Object |
Name |
Dir. |
Type |
Description |
|---|---|---|---|---|
constant |
addr_value |
in |
unsigned |
The memory address of the peripheral being accessed |
constant |
data_exp |
in |
std_logic_vector |
The data value to be expect when reading the memory address |
constant |
protection |
in |
std_logic_vector(2 downto 0) |
Indicates normal, privileged or secure protection levels and whether it’s a data or instruction access |
constant |
max_polls |
in |
integer |
The maximum number of polls (reads) before the expected data must be found. Exceeding this limit results in an alert with severity ‘alert_level’. Note that 0 means no limit. |
constant |
timeout |
in |
time |
The maximum time to pass before the expected data must be found. Exceeding this limit results in an alert with severity ‘alert_level’. Note that 0 ns means no timeout. |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
signal |
apb_if |
inout |
APB signal interface record |
|
signal |
terminate_loop |
in |
std_logic |
External control of loop termination to e.g. stop polling prematurely |
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_BFM_SCOPE (“APB BFM”). |
constant |
msg_id_panel |
in |
t_msg_id_panel |
Controls verbosity within a specified scope. Default value is shared_msg_id_panel. For more information see Scope of Verbosity Control. |
constant |
config |
in |
Configuration of BFM behavior and restrictions. Default value is C_APB_BFM_CONFIG_DEFAULT. |
-- Examples:
apb_poll_until(x"1155", x"0A5D", "000", 10, 100 ns, "Poll for data from Peripheral 1", apb_if, terminate_loop);
apb_poll_until(x"1155", x"0A5D", "000", 10, 100 ns, "Poll for data from Peripheral 1", apb_if, terminate_loop, ERROR, C_SCOPE, shared_msg_id_panel, C_APB_BFM_CONFIG_DEFAULT);
-- Suggested usage (requires local overload, see 'Local BFM overloads' section):
apb_poll_until(C_ADDR_REG_1, x"05AD", "Poll register 1 until expected data is found");
apb_poll_until(C_ADDR_REG_1, x"05AD", C_MAX_POLLS, C_TIMEOUT, "Poll register 1 until expected data is found");
init_apb_if_signals()
Initializes the APB interface. All the BFM outputs are set to ‘0’, and BFM inputs are set to ‘Z’.
t_apb_if := init_apb_if_signals(addr_width, data_width)
Object |
Name |
Dir. |
Type |
Description |
|---|---|---|---|---|
constant |
addr_width |
in |
natural |
Width of the address signal |
constant |
data_width |
in |
natural |
Width of the data signals |
-- Examples:
apb_if <= init_apb_if_signals(apb_if.paddr'length, apb_if.pwdata'length);
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.
apb_write(C_ADDR_REG_1, x"AA55", "Write data to Peripheral 1");
rather than
apb_write(C_ADDR_REG_1, x"AA55", "1111", "000", "Write data to Peripheral 1", apb_if, C_SCOPE, shared_msg_id_panel, C_APB_BFM_CONFIG_DEFAULT);
By defining the local overload as e.g.
procedure apb_write(
constant addr_value : in unsigned;
constant data_value : in std_logic_vector;
constant msg : in string) is
variable v_byte_enable : std_logic_vector((data_value'length / 8) - 1 downto 0) := (others => '1');
begin
apb_write(addr_value, -- Keep as is
data_value, -- Keep as is
v_byte_enable, -- This could also be an input if needed
C_DEFAULT_PROTECTION, -- This could also be an input if needed
msg, -- Keep as is
apb_if, -- Signal must be visible in local process scope
C_SCOPE, -- Use the default
shared_msg_id_panel, -- Use global, shared msg_id_panel
C_APB_CONFIG_LOCAL); -- Use locally defined configuration or C_APB_CONFIG_DEFAULT
end procedure;
Using a local overload like this also allows the following – if wanted:
Have address value as natural – and convert in the overload
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
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 more information on the APB specification, refer to “AMBA® APB Protocol Specification” (ARM IHI 0024D), available from ARM.
Important
This is a simplified Bus Functional Model (BFM) for APB.
The given BFM complies with the basic APB protocol and thus allows a normal access towards an APB interface.
This BFM is not an APB protocol checker.
For a more advanced BFM please contact UVVM support at info@uvvm.org
VVC
VVC functionality is implemented in apb_vvc.vhd
For general information see VVC Mechanisms and Features.
Entity
Generics
Name |
Type |
Default |
Description |
|---|---|---|---|
GC_ADDR_WIDTH |
integer |
32 |
Width of the APB address bus |
GC_DATA_WIDTH |
integer |
32 |
Width of the APB data bus |
GC_INSTANCE_IDX |
natural |
0 |
Instance number to assign the VVC. Maximum value is defined by C_APB_VVC_MAX_INSTANCE_NUM in adaptations_pkg. |
GC_APB_CONFIG |
C_APB_BFM_CONFIG_DEFAULT |
Configuration for the APB 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 |
Note
Default values for the cmd/result queue generics are defined in adaptations_pkg.
Signals
Object |
Name |
Dir. |
Type |
Description |
|---|---|---|---|---|
signal |
apb_vvc_master_if |
inout |
APB signal interface record |
In this VVC, the interface has been encapsulated in a signal record of type t_apb_if in order to improve readability of the code. Since the APB interface buses can be of arbitrary size, the interface vectors have been left unconstrained. These unconstrained vectors need to be constrained when the interface signals are instantiated. For this interface, it could look like:
signal apb_if : t_apb_if(paddr(C_ADDR_WIDTH - 1 downto 0),
pwdata(C_DATA_WIDTH - 1 downto 0),
pstrobe((C_DATA_WIDTH / 8) - 1 downto 0),
prdata(C_DATA_WIDTH - 1 downto 0));
Configuration Record
vvc_config accessible via shared_apb_vvc_config
Record element |
Type |
Default |
Description |
|---|---|---|---|
inter_bfm_delay |
C_APB_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_APB_BFM_CONFIG_DEFAULT |
Configuration for the APB 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. |
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_apb_vvc_config(C_VVC_IDX).inter_bfm_delay.delay_in_time := 50 ns;
shared_apb_vvc_config(C_VVC_IDX).bfm_config.id_for_bfm := ID_BFM;
Status Record
vvc_status accessible via shared_apb_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.
Note
Some parameters in the VVC procedures are unconstrained for flexibility. However, the maximum sizes of such parameters need to be defined for the VVC framework. For this VVC, the following maximum values can be configured from adaptations_pkg:
C_APB_VVC_CMD_DATA_MAX_LENGTH
Maximum pwdata/prdata length
C_APB_VVC_CMD_ADDR_MAX_LENGTH
Maximum paddr length
C_APB_VVC_CMD_BYTE_ENABLE_MAX_LENGTH
Maximum pstrb length
C_APB_VVC_CMD_STRING_MAX_LENGTH
Maximum msg length
apb_write()
Adds a write command to the APB 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 apb_write() procedure.
apb_write(VVCT, vvc_instance_idx, addr, data, [byte_enable, protection,] 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 |
addr |
in |
unsigned |
The memory address of the peripheral being accessed |
constant |
data |
in |
std_logic_vector |
The data value to be written to the memory address |
constant |
byte_enable |
in |
std_logic_vector |
Each bit indicates which byte in data is valid |
constant |
protection |
in |
std_logic_vector(2 downto 0) |
Indicates normal, privileged or secure protection levels and whether it’s a data or instruction access |
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 defined in adaptations_pkg. |
-- Examples:
apb_write(APB_VVCT, 0, x"1000", x"4000", "Write data to Peripheral 1", C_SCOPE);
apb_write(APB_VVCT, 0, x"1000", x"4000", "1111", "000" "Write data to Peripheral 1", C_SCOPE);
-- It is recommended to use constants to improve the readability of the code, e.g.:
apb_write(APB_VVCT, 0, C_ADDR_REG_1, x"4000", C_BYTE_ENABLE, C_NON_SECURE, "Write data to Peripheral 1");
apb_read()
Adds a read command to the APB 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 apb_read() procedure.
The value read from DUT will not be returned in this procedure call since it is non-blocking for the sequencer/caller, but the read data will be stored in the VVC for a potential future fetch (see example with fetch_result below). If the data_routing is set to TO_SB, the read data will be sent to the APB VVC dedicated scoreboard where it will be checked against the expected value (provided by the testbench).
apb_read(VVCT, vvc_instance_idx, addr, [protection,] [data_routing,] 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 |
addr |
in |
unsigned |
The memory address of the peripheral being accessed |
constant |
protection |
in |
std_logic_vector(2 downto 0) |
Indicates normal, privileged or secure protection levels and whether it’s a data or instruction access |
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 |
scope |
in |
string |
Describes the scope from which the log/alert originates. Default value is C_VVC_CMD_SCOPE_DEFAULT defined in adaptations_pkg. |
-- Examples:
apb_read(APB_VVCT, 0, x"1000", "Read from Peripheral 1", C_SCOPE);
apb_read(APB_VVCT, 0, x"1002", TO_SB, "Read from Peripheral 1 and send to Scoreboard", C_SCOPE);
-- It is recommended to use constants to improve the readability of the code, e.g.:
apb_read(APB_VVCT, 0, C_ADDR_REG_1, "Read from Peripheral 1");
-- Example with fetch_result() call: Result is placed in v_result
variable v_cmd_idx : natural; -- Command index for the last read
variable v_result : work.vvc_cmd_pkg.t_vvc_result; -- Result from read.
...
apb_read(APB_VVCT, 0, C_ADDR_REG_1, "Read from Peripheral 1";
v_cmd_idx := get_last_received_cmd_idx(APB_VVCT, 0);
await_completion(APB_VVCT, 0, v_cmd_idx, 1 us, "Wait for read to finish");
fetch_result(APB_VVCT, 0, v_cmd_idx, v_result, "Fetching result from read operation");
Hint
t_vvc_result is defined in the corresponding vvc_cmd_pkg.vhd for the VIP.
apb_check()
Adds a check command to the APB 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 apb_check() procedure. The apb_check() procedure will perform a read operation, then check if the read data is equal to the expected data in the data parameter. If the read data is not equal to the expected data parameter, an alert with severity ‘alert_level’ will be issued. The read data will not be stored in this procedure.
apb_check(VVCT, vvc_instance_idx, addr, data, [protection,] 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 |
addr |
in |
unsigned |
The memory address of the peripheral being accessed |
constant |
data |
in |
std_logic_vector |
The expected data value to be read from the addressed register |
constant |
protection |
in |
std_logic_vector(2 downto 0) |
Indicates normal, privileged or secure protection levels and whether it’s a data or instruction access |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
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 defined in adaptations_pkg. |
-- Examples:
apb_check(APB_VVCT, 0, x"1155", x"123B", "Check data from Peripheral 1");
apb_check(APB_VVCT, 0, x"1155", x"123B", "000", "Check data from Peripheral 1", TB_ERROR, C_SCOPE):
-- It is recommended to use constants to improve the readability of the code, e.g.:
apb_check(APB_VVCT, 0, C_ADDR_REG_1, x"4000", C_NON_SECURE, "Check data from Peripheral 1");
apb_poll_until()
Adds a poll_until command to the APB 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 apb_poll_until() procedure. The apb_poll_until() procedure will perform a read operation, then check if the read data is equal to the data in the data parameter. If the read data is not equal to the expected data parameter, the process will be repeated until the read data is equal to the expected data, or the procedure is terminated by either a terminate command, a timeout or the poll limit set in max_polls. The read data will not be stored by this procedure.
apb_poll_until(VVCT, vvc_instance_idx, addr, data, [protection,] msg, [max_polls, [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 |
addr |
in |
unsigned |
The memory address of the peripheral being accessed |
constant |
data |
in |
std_logic_vector |
The expected data value to be read from the addressed register |
constant |
protection |
in |
std_logic_vector(2 downto 0) |
Indicates normal, privileged or secure protection levels and whether it’s a data or instruction access |
constant |
msg |
in |
string |
A custom message to be appended in the log/alert |
constant |
max_polls |
in |
integer |
The maximum number of polls (reads) before the expected data must be found. Exceeding this limit results in an alert with severity ‘alert_level’. Note that 0 means no limit. Default value is 100. |
constant |
timeout |
in |
time |
The maximum time to pass before the expected data must be found. Exceeding this limit results in an alert with severity ‘alert_level’. Note that 0 ns means no timeout. Default value is 1 us. |
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 defined in adaptations_pkg. |
-- Examples:
apb_poll_until(APB_VVCT, 0, x"1155", x"0ABD", "Poll for data from Peripheral 1");
apb_poll_until(APB_VVCT, 0, x"1155", x"0ABD", "000", "Poll for data from Peripheral 1", 5, 0 ns, TB_WARNING, C_SCOPE);
-- It is recommended to use constants to improve the readability of the code, e.g.:
apb_poll_until(APB_VVCT, 0, C_ADDR_REG_1, x"0ABD", "Poll for data from Peripheral 1 until expected data is found");
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 |
address |
unsigned(31 downto 0) |
0x0 |
Address of the APB read or write transaction |
data |
std_logic_vector(31 downto 0) |
0x0 |
Data for APB read or write 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 |
INACTIVE |
Set to INACTIVE, IN_PROGRESS, FAILED or SUCCEEDED during a transaction |
Info field |
Type |
Default |
Description |
|---|---|---|---|
operation |
t_operation |
NO_OPERATION |
Current VVC operation, e.g. INSERT_DELAY, POLL_UNTIL, READ, WRITE |
address |
unsigned(31 downto 0) |
0x0 |
Address of the APB read or write transaction |
data |
std_logic_vector(31 downto 0) |
0x0 |
Data for APB read or write transaction |
max_polls |
integer |
1 |
Maximum number of polls allowed in the apb_poll_until() procedure. 0 means no limit. |
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 |
INACTIVE |
Set to INACTIVE, IN_PROGRESS, FAILED or SUCCEEDED during a transaction |
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. apb_read(). 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 APB scoreboard is accessible from the testbench as a shared variable apb_vvc_sb, located in
the vvc_methods_pkg.vhd, e.g.
apb_vvc_sb.add_expected(C_APB_VVC_IDX, pad_apb_sb(v_expected), "Adding expected");
The APB scoreboard is per default a 32 bits wide standard logic vector. When sending expected data to the scoreboard, where the data width is smaller than the default scoreboard width, we recommend zero-padding the data with the pad_apb_sb() function, e.g.
apb_vvc_sb.add_expected(<APB VVC instance number>, pad_apb_sb(<exp data>));
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 APB VVC scoreboard using the apb_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_apb_vvc_config(C_VVC_INDEX).unwanted_activity_severity := NO_ALERT;
Note that the pready signal is not monitored in this VVC. The pready signal is allowed to toggle whenever penable is low, and there is no method to differentiate between the unwanted activity and intended activity. See the APB protocol specification for more information on the pready signal.
For APB VVC, the unwanted activity detection is enabled by default with severity ERROR.
More information can be found in Essential Mechanisms - Unwanted Activity Detection.
Compilation
The APB 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
APB BFM
Before compiling the APB 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 |
|---|---|---|
external_vip_apb |
apb_bfm_pkg.vhd |
APB BFM |
external_vip_apb |
transaction_pkg.vhd |
APB transaction package with DTT types, constants, etc. |
external_vip_apb |
vvc_cmd_pkg.vhd |
APB VVC command types and operations |
external_vip_apb |
../uvvm_vvc_framework/src_target_dependent/td_target_support_pkg.vhd |
UVVM VVC target support package, compiled into this VVC library |
external_vip_apb |
../uvvm_vvc_framework/src_target_dependent/td_vvc_framework_common_methods_pkg.vhd |
Common UVVM framework methods compiled into the this VVC library |
external_vip_apb |
vvc_sb_pkg.vhd |
APB VVC scoreboard |
external_vip_apb |
vvc_methods_pkg.vhd |
APB VVC methods |
external_vip_apb |
../uvvm_vvc_framework/src_target_dependent/td_queue_pkg.vhd |
UVVM queue package for this VVC |
external_vip_apb |
../uvvm_vvc_framework/src_target_dependent/td_vvc_entity_support_pkg.vhd |
UVVM VVC entity support compiled into this VVC library |
external_vip_apb |
apb_vvc.vhd |
APB VVC |
external_vip_apb |
vvc_context.vhd |
APB 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 more information on the APB specification, refer to “AMBA® APB Protocol Specification” (ARM IHI 0024D), available from ARM.
Important
This is a simplified Verification IP (VIP) for APB.
The given VIP complies with the basic APB protocol and thus allows a normal access towards an APB interface.
This VIP is not an APB protocol checker.
For a more advanced VIP please contact UVVM support at info@uvvm.org
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.