I'm having trouble with a verilog case statement executing strangely and I don't know why.
The basics below... I'm sending X/Y coordinates to a module, setting write enable (we), and then waiting for it to strobe data valid (dv) for a clock cycle.
X and Y start off at 0. WE gets set to 1 and then wait for the dv flag to be set. And this should happen forever. The clock divider is there to pause between sending X/Y coordinates.
The problem I'm having is that middle case expression is getting executed at some point and I don't understand why. wait_ans never gets set to 2'b10 at any point. I have changed that middle expression to be 3'b010 and it still executes.
Do verilog case statements "fall through" to the next case expression unless you call "break" like they do in some programming languages? I haven't seen anything to indicate that they do.
Is my concatenation of {wait_ans, dv} wrong?
module top_framebuffer_seven(
output [0:8] out_matrix
);
wire CLKHF, dv;
wire [1:0] dout_a;
reg we = 0;
reg [1:0] din_a = 3;
reg [2:0] x = 0;
reg [3:0] y = 0;
reg [1:0] wait_ans = 2'b00;
reg [31:0] divider = 3000000;
framebuffer_seven fb(32'b11111111_10000000_01000000_00000000, CLKHF, we, 0, 1, din_a, dout_a, 6'b0, x, y, dv, out_matrix);
HSOSC #(.CLKHF_DIV ("0b11")) OSCInst0 (.CLKHFEN (1), .CLKHFPU (1), .CLKHF (CLKHF));
always @(posedge CLKHF) begin
if (divider != 0)
divider <= divider - 1;
else
case ({wait_ans, dv})
3'b000 : begin
we <= 1;
wait_ans <= 2'b11;
end
3'b100 : begin
x <= 2;
y <= 6;
wait_ans <= 2'b00;
end
3'b111 : begin
wait_ans <= 2'b00;
we <= 0;
divider <= 3000000;
end
endcase
end
endmodule