I'm making the master JK flipflop, and the errors came out like this:
** Error: (vlog-13069) C:/Windows/System32/ssy_1775_final.v(13): near "=": syntax error, unexpected '='.
** Error: C:/Windows/System32/ssy_1775_final.v(13): (vlog-13205) Syntax error found in the scope following 'Y'. Is there a missing '::'?
The code I made is as below:
module JK_FlipFlop(J, K, clk, Y_BAR, Y, Q);
input J, K, clk;
output Y, Q;
reg Y_BAR;
wire Y, Q;
always@(posedge clk)
assign Y_BAR = ~Y;
begin
if(J==0 && K==0)
begin Y=Y; Y_BAR=Y_BAR; end
else if(J==0 && K==1)
begin Y<=1'b0; Y_BAR<=1'b1; end
else if(J==1 && K==0)
begin Y<=1'b1; Y_BAR<=1'b0; end
else if(J==1 && K==1)
begin Y=Y_BAR; Y_BAR=Y; end
end
always@(negedge clk)
begin
if(Y==0 && Y_BAR==0)
begin end
else if(Y==0 && Y_BAR==1)
begin Q<=1'b0; end
else if(Y==1 && Y_BAR==0)
begin Q<=1'b1; end
else if(Y==1 && Y_BAR==1)
begin Q<=~Q; end
end
endmodule
I don't know why the error came out.
I pray that someone will spare me.