data/full_repos/permissive/203650831/hd44780_hello.v
None: at end of input
1: b'%Error: data/full_repos/permissive/203650831/hd44780_hello.v:16: Cannot find include file: ./hd44780_build_config.inc\n`include "./hd44780_build_config.inc" \n         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/203650831,data/full_repos/permissive/203650831/./hd44780_build_config.inc\n             data/full_repos/permissive/203650831,data/full_repos/permissive/203650831/./hd44780_build_config.inc.v\n             data/full_repos/permissive/203650831,data/full_repos/permissive/203650831/./hd44780_build_config.inc.sv\n             ./hd44780_build_config.inc\n             ./hd44780_build_config.inc.v\n             ./hd44780_build_config.inc.sv\n             obj_dir/./hd44780_build_config.inc\n             obj_dir/./hd44780_build_config.inc.v\n             obj_dir/./hd44780_build_config.inc.sv\n%Error: data/full_repos/permissive/203650831/hd44780_hello.v:247: Define or directive not defined: \'`H4_TIMER_BITS\'\n    reg[`H4_TIMER_BITS-1:0] htime_len = 0;\n        ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/203650831/hd44780_hello.v:275: Define or directive not defined: \'`H4_DELAY_100MS\'\n                htime_len <= `H4_DELAY_100MS;\n                             ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/203650831/hd44780_hello.v:275: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n                htime_len <= `H4_DELAY_100MS;\n                                            ^\n%Error: data/full_repos/permissive/203650831/hd44780_hello.v:354: Define or directive not defined: \'`H4_TIMER_BITS\'\n    parameter GREENBLINKBITS = `H4_TIMER_BITS + 2;   \n                               ^~~~~~~~~~~~~~\n%Error: Exiting due to 5 error(s)\n'
module hd44780_hello(

    output wire lcd_rs,
    output wire lcd_e,
    output wire [3:0] lcd_data,
    input wire the_button,
    output wire led_g,
    output wire led_b,
    output wire led_r,
    output wire o_led0,
    output wire o_led1,
    output wire o_led2,
    output wire o_led3,
    output wire logan_strobe
    );







	wire clk;



    SB_HFOSC #(.CLKHF_DIV("0b11")) u_hfosc (
		.CLKHFPU(1'b1),
		.CLKHFEN(1'b1),
		.CLKHF(clk)
	);





    wire button_internal;
    wire button_acthi;
    SB_IO #(
        .PIN_TYPE(6'b 0000_01),
        .PULLUP(1'b 1)
    ) button_input(
        .PACKAGE_PIN(the_button),
        .D_IN_0(button_internal)
    );
    assign button_acthi = ~button_internal;






    reg led_r_pwm_reg = 0;
    reg led_g_pwm_reg = 0;
    reg led_b_pwm_reg = 0;

    SB_RGBA_DRV rgb (
      .RGBLEDEN (1'b1),
      .RGB0PWM  (led_g_pwm_reg),
      .RGB1PWM  (led_b_pwm_reg),
      .RGB2PWM  (led_r_pwm_reg),
      .CURREN   (1'b1),
      .RGB0     (led_g),
      .RGB1     (led_b),
      .RGB2     (led_r)
    );
    defparam rgb.CURRENT_MODE = "0b1";
    defparam rgb.RGB0_CURRENT = "0b000001";
    defparam rgb.RGB1_CURRENT = "0b000001";
    defparam rgb.RGB2_CURRENT = "0b000001";


    wire led_g_outwire;



    parameter PWMbits = 3;
    reg[PWMbits-1:0] pwmctr = 0;
    always @(posedge clk) begin



        led_g_pwm_reg <= (&pwmctr) & led_g_outwire;
        led_b_pwm_reg <= (&pwmctr) & led_b_outwire;
        led_r_pwm_reg <= (&pwmctr) & led_r_outwire;
        pwmctr <= pwmctr + 1;
    end






    wire wb_reset;
    wire syscon_reset;
    wire wb_clk;
    hd44780_syscon syscon(
        .i_clk(clk),
        .RST_O(syscon_reset),
        .CLK_O(wb_clk)
        );






    reg button_has_been_pressed = 0;
    reg logan_strobe_reg = 0;

    always @(posedge clk) begin
        if(~button_has_been_pressed) begin
            if(button_acthi) begin


                button_has_been_pressed <= 1;


            end
        end
    end




    assign wb_reset = syscon_reset | ~button_has_been_pressed;






    wire led_g_outwire;
    wire led_b_outwire;
    wire led_r_outwire;




    parameter address_bits = 8, data_bits = 16;
    localparam text_instr_addr = 16;

    reg [address_bits-1:0] start_addr = 0;
    reg [address_bits-1:0] addr_w_reg = 0;

    wire [address_bits-1:0] addr_r_wires;
    reg [data_bits-1:0] data_w_reg = 0;

    wire [data_bits-1:0] data_r_wire;
    reg ram_wen = 0;


    hd44780_ram #(.initfile("settings/init-totoro.mem"),.filehex(0),.addr_width(address_bits),.data_width(data_bits)) rammy(
        .din(data_w_reg),
        .write_en(ram_wen),
        .waddr(addr_w_reg),
        .wclk(clk),
        .raddr(addr_r_wires),
        .rclk(clk),
        .dout(data_r_wire));


    reg cont_stb = 0;
    wire cont_busy;
    wire cont_error;


    hd44780_controller ctrlr(
        .RST_I(wb_reset),
        .CLK_I(wb_clk),
        .STB_I(cont_stb),


        .o_read_addr_lines(addr_r_wires),
        .i_start_addr(start_addr),
        .i_read_data_lines(data_r_wire),


        .busy(cont_busy),
        .error(cont_error),



        .o_lcd_nybble(lcd_data),
        .o_rs(lcd_rs),
        .o_e(lcd_e)
    );


    reg reg_led0 = 0;
    reg reg_led1 = 0;
    reg reg_led2 = 0;
    reg reg_led3 = 0;


    reg[`H4_TIMER_BITS-1:0] htime_len = 0;
    reg htimer_stb_reg = 0;

    wire htimer_busy;
    hd44780_state_timer stimey(
        .RST_I(wb_reset),
        .CLK_I(wb_clk),
        .DAT_I(htime_len),
        .start_strobe(htimer_stb_reg),
        .busy(htimer_busy)
        );



    reg[3:0] hello_state = 0;
    localparam hello_begin = 4'b0000, hello_100ms_drop = 4'b0001, hello_100ms_wait = 4'b0010,
        hello_init_drop = 4'b0011, hello_init_wait = 4'b0100,
        hello_text_begin = 4'b0101, hello_text_raise = 4'b0110, hello_text_drop = 4'b0111, hello_text_wait = 4'b1000,
        hello_lockup = 4'b1001;

    always @(posedge wb_clk) begin
        case(hello_state)
            hello_begin: begin

                reg_led0 <= 1;
                reg_led1 <= 1;
                reg_led2 <= 1;
                reg_led3 <= 1;
                htime_len <= `H4_DELAY_100MS;

                if(button_has_been_pressed) begin

                    htimer_stb_reg <= 1;
                    hello_state <= hello_100ms_drop;
                    reg_led0 <= 0;
                end
            end

            hello_100ms_drop: begin
                htimer_stb_reg <= 0;
                hello_state <= hello_100ms_wait;
            end

            hello_100ms_wait: begin

                if(~htimer_busy) begin
                    cont_stb <= 1;
                    reg_led1 <= 0;
                    logan_strobe_reg <= 1;
                    hello_state <= hello_init_drop;
                end
            end

            hello_init_drop: begin
                cont_stb <= 0;
                hello_state <= hello_init_wait;
            end

            hello_init_wait: begin
                if(~cont_busy) begin
                    reg_led2 <= 0;
                    hello_state <= hello_text_begin;
                end
            end

            hello_text_begin: begin
                start_addr <= text_instr_addr;
                hello_state <= hello_text_raise;
            end

            hello_text_raise: begin
                cont_stb <= 1;
                hello_state <= hello_text_drop;
            end

            hello_text_drop: begin
                cont_stb <= 0;
                hello_state <= hello_text_wait;
            end

            hello_text_wait: begin

                if(~cont_busy) begin
                    reg_led3 <= 0;
                    hello_state <= hello_lockup;
                end
            end

            hello_lockup: begin

                hello_state <= hello_lockup;
            end
        endcase
    end


    assign logan_strobe = logan_strobe_reg;



    assign o_led0 = reg_led0;
    assign o_led1 = reg_led1;
    assign o_led2 = reg_led2;
    assign o_led3 = reg_led3;



    parameter GREENBLINKBITS = `H4_TIMER_BITS + 2;


    reg[GREENBLINKBITS-1:0] greenblinkct = 0;
    always @(posedge clk) begin
        greenblinkct <= greenblinkct + 1;
    end

    assign led_g_outwire = ~greenblinkct[GREENBLINKBITS-1];
    assign led_b_outwire = greenblinkct[GREENBLINKBITS-1];
    assign led_r_outwire = ~greenblinkct[GREENBLINKBITS-2];



endmodule
module hd44780_hello(

    output wire lcd_rs,
    output wire lcd_e,
    output wire [3:0] lcd_data,
    input wire the_button,
    output wire led_g,
    output wire led_b,
    output wire led_r,
    output wire o_led0,
    output wire o_led1,
    output wire o_led2,
    output wire o_led3,
    output wire logan_strobe
    );








	wire clk;



    SB_HFOSC #(.CLKHF_DIV("0b11")) u_hfosc (
		.CLKHFPU(1'b1),
		.CLKHFEN(1'b1),
		.CLKHF(clk)
	);





    wire button_internal;
    wire button_acthi;
    SB_IO #(
        .PIN_TYPE(6'b 0000_01),
        .PULLUP(1'b 1)
    ) button_input(
        .PACKAGE_PIN(the_button),
        .D_IN_0(button_internal)
    );
    assign button_acthi = ~button_internal;






    reg led_r_pwm_reg = 0;
    reg led_g_pwm_reg = 0;
    reg led_b_pwm_reg = 0;

    SB_RGBA_DRV rgb (
      .RGBLEDEN (1'b1),
      .RGB0PWM  (led_g_pwm_reg),
      .RGB1PWM  (led_b_pwm_reg),
      .RGB2PWM  (led_r_pwm_reg),
      .CURREN   (1'b1),
      .RGB0     (led_g),
      .RGB1     (led_b),
      .RGB2     (led_r)
    );
    defparam rgb.CURRENT_MODE = "0b1";
    defparam rgb.RGB0_CURRENT = "0b000001";
    defparam rgb.RGB1_CURRENT = "0b000001";
    defparam rgb.RGB2_CURRENT = "0b000001";


    wire led_g_outwire;



    parameter PWMbits = 3;
    reg[PWMbits-1:0] pwmctr = 0;
    always @(posedge clk) begin



        led_g_pwm_reg <= (&pwmctr) & led_g_outwire;
        led_b_pwm_reg <= (&pwmctr) & led_b_outwire;
        led_r_pwm_reg <= (&pwmctr) & led_r_outwire;
        pwmctr <= pwmctr + 1;
    end






    wire wb_reset;
    wire syscon_reset;
    wire wb_clk;
    hd44780_syscon syscon(
        .i_clk(clk),
        .RST_O(syscon_reset),
        .CLK_O(wb_clk)
        );






    reg button_has_been_pressed = 0;
    reg logan_strobe_reg = 0;

    always @(posedge clk) begin
        if(~button_has_been_pressed) begin
            if(button_acthi) begin


                button_has_been_pressed <= 1;


            end
        end
    end




    assign wb_reset = syscon_reset | ~button_has_been_pressed;






    wire led_g_outwire;
    wire led_b_outwire;
    wire led_r_outwire;




    parameter address_bits = 8, data_bits = 16;
    localparam text_instr_addr = 16;

    reg [address_bits-1:0] start_addr = 0;
    reg [address_bits-1:0] addr_w_reg = 0;

    wire [address_bits-1:0] addr_r_wires;
    reg [data_bits-1:0] data_w_reg = 0;

    wire [data_bits-1:0] data_r_wire;
    reg ram_wen = 0;


    hd44780_ram #(.initfile("settings/init-totoro.mem"),.filehex(0),.addr_width(address_bits),.data_width(data_bits)) rammy(
        .din(data_w_reg),
        .write_en(ram_wen),
        .waddr(addr_w_reg),
        .wclk(clk),
        .raddr(addr_r_wires),
        .rclk(clk),
        .dout(data_r_wire));


    reg cont_stb = 0;
    wire cont_busy;
    wire cont_error;


    hd44780_controller ctrlr(
        .RST_I(wb_reset),
        .CLK_I(wb_clk),
        .STB_I(cont_stb),


        .o_read_addr_lines(addr_r_wires),
        .i_start_addr(start_addr),
        .i_read_data_lines(data_r_wire),


        .busy(cont_busy),
        .error(cont_error),



        .o_lcd_nybble(lcd_data),
        .o_rs(lcd_rs),
        .o_e(lcd_e)
    );


    reg reg_led0 = 0;
    reg reg_led1 = 0;
    reg reg_led2 = 0;
    reg reg_led3 = 0;


    reg[`H4_TIMER_BITS-1:0] htime_len = 0;
    reg htimer_stb_reg = 0;

    wire htimer_busy;
    hd44780_state_timer stimey(
        .RST_I(wb_reset),
        .CLK_I(wb_clk),
        .DAT_I(htime_len),
        .start_strobe(htimer_stb_reg),
        .busy(htimer_busy)
        );



    reg[3:0] hello_state = 0;
    localparam hello_begin = 4'b0000, hello_100ms_drop = 4'b0001, hello_100ms_wait = 4'b0010,
        hello_init_drop = 4'b0011, hello_init_wait = 4'b0100,
        hello_text_begin = 4'b0101, hello_text_raise = 4'b0110, hello_text_drop = 4'b0111, hello_text_wait = 4'b1000,
        hello_lockup = 4'b1001;

    always @(posedge wb_clk) begin
        case(hello_state)
            hello_begin: begin

                reg_led0 <= 1;
                reg_led1 <= 1;
                reg_led2 <= 1;
                reg_led3 <= 1;
                htime_len <= `H4_DELAY_100MS;

                if(button_has_been_pressed) begin

                    htimer_stb_reg <= 1;
                    hello_state <= hello_100ms_drop;
                    reg_led0 <= 0;
                end
            end

            hello_100ms_drop: begin
                htimer_stb_reg <= 0;
                hello_state <= hello_100ms_wait;
            end

            hello_100ms_wait: begin

                if(~htimer_busy) begin
                    cont_stb <= 1;
                    reg_led1 <= 0;
                    logan_strobe_reg <= 1;
                    hello_state <= hello_init_drop;
                end
            end

            hello_init_drop: begin
                cont_stb <= 0;
                hello_state <= hello_init_wait;
            end

            hello_init_wait: begin
                if(~cont_busy) begin
                    reg_led2 <= 0;
                    hello_state <= hello_text_begin;
                end
            end

            hello_text_begin: begin
                start_addr <= text_instr_addr;
                hello_state <= hello_text_raise;
            end

            hello_text_raise: begin
                cont_stb <= 1;
                hello_state <= hello_text_drop;
            end

            hello_text_drop: begin
                cont_stb <= 0;
                hello_state <= hello_text_wait;
            end

            hello_text_wait: begin

                if(~cont_busy) begin
                    reg_led3 <= 0;
                    hello_state <= hello_lockup;
                end
            end

            hello_lockup: begin

                hello_state <= hello_lockup;
            end
        endcase
    end


    assign logan_strobe = logan_strobe_reg;



    assign o_led0 = reg_led0;
    assign o_led1 = reg_led1;
    assign o_led2 = reg_led2;
    assign o_led3 = reg_led3;



    parameter GREENBLINKBITS = `H4_TIMER_BITS + 2;


    reg[GREENBLINKBITS-1:0] greenblinkct = 0;
    always @(posedge clk) begin
        greenblinkct <= greenblinkct + 1;
    end

    assign led_g_outwire = ~greenblinkct[GREENBLINKBITS-1];
    assign led_b_outwire = greenblinkct[GREENBLINKBITS-1];
    assign led_r_outwire = ~greenblinkct[GREENBLINKBITS-2];



endmodule