No Consecutive 7's

Tenstorrent
Micron

Problem Description

Write a SystemVerilog constraint to satisfy the following requirements:

  1. Each element of the queue should have a value between 0 and 9 (inclusive).

  2. No two consecutive elements in the queue should have the value 7.

Example output :

Correct output :

q = {0, 4, 7, 5, 7, 5, 7, …. (50 elements) …, 3};

Incorrect output :

q = {3, 7, 7, 1, 8, 5, 7, …. (50 elements) …, 4}; → Two sevens are consecutive to each other

SystemVerilog

Code Editor Access

Log in to write, run and submit your solution to this interview question. It's free.

Output

Output goes here...