4. (30') Verilog design of sequential circuit: The block diagram and state transition graph of a sequence detector is shown in Figure 4.
(1) Is it a Mealy machine or Moore machine? How do you know? Assume the initial state is A, based on STG, can you guess what sequence (four-bit) this circuit detects? (Hint: follow the "lucky-day" input sequence in STG to achieve output z=1)
(2) Use the template we learned in class, can you write Verilog code (STG-based) to design this sequential circuit?
(3) Use the template we learned in class, can you write a Verilog testbench file to test this sequential circuit? Use the last digit of your student ID and convert it into a four-bit binary sequence for testing. For example, if the last digit of your student ID is "9" = "1001 (2)", then you can set your test pattern as x=1 -> 0 -> 0 -> 1 as your test pattern sequence. Each test pattern lasts for 10ns.
(a)
(b)
Figure 4. A sequence detector circuit (Mealy machine) (a) block diagram (b) State transition graph
detector is shown in Figure 4.
sequential circuit? (3) Use the template we learned in class, can you write a Verilog testbench file to test this sequential circuit? Use the last digit of your student ID and convert it into a four-bit binary sequence for testing. For example, if the last digit of your student ID is 9 = 1001 then you can set your test pattern as x=1-0-0-1 as your test pattern sequence. Each test pattern lasts for 10ns.
1/0
Input (x) clock clk
0/0
0/0
Sequence detector
>Output)
0/0
B
1/0
C
1/1
1/0
0/0
(a)
(b)
Figure 4. A sequence detector circuit (Mealy machine) (a) block diagram (b) State transition graph