// Programmed by James Tandon module template(x, state_input, clk, q); input [1:0]x; input state_input, clk; output [3:0]q; reg [3:0]q; initial begin q[3:0] = 0; end // You can place both state machine tables in this file. Which section should you use for // the serial adder? Which section should you use for the 1-digit BCD counter? always@(posedge clk) begin if (state_input) begin case ({x,q[1:0]}) 4'b0000 : q <= 4'b0001 ; 4'b0001 : q <= 4'b0010 ; 4'b0010 : q <= 4'b0011 ; 4'b0011 : q <= 4'b0100 ; 4'b0100 : q <= 4'b0000 ; 4'b0101 : q <= 4'b0000 ; 4'b0110 : q <= 4'b0000 ; 4'b0111 : q <= 4'b0000 ; 4'b1000 : q <= 4'b0000 ; 4'b1001 : q <= 4'b0000 ; 4'b1010 : q <= 4'b0000 ; 4'b1011 : q <= 4'b0000 ; 4'b1100 : q <= 4'b0000 ; 4'b1101 : q <= 4'b0000 ; 4'b1110 : q <= 4'b0000 ; 4'b1111 : q <= 4'b0000 ; endcase end else begin case (q) 4'b0000 : q <= 4'b0000 ; 4'b0001 : q <= 4'b0000 ; 4'b0010 : q <= 4'b0000 ; 4'b0011 : q <= 4'b0000 ; 4'b0100 : q <= 4'b0000 ; 4'b0101 : q <= 4'b0000 ; 4'b0110 : q <= 4'b0000 ; 4'b0111 : q <= 4'b0000 ; 4'b1000 : q <= 4'b0000 ; 4'b1001 : q <= 4'b0000 ; 4'b1010 : q <= 4'b0000 ; 4'b1011 : q <= 4'b0000 ; 4'b1100 : q <= 4'b0000 ; 4'b1101 : q <= 4'b0000 ; 4'b1110 : q <= 4'b0000 ; 4'b1111 : q <= 4'b0000 ; endcase end end endmodule