سوال ۸۲ کنکور ارشد مهندسی کامپیوتر ۱۴۰۱
کد وریلاگ زیر، توصیفکنندهٔ یک توالی شمارش با چه تعداد سیکل ساعت تکرار میباشد؟ (علامت نشاندهندهٔ XOR است.)
module func (R, L, clk, Q);
input |0:2|R;
input L, clk;
output reg [0:2] Q;
always @(posedge clk)
if (L)
Q <= R;
else
Q <= {Q[2], Q[0] ^ Q[2], Q[1]};
endmodule
پاسخ صحیح: گزینهٔ B — ۷
This is a 3-bit linear-feedback shift register (LFSR). The vector index runs , and the non-blocking assignment computes the next state from the current state :
so the next-state map is
Writing a state as , the transition is . Tracing every state:
| state | next |
|---|---|
The all-zero state is a fixed point (a dead state). All seven non-zero states form a single cycle:
The sequence therefore repeats every clock cycles. This is the maximal length of a 3-bit LFSR, , confirming the feedback polynomial is primitive. The answer is option 2.
Exam trick: A maximal-length -bit LFSR has period (it visits every state except all-zeros). Spotting the XOR-feedback shift structure lets you answer for without tracing the full table.