data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v
1: b'%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:105: Signal definition not found, creating implicitly: \'i2c_scl_i\'\n    assign i2c_scl_i = SCL_1;\n           ^~~~~~~~~\n                   ... Use "/* verilator lint_off IMPLICIT */" and lint_on around source to disable this message.\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:106: Signal definition not found, creating implicitly: \'i2c_scl_t\'\n                                                                                               : ... Suggested alternative: \'i2c_scl_i\'\n    assign SCL_1 = i2c_scl_t ? 1\'bz : i2c_scl_o;\n                   ^~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:106: Signal definition not found, creating implicitly: \'i2c_scl_o\'\n                                                                                               : ... Suggested alternative: \'i2c_scl_i\'\n    assign SCL_1 = i2c_scl_t ? 1\'bz : i2c_scl_o;\n                                      ^~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:108: Signal definition not found, creating implicitly: \'i2c_sda_i\'\n                                                                                               : ... Suggested alternative: \'i2c_scl_i\'\n    assign i2c_sda_i = SDA_1;\n           ^~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:109: Signal definition not found, creating implicitly: \'i2c_sda_t\'\n                                                                                               : ... Suggested alternative: \'i2c_sda_i\'\n    assign SDA_1 = i2c_sda_t ? 1\'bz : i2c_sda_o;\n                   ^~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:109: Signal definition not found, creating implicitly: \'i2c_sda_o\'\n                                                                                               : ... Suggested alternative: \'i2c_sda_i\'\n    assign SDA_1 = i2c_sda_t ? 1\'bz : i2c_sda_o;\n                                      ^~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:193: Signal definition not found, creating implicitly: \'i2c_cmd_start\'\n                                                                                               : ... Suggested alternative: \'cmd_start\'\n    assign i2c_cmd_start           = busy ? cmd_start          : 0;\n           ^~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:194: Signal definition not found, creating implicitly: \'i2c_cmd_read\'\n                                                                                               : ... Suggested alternative: \'cmd_read\'\n    assign i2c_cmd_read            = busy ? cmd_read           : 0;\n           ^~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:195: Signal definition not found, creating implicitly: \'i2c_cmd_write\'\n                                                                                               : ... Suggested alternative: \'cmd_write\'\n    assign i2c_cmd_write           = busy ? cmd_write          : 0;\n           ^~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:196: Signal definition not found, creating implicitly: \'i2c_cmd_write_multiple\'\n                                                                                               : ... Suggested alternative: \'cmd_write_multiple\'\n    assign i2c_cmd_write_multiple  = busy ? cmd_write_multiple : 0;\n           ^~~~~~~~~~~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:197: Signal definition not found, creating implicitly: \'i2c_cmd_stop\'\n                                                                                               : ... Suggested alternative: \'i2c_cmd_start\'\n    assign i2c_cmd_stop            = busy ? cmd_stop           : 0;\n           ^~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:198: Signal definition not found, creating implicitly: \'i2c_cmd_valid\'\n                                                                                               : ... Suggested alternative: \'cmd_valid\'\n    assign i2c_cmd_valid           = busy ? cmd_valid          : 0;\n           ^~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:200: Signal definition not found, creating implicitly: \'i2c_cmd_ready\'\n                                                                                               : ... Suggested alternative: \'i2c_cmd_read\'\n    assign cmd_ready               = i2c_cmd_ready;\n                                     ^~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:203: Signal definition not found, creating implicitly: \'i2c_data_in_valid\'\n                                                                                               : ... Suggested alternative: \'i2c_data_in\'\n    assign i2c_data_in_valid       = busy ? data_out_valid : 0;\n           ^~~~~~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:205: Signal definition not found, creating implicitly: \'i2c_data_in_ready\'\n                                                                                               : ... Suggested alternative: \'i2c_data_in_valid\'\n    assign data_out_ready          = i2c_data_in_ready;\n                                     ^~~~~~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:207: Signal definition not found, creating implicitly: \'i2c_data_in_last\'\n                                                                                               : ... Suggested alternative: \'i2c_data_in_ready\'\n    assign i2c_data_in_last        = busy ? data_out_last : 0;\n           ^~~~~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:209: Signal definition not found, creating implicitly: \'i2c_missed_ack\'\n                                                                                               : ... Suggested alternative: \'missed_ack\'\n    assign missed_ack = i2c_missed_ack;\n                        ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:54: Cannot find file containing module: \'i2c_master\'\n    i2c_master rtcc_i2c (\n    ^~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new,data/full_repos/permissive/189468210/i2c_master\n             data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new,data/full_repos/permissive/189468210/i2c_master.v\n             data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new,data/full_repos/permissive/189468210/i2c_master.sv\n             i2c_master\n             i2c_master.v\n             i2c_master.sv\n             obj_dir/i2c_master\n             obj_dir/i2c_master.v\n             obj_dir/i2c_master.sv\n%Error: data/full_repos/permissive/189468210/PMOD.srcs/sources_1/new/PMOD_RTCC.v:166: Cannot find file containing module: \'PMOD_RTCC_Op\'\n    PMOD_RTCC_Op rtcc_op (\n    ^~~~~~~~~~~~\n%Error: Exiting due to 2 error(s), 17 warning(s)\n'
module PMOD_RTCC(
    input CLK,
    input RST_N,
    
    input mfiState,
    output busy,
    
    inout SCL_1,
    inout SDA_1,
    inout SCL_2,
    inout SDA_2,
    
    output missed_ack
    );
    
    parameter CLK_FREQ = 100000000;
    parameter I2C_CLK_FREQ = 400000;
    
    localparam [6:0] EEPROM_ADDR = 'b1010111;
    localparam [6:0] RTCC_ADDR   = 'b1101111;
    
    localparam RTCC_REG_START = 0;
    localparam SRAM_START = 'h20;
    
    localparam EEPROM_START = 0;
    localparam EEPROM_PROTECTED_START = 'hF0;
    localparam EEPROM_STATUS_ADDR = 'hFF;
    
    wire [6:0] i2c_cmd_address;
    wire [7:0] i2c_data_in, i2c_data_out;
    
    i2c_master rtcc_i2c (
        .clk (CLK),
        .rst (~RST_N),
        

        .cmd_address        (i2c_cmd_address),
        .cmd_start          (i2c_cmd_start),
        .cmd_read           (i2c_cmd_read),
        .cmd_write          (i2c_cmd_write),
        .cmd_write_multiple (i2c_cmd_write_multiple),
        .cmd_stop           (i2c_cmd_stop),
        .cmd_valid          (i2c_cmd_valid),
        .cmd_ready          (i2c_cmd_ready),
        
        .data_in            (i2c_data_in),
        .data_in_valid      (i2c_data_in_valid),
        .data_in_ready      (i2c_data_in_ready),
        .data_in_last       (i2c_data_in_last),
        
        .data_out           (i2c_data_out),
        .data_out_valid     (i2c_data_out_valid),
        .data_out_ready     (i2c_data_out_ready),
        .data_out_last      (i2c_data_out_last),
        

        .scl_i              (i2c_scl_i),
        .scl_o              (i2c_scl_o),
        .scl_t              (i2c_scl_t),
        .sda_i              (i2c_sda_i),
        .sda_o              (i2c_sda_o),
        .sda_t              (i2c_sda_t),
        

        .busy               (i2c_busy),
        .bus_control        (i2c_bus_control),
        .bus_active         (i2c_bus_active),
        .missed_ack         (i2c_missed_ack),
        

        .prescale           (CLK_FREQ / (I2C_CLK_FREQ * 4)),
        .stop_on_idle       (1)
    );
    
    assign i2c_scl_i = SCL_1;
    assign SCL_1 = i2c_scl_t ? 1'bz : i2c_scl_o;
    assign SCL_2 = i2c_scl_t ? 1'bz : i2c_scl_o;
    assign i2c_sda_i = SDA_1;
    assign SDA_1 = i2c_sda_t ? 1'bz : i2c_sda_o;
    assign SDA_2 = i2c_sda_t ? 1'bz : i2c_sda_o;

    reg mfiState_prev;
    
    reg [6:0] dev_addr;
    reg [7:0] reg_addr;
    reg [7:0] reg_data;

    reg start;

    always @(posedge CLK) begin
        mfiState_prev <= mfiState;
    end

    always @(posedge CLK) begin
        if (!RST_N) begin
            start <= 0;
            dev_addr <= 0;
            reg_addr <= 0;
            reg_data <= 0;
        end
        else begin
            if (mfiState != mfiState_prev && !busy) begin
                start <= 1;
                
                if (mfiState) begin
                    dev_addr <= RTCC_ADDR;
                    reg_addr <= 'h07;
                    reg_data <= 'b10001000;
                end
                else begin
                    dev_addr <= RTCC_ADDR;
                    reg_addr <= 'h07;
                    reg_data <= 'b00001000;
                end
            end
            else begin
                start <= 0;
            end
        end
    end

    wire [6:0]  cmd_address;
    wire        cmd_start;
    wire        cmd_read;
    wire        cmd_write;
    wire        cmd_write_multiple;
    wire        cmd_stop;
    wire        cmd_valid;
    wire        cmd_ready;

    wire [7:0]  data_out;
    wire        data_out_valid;
    wire        data_out_ready;
    wire        data_out_last;
    
    PMOD_RTCC_Op rtcc_op (
        .clk     (CLK),
        .rst     (!RST_N),
        
        .dev_addr           (dev_addr),
        .reg_addr           (reg_addr),
        .reg_data           (reg_data),
        
        .cmd_address        (cmd_address),
        .cmd_start          (cmd_start),
        .cmd_read           (cmd_read),
        .cmd_write          (cmd_write),
        .cmd_write_multiple (cmd_write_multiple),
        .cmd_stop           (cmd_stop),
        .cmd_valid          (cmd_valid),
        .cmd_ready          (cmd_ready),
        
        .data_out           (data_out),
        .data_out_valid     (data_out_valid),
        .data_out_ready     (data_out_ready),
        .data_out_last      (data_out_last),

        .busy               (busy),
        .start              (start)
        );

    assign i2c_cmd_address         = busy ? cmd_address        : 0;
    assign i2c_cmd_start           = busy ? cmd_start          : 0;
    assign i2c_cmd_read            = busy ? cmd_read           : 0;
    assign i2c_cmd_write           = busy ? cmd_write          : 0;
    assign i2c_cmd_write_multiple  = busy ? cmd_write_multiple : 0;
    assign i2c_cmd_stop            = busy ? cmd_stop           : 0;
    assign i2c_cmd_valid           = busy ? cmd_valid          : 0;

    assign cmd_ready               = i2c_cmd_ready;

    assign i2c_data_in             = busy ? data_out       : 0;
    assign i2c_data_in_valid       = busy ? data_out_valid : 0;

    assign data_out_ready          = i2c_data_in_ready;

    assign i2c_data_in_last        = busy ? data_out_last : 0;
                                     
    assign missed_ack = i2c_missed_ack;

endmodule
module PMOD_RTCC(
    input CLK,
    input RST_N,
    
    input mfiState,
    output busy,
    
    inout SCL_1,
    inout SDA_1,
    inout SCL_2,
    inout SDA_2,
    
    output missed_ack
    );

    
    parameter CLK_FREQ = 100000000;
    parameter I2C_CLK_FREQ = 400000;
    
    localparam [6:0] EEPROM_ADDR = 'b1010111;
    localparam [6:0] RTCC_ADDR   = 'b1101111;
    
    localparam RTCC_REG_START = 0;
    localparam SRAM_START = 'h20;
    
    localparam EEPROM_START = 0;
    localparam EEPROM_PROTECTED_START = 'hF0;
    localparam EEPROM_STATUS_ADDR = 'hFF;
    
    wire [6:0] i2c_cmd_address;
    wire [7:0] i2c_data_in, i2c_data_out;
    
    i2c_master rtcc_i2c (
        .clk (CLK),
        .rst (~RST_N),
        

        .cmd_address        (i2c_cmd_address),
        .cmd_start          (i2c_cmd_start),
        .cmd_read           (i2c_cmd_read),
        .cmd_write          (i2c_cmd_write),
        .cmd_write_multiple (i2c_cmd_write_multiple),
        .cmd_stop           (i2c_cmd_stop),
        .cmd_valid          (i2c_cmd_valid),
        .cmd_ready          (i2c_cmd_ready),
        
        .data_in            (i2c_data_in),
        .data_in_valid      (i2c_data_in_valid),
        .data_in_ready      (i2c_data_in_ready),
        .data_in_last       (i2c_data_in_last),
        
        .data_out           (i2c_data_out),
        .data_out_valid     (i2c_data_out_valid),
        .data_out_ready     (i2c_data_out_ready),
        .data_out_last      (i2c_data_out_last),
        

        .scl_i              (i2c_scl_i),
        .scl_o              (i2c_scl_o),
        .scl_t              (i2c_scl_t),
        .sda_i              (i2c_sda_i),
        .sda_o              (i2c_sda_o),
        .sda_t              (i2c_sda_t),
        

        .busy               (i2c_busy),
        .bus_control        (i2c_bus_control),
        .bus_active         (i2c_bus_active),
        .missed_ack         (i2c_missed_ack),
        

        .prescale           (CLK_FREQ / (I2C_CLK_FREQ * 4)),
        .stop_on_idle       (1)
    );
    
    assign i2c_scl_i = SCL_1;
    assign SCL_1 = i2c_scl_t ? 1'bz : i2c_scl_o;
    assign SCL_2 = i2c_scl_t ? 1'bz : i2c_scl_o;
    assign i2c_sda_i = SDA_1;
    assign SDA_1 = i2c_sda_t ? 1'bz : i2c_sda_o;
    assign SDA_2 = i2c_sda_t ? 1'bz : i2c_sda_o;

    reg mfiState_prev;
    
    reg [6:0] dev_addr;
    reg [7:0] reg_addr;
    reg [7:0] reg_data;

    reg start;

    always @(posedge CLK) begin
        mfiState_prev <= mfiState;
    end

    always @(posedge CLK) begin
        if (!RST_N) begin
            start <= 0;
            dev_addr <= 0;
            reg_addr <= 0;
            reg_data <= 0;
        end
        else begin
            if (mfiState != mfiState_prev && !busy) begin
                start <= 1;
                
                if (mfiState) begin
                    dev_addr <= RTCC_ADDR;
                    reg_addr <= 'h07;
                    reg_data <= 'b10001000;
                end
                else begin
                    dev_addr <= RTCC_ADDR;
                    reg_addr <= 'h07;
                    reg_data <= 'b00001000;
                end
            end
            else begin
                start <= 0;
            end
        end
    end

    wire [6:0]  cmd_address;
    wire        cmd_start;
    wire        cmd_read;
    wire        cmd_write;
    wire        cmd_write_multiple;
    wire        cmd_stop;
    wire        cmd_valid;
    wire        cmd_ready;

    wire [7:0]  data_out;
    wire        data_out_valid;
    wire        data_out_ready;
    wire        data_out_last;
    
    PMOD_RTCC_Op rtcc_op (
        .clk     (CLK),
        .rst     (!RST_N),
        
        .dev_addr           (dev_addr),
        .reg_addr           (reg_addr),
        .reg_data           (reg_data),
        
        .cmd_address        (cmd_address),
        .cmd_start          (cmd_start),
        .cmd_read           (cmd_read),
        .cmd_write          (cmd_write),
        .cmd_write_multiple (cmd_write_multiple),
        .cmd_stop           (cmd_stop),
        .cmd_valid          (cmd_valid),
        .cmd_ready          (cmd_ready),
        
        .data_out           (data_out),
        .data_out_valid     (data_out_valid),
        .data_out_ready     (data_out_ready),
        .data_out_last      (data_out_last),

        .busy               (busy),
        .start              (start)
        );

    assign i2c_cmd_address         = busy ? cmd_address        : 0;
    assign i2c_cmd_start           = busy ? cmd_start          : 0;
    assign i2c_cmd_read            = busy ? cmd_read           : 0;
    assign i2c_cmd_write           = busy ? cmd_write          : 0;
    assign i2c_cmd_write_multiple  = busy ? cmd_write_multiple : 0;
    assign i2c_cmd_stop            = busy ? cmd_stop           : 0;
    assign i2c_cmd_valid           = busy ? cmd_valid          : 0;

    assign cmd_ready               = i2c_cmd_ready;

    assign i2c_data_in             = busy ? data_out       : 0;
    assign i2c_data_in_valid       = busy ? data_out_valid : 0;

    assign data_out_ready          = i2c_data_in_ready;

    assign i2c_data_in_last        = busy ? data_out_last : 0;
                                     
    assign missed_ack = i2c_missed_ack;

endmodule