system verilog part24
vn dv pathshala
0:00 / 0:00
system verilog part24
5 просмотров · 8 дней назад
vn dv pathshala
195 подписчиков
5 просмотров · 8 дней назад
SystemVerilog Functional Coverage, focusing on what functional coverage means, the difference between code and functional coverage, and the concepts of covergroups, coverpoints, bins, and sampling. Functional coverage is a user-defined measurement of whether the important functional scenarios specified in the verification plan have actually been exercised. Unlike code coverage, which measures whether RTL constructs such as statements, branches, expressions, FSM states/transitions, and toggles have executed, functional coverage measures whether the intended behavior and scenarios of the design have been tested. For example, if an APB slave supports READ, WRITE, different addresses, PSTRB combinations, wait states, and error responses, functional coverage can explicitly define these scenarios and determine whether each one has occurred. A covergroup is the container that defines the functional coverage model and specifies when sampling occurs, commonly using @(posedge clk). Inside the covergroup, a coverpoint identifies the variable or expression whose values we want to measure—for example, cp1: coverpoint addr;, cp2: coverpoint data;, and cp3: coverpoint en;. The possible values of a coverpoint are divided into bins, which represent meaningful value groups or scenarios. Bins can be automatically generated by the simulator or explicitly defined by the verification engineer. For example, for addr[3:0], automatic bins can represent values 0,1,2,...15, while explicit bins could group specific addresses such as bins low_addr = {0,1,2}; and bins high_addr = {[8:15]};. Explicit bins are generally more useful for protocol verification because we can group values according to functional meaning rather than merely numerical ranges. The image also highlights that bins can be classified as normal bins, ignored bins, and illegal bins. An ignore_bins declaration excludes values from the coverage calculation when those values are valid but irrelevant to the particular coverage goal, while illegal_bins identifies values that should never occur and can flag an error when sampled. Sampling is the process by which the covergroup evaluates the coverpoints and determines which bins have been hit. In the typical flow shown, a clocking event occurs, the covergroup is sampled, the coverpoint values are evaluated, matching bins are hit, and the coverage database is updated. For example, if we have covergroup cg @(posedge pclk); coverpoint paddr; coverpoint pwrite; endgroup, then at each positive edge of pclk, the current values of paddr and pwrite are sampled and the corresponding bins are updated. An important point is that 100% functional coverage does not necessarily mean the design is bug-free; it only means that all scenarios represented in the functional coverage model have been exercised. If an important feature was never included in the coverage model, the coverage report cannot tell us that it was missed. This is why the functional coverage model must be derived carefully from the specification and verification plan. In practical DV work, functional coverage becomes much more powerful when combined with cross coverage, where two or more coverpoints are combined to verify meaningful combinations—for example, cross pwrite, paddr; can ensure that both READ/WRITE operations occur across the required address regions. For an interview, a concise answer would be: “Functional coverage is a user-defined metric used to measure whether the important functional scenarios from the specification have been exercised. We create covergroups containing coverpoints and bins, sample them during simulation, and analyze the coverage report to identify missing scenarios. Code coverage tells us what RTL code was executed, whereas functional coverage tells us whether the intended functionality and scenarios were exercised. I use functional coverage along with assertions, scoreboard checking, and code coverage to achieve confidence in verification completeness.”