Three in One Vlsi Interview Guide
Three in One Vlsi Interview Guide
function T pop();
if (q.size() > 0)
return q.pop_front();
else begin
$display("FIFO Empty");
return '0;
end
endfunction
function int size();
return q.size();
endfunction
endclass
module top;
logic clk;
alu_if intf(clk);
alu u1(intf);
endmodule
3. Write a SystemVerilog constraint to generate an
even number between 10 and 100 divisible by 6.
Answer:
class gen_num;
rand int x;
constraint c1 {
x inside {[10:100]};
x % 2 == 0;
x % 6 == 0;
}
endclass
function new();
cg = new();
endfunction
endclass
class fsm;
state_t current;
function void next_state(state_t s);
case (s)
IDLE: $display("State: IDLE");
READ: $display("State: READ");
WRITE: $display("State: WRITE");
default: $display("Unknown");
endcase
endfunction
endclass
7. Demonstrate with clause in constrained
randomization.
Answer:
class item;
rand int a, b;
endclass
module tb;
item it = new();
initial begin
void'(it.randomize() with { a > b; a < 100; b > 10;
});
$display("a = %0d, b = %0d", it.a, it.b);
end
endmodule
initial begin
#10;
int val;
mbx.get(val);
$display("Received: %0d", val);
end
initial begin
#5;
mbx.put(42);
end
endmodule
payload p = new();
module tb;
addr_gen ag = new();
initial begin
void'(ag.randomize() with {
addr inside {[32'h1000:32'h2000]};
addr % 16 == 0;
});
$display("Aligned Address: %0h", ag.addr);
end
endmodule
initial begin
if (type == "A")
obj = new A;
else
obj = new B;
obj.disp();
end
endmodule
initial begin
cg = new();
// drive values and sample
end
endmodule
constraint c {
mem.size() == 8;
foreach (mem[i])
mem[i] inside {[0:255]};
}
endclass
+91- 9182280927