Given the finite state machine circuit as shown, assume that the D flip-flops are initially reset to zero before the machine begins.
Build this circuit.
开始的时候置0,所以一开始所有的Q都得是0;
这个地方放写完之后有个疑惑,就是w1、w2、w3是不是定义成reg类型会更好(reg类型是通过的) ,但是定义成wire类型也是通过了的:
module top_module (
input clk,
input x,
output z
);
wire w1,w2,w3; // 是不是定义成reg类型更好
initial begin
w1 = 0;
w2 = 0;
w3 = 0;
end
always @(posedge clk)begin
w1 = x^w1;
w2 = x&~w2;
w3 = x|~w3;
end
assign z = ~(w1|w2|w3);
endmodule