160 lines
3.7 KiB
Systemverilog
160 lines
3.7 KiB
Systemverilog
// Copyright lowRISC contributors.
|
|
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
// Register Package auto-generated by `reggen` containing data structure
|
|
|
|
package i2c_reg_pkg;
|
|
|
|
// Address widths within the block
|
|
parameter int BlockAw = 4;
|
|
|
|
////////////////////////////
|
|
// Typedefs for registers //
|
|
////////////////////////////
|
|
|
|
typedef struct packed {
|
|
struct packed {
|
|
logic q;
|
|
logic qe;
|
|
} start;
|
|
struct packed {
|
|
logic q;
|
|
logic qe;
|
|
} int_en;
|
|
struct packed {
|
|
logic q;
|
|
logic qe;
|
|
} int_pending;
|
|
struct packed {
|
|
logic q;
|
|
logic qe;
|
|
} mode;
|
|
struct packed {
|
|
logic q;
|
|
logic qe;
|
|
} write;
|
|
struct packed {
|
|
logic q;
|
|
logic qe;
|
|
} ack;
|
|
struct packed {
|
|
logic q;
|
|
logic qe;
|
|
} error;
|
|
struct packed {
|
|
logic [15:0] q;
|
|
logic qe;
|
|
} clk_div;
|
|
} i2c_reg2hw_ctrl_reg_t;
|
|
|
|
typedef struct packed {
|
|
struct packed {
|
|
logic [7:0] q;
|
|
} address;
|
|
struct packed {
|
|
logic [7:0] q;
|
|
} regreg;
|
|
struct packed {
|
|
logic [7:0] q;
|
|
} data;
|
|
} i2c_reg2hw_master_data_reg_t;
|
|
|
|
typedef struct packed {
|
|
logic [7:0] q;
|
|
logic re;
|
|
} i2c_reg2hw_slave_data_reg_t;
|
|
|
|
typedef struct packed {
|
|
struct packed {
|
|
logic d;
|
|
logic de;
|
|
} start;
|
|
struct packed {
|
|
logic d;
|
|
logic de;
|
|
} int_en;
|
|
struct packed {
|
|
logic d;
|
|
logic de;
|
|
} int_pending;
|
|
struct packed {
|
|
logic d;
|
|
logic de;
|
|
} mode;
|
|
struct packed {
|
|
logic d;
|
|
logic de;
|
|
} write;
|
|
struct packed {
|
|
logic d;
|
|
logic de;
|
|
} ack;
|
|
struct packed {
|
|
logic d;
|
|
logic de;
|
|
} error;
|
|
struct packed {
|
|
logic [15:0] d;
|
|
logic de;
|
|
} clk_div;
|
|
} i2c_hw2reg_ctrl_reg_t;
|
|
|
|
typedef struct packed {
|
|
struct packed {
|
|
logic [7:0] d;
|
|
logic de;
|
|
} address;
|
|
struct packed {
|
|
logic [7:0] d;
|
|
logic de;
|
|
} regreg;
|
|
struct packed {
|
|
logic [7:0] d;
|
|
logic de;
|
|
} data;
|
|
} i2c_hw2reg_master_data_reg_t;
|
|
|
|
typedef struct packed {
|
|
logic [7:0] d;
|
|
} i2c_hw2reg_slave_data_reg_t;
|
|
|
|
// Register -> HW type
|
|
typedef struct packed {
|
|
i2c_reg2hw_ctrl_reg_t ctrl; // [63:33]
|
|
i2c_reg2hw_master_data_reg_t master_data; // [32:9]
|
|
i2c_reg2hw_slave_data_reg_t slave_data; // [8:0]
|
|
} i2c_reg2hw_t;
|
|
|
|
// HW -> register type
|
|
typedef struct packed {
|
|
i2c_hw2reg_ctrl_reg_t ctrl; // [65:35]
|
|
i2c_hw2reg_master_data_reg_t master_data; // [34:8]
|
|
i2c_hw2reg_slave_data_reg_t slave_data; // [7:0]
|
|
} i2c_hw2reg_t;
|
|
|
|
// Register offsets
|
|
parameter logic [BlockAw-1:0] I2C_CTRL_OFFSET = 4'h0;
|
|
parameter logic [BlockAw-1:0] I2C_MASTER_DATA_OFFSET = 4'h4;
|
|
parameter logic [BlockAw-1:0] I2C_SLAVE_DATA_OFFSET = 4'h8;
|
|
|
|
// Reset values for hwext registers and their fields
|
|
parameter logic [7:0] I2C_SLAVE_DATA_RESVAL = 8'h0;
|
|
|
|
// Register index
|
|
typedef enum int {
|
|
I2C_CTRL,
|
|
I2C_MASTER_DATA,
|
|
I2C_SLAVE_DATA
|
|
} i2c_id_e;
|
|
|
|
// Register width information to check illegal writes
|
|
parameter logic [3:0] I2C_PERMIT [3] = '{
|
|
4'b1111, // index[0] I2C_CTRL
|
|
4'b0111, // index[1] I2C_MASTER_DATA
|
|
4'b0001 // index[2] I2C_SLAVE_DATA
|
|
};
|
|
|
|
endpackage
|
|
|