For detailed information on PWM design features, please see the PWM HWIP technical specification.
PWM testbench has been constructed based on the CIP testbench architecture.
Top level testbench is located at hw/ip/pwm/dv/tb/tb.sv
. It instantiates the PWM DUT module hw/ip/pwm/rtl/pwm.sv
. In addition, it instantiates the following interfaces, connects them to the DUT and sets their handle into uvm_config_db
:
pins_if
)pins_if
)The following utilities provide generic helper tasks and functions to perform activities that are common across the project:
All common types and methods defined at the package level can be found in pwm_env_pkg
. Some of them in use are:
parameter uint NUM_PWM_CHANNELS = 6; // datatype typedef enum bit [1:0] { Standard = 2'b00, Blinking = 2'b01, Heartbeat = 2'b11, Allmodes = 2'b10 } pwm_mode_e; typedef enum bit { Enable = 1'b1, Disable = 1'b0 } pwm_status_e; typedef struct packed { bit [26:0] ClkDiv; bit [3:0] DcResn; bit CntrEn; } cfg_reg_t; typedef struct packed { bit BlinkEn; bit HtbtEn; bit [13:0] RsvParam; bit [15:0] PhaseDelay; } param_reg_t; typedef struct packed { bit [15:0] B; bit [15:0] A; } dc_blink_t; // function function automatic pwm_mode_e get_pwm_mode(bit [1:0] mode); return (mode == 2'b10) ? Blinking : (mode == 2'b11) ? Heartbeat : (mode == 2'b00) ? Standard : Allmodes; endfunction : get_pwm_mode
PWM instantiates (already handled in CIP base env) tl_agent which provides the ability to drive and independently monitor random traffic via TL host interface into PWM device.
Because the DUT does require any response a full agent is not needed. Instead a PWM monitor has been developed. It will capture all traffic on the PWM channel and each pulse in a pwm sequence item for later analysis in the scoreboard. For each pulse a number of features are captured such as:
The PWM RAL model is created with the ralgen
FuseSoC generator script automatically when the simulation is at the build stage.
It can be created manually by invoking regtool
All test sequences reside in hw/ip/pwm/dv/env/seq_lib
. The pwm_base_vseq
virtual sequence is extended from cip_base_vseq
and serves as a starting point. All test sequences are extended from pwm_base_vseq
. It provides commonly used handles, variables, functions and tasks that the test sequences can simple use / call.
Some of the most commonly used tasks / functions are as follows:
To ensure high quality constrained random stimulus, it is necessary to develop a functional coverage model. The functional coverage plan can be found here: coverageplan
The pwm_scoreboard
is primarily used for transaction-by-transaction checking. It creates the following analysis ports to retrieve the data monitored by corresponding interface agents:
when a channel is configured to start sending pulses the first expected item is generated. Because of the way the PWM IP is design the first and the last pulse might not match the configuration settings. Therefore the scoreboard will wait until a channel is disabled before checking the output. Once a channel is disabled it will first discard the first two items received from the monitor. The is send because the channel was enabled and has no valid information. The second is the one that cannot be expected to match configuration. For pulse mode it will get the expected pulse item and match all incoming item to this one. For blink and heart beat mode after an item is compared successfully the scoreboard will generate the next expected item based on the previous item and the settings of the blink parameters. If an error is found the scoreboard will throw an error.
tb/pwm_bind.sv
binds the tlul_assert
assertions to the IP to ensure TileLink interface protocol compliance.We are using our in-house developed regression tool for building and running our tests and regressions. Please take a look at the link for detailed information on the usage, capabilities, features and known issues. Here's how to run a smoke test:
$ $REPO_TOP/util/dvsim/dvsim.py $REPO_TOP/hw/ip/pwm/dv/pwm_sim_cfg.hjson -i pwm_smoke