Block coverage is a type of code coverage that measures the percentage of basic blocks executed during the simulation. A basic block is a continuous sequence of code statements with a single point of entry and a single point of exit.
Here is an example of block coverage RTL code:
module my_module(input clk, input sel, input [7:0] data, output reg [7:0] out); reg [7:0] internal_reg; always @(posedge clk) begin if(sel) begin internal_reg <= data; end else begin internal_reg <= internal_reg + 1; end end always @* begin case(internal_reg) 8'h00: out = 8'h10; 8'h01: out = 8'h20; 8'h02: out = 8'h30; 8'h03: out = 8'h40; default: out = 8'h50; endcase end endmodule
In this example, the my_module contains two always blocks that operate on different conditions. The first always block updates the value of internal_reg based on the value of sel and data inputs. The second always block uses the value of internal_reg to set the output value.
The basic blocks in this RTL code include the if/else condition in the first always block and the case statement in the second always block. Block coverage would measure the percentage of these basic blocks that have been executed during the simulation.
To determine the block coverage of this RTL code, a testbench would need to be created that exercises both the if/else condition in the first always block and each of the cases in the second always block. The percentage of basic blocks executed during the simulation compared to the total number of basic blocks in the code would provide the block coverage result.