module test_branch;
    reg clk=0;
    reg [3:0] key=14;
    reg [9:0] switches=0;
    wire [9:0] lamps;
    wire [6:0] h0,h1,h2,h3,h4,h5;
    wire [41:0] letters = ~{h5,h4,h3,h2,h1,h0};
    localparam [41:0] pass_word = {7'h73,7'h77,7'h6d,7'h6d,7'h79,7'h5e};
    localparam [41:0] fail_word = {7'h71,7'h77,7'h30,7'h38,7'h79,7'h5e};
    branch_cpu dut(clk,key,switches,lamps,h0,h1,h2,h3,h4,h5);
    always #1 clk=~clk;
    initial begin
        repeat(5) @(negedge clk); key=15;
        if (letters!==0 || lamps!==0) begin $display("FAIL reset"); $finish; end
        switches=512; repeat(3000) @(negedge clk);
        if (letters===fail_word) begin $display("FAIL diagnostic address 0x%h",lamps); $finish; end
        if (letters!==pass_word || lamps!==14) begin $display("FAIL result %h %h",letters,lamps); $finish; end
        switches=0; repeat(100) @(negedge clk);
        if (letters!==pass_word || lamps!==14) begin $display("FAIL hold"); $finish; end
        $display("PASS 14 diagnostic cases, six display glyphs and halt"); $finish;
    end
endmodule
