Which SystemVerilog constraint block generates an 8-bit unsigned address…
Which SystemVerilog constraint block generates an 8-bit unsigned address addr that is **even** and lies in the inclusive range **32 to 127**? class address_item; rand bit [7:0] addr; // constraint here endclass
- constraint addr_c { addr inside {[8'd32:8'd127]}; addr[0] == 1'b0; }
- constraint addr_c { addr inside {[8'd32:8'd127]}; addr[0] == 1'b1; }
- constraint addr_c { 32 <= addr <= 127; addr[1:0] == 2'b00; }
- constraint addr_c { addr inside {[8'd32:8'd127]}; addr[7] == 1'b0; }
Correct answer
A. constraint addr_c { addr inside {[8'd32:8'd127]}; addr[0] == 1'b0; }
Explanation
addr inside {[8'd32:8'd127]}; restricts addr to the inclusive range $[32, 127]$, and addr[0] == 1'b0; forces the least significant bit to 0 so every generated address is even. Option B produces odd numbers, Option C chains relational operators (which in Verilog/SV evaluates (32 <= addr) <= 127 and also forces 4-byte alignment), and Option D only checks the MSB.