I am a beginner in Verilog and my counter is not working. I'm not sure what I'm doing wrong. Below, I will type my code.
module jkfflop(
input J,
input K,
input clk,
output Q);
reg Q;
always @(posedge clk) begin
if(J==1'b0 && K==1'b1) begin
Q <= 'b0;
end
else if(J==1'b1 && K==1'b0) begin
Q <= 1'b1;
end
else if(J==1'b1 & K==1'b1) begin
Q <= ~Q;
end
end
endmodule
module counter(
input clk,
output[3:0] q1,
output[3:0] an,
output a,b,c,d,e,f,g);
wire sclk;
wire t1, t2;
and(t1,q1[1],q1[0]);
and(t2,t1,q1[2]);
slowClock ck1 (clk, 1'b1,sclk);
jkfflop ff1(q1[0], 1'b1, 1'b1, sclk);
jkfflop ff2(q1[1], q1[0], q1[0], sclk);
jkfflop ff3(q1[2], t1, t2, sclk);
jkfflop ff4(q1[3], t2, t2, sclk);
sevseg S1(q1[0],q1[1],q1[2],q1[3],a,b,c,d,e,f,g,an);
endmodule
module sevseg(
input A,
input B,
input C,
input D,
output a,b,c,d,e,f,g,
output[3:0] an);
assign an = 4'b1110;
assign a = (~A & ~B & ~C & ~D) | (~A & B & ~C & ~D);
assign b = (~B & ~C & D) | (~B & ~C & ~D);
assign c = (~A & ~B & C & ~D);
assign d = (B & ~C & ~D) | (B & C & D);
assign e = D | (B & ~C);
assign f = (C & D) | (~A & ~B & ~C) + (B & C & D);
assign g = (~A & ~B & ~C) + (B & C & D);
endmodule
jkfflop ff1(q1[0], 1'b1, 1'b1, sclk), the argument list is in a different order -- q1[0] (as J), 1'b1 (as K), 1'b1 (as clk), sclk (as output reg Q), which is clearly not what you intended. \$\endgroup\$