opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[regtool] Need reg_we, reg_wdata, reg_re, reg_rdata in <>_reg_pkg.sv for hwext implementaion

Open Jacob-Levy opened this issue 5 years ago • 5 comments

@arnonsha @zi-v @msfschaffner @tjaychen

In order to simplify a register function in the hwext, I need to be able to access the reg_we & reg_wdata that are implemenated in <>_reg_top.sv by tlul_adapter_reg

. . .
  tlul_adapter_reg #(
    .RegAw(AW),
    .RegDw(DW)
  ) u_reg_if (
    .clk_i,
    .rst_ni,

    .tl_i (tl_reg_h2d),
    .tl_o (tl_reg_d2h),

    .we_o    (reg_we),
    .re_o    (reg_re),
    .addr_o  (reg_addr),
    .wdata_o (reg_wdata),
    .be_o    (reg_be),
    .rdata_i (reg_rdata),
    .error_i (reg_error)
  );

  assign reg2hw.reg_if.reg_we    = reg_we; 
  assign reg2hw.reg_if.reg_re    = reg_re; 
  assign reg2hw.reg_if.reg_addr  = reg_addr; 
  assign reg2hw.reg_if.reg_wdata = reg_wdata; 
  assign reg2hw.reg_if.reg_be    = reg_be; 
  assign reg2hw.reg_if.reg_rdata = reg_rdata; 
  assign reg2hw.reg_if.reg_error = reg_error;
. . .

Can a pack struct that include the reg i/f be added to the <>_reg_pkg.sv And then added to the <>_reg2hw_t struct

, , ,
typedef struct packed {
  logic         reg_we;
  logic         reg_re;
  logic [9:0]   reg_addr;
  logic [31:0]  reg_wdata;
  logic [3:0]   reg_be;
  logic [31:0]  reg_rdata;
  logic         reg_error;
} ast_reg2hw_reg_if_t;

  // Register -> HW type
  typedef struct packed {
    ast_reg2hw_reg_if_t reg_if;   // [770:690]
    ast_reg2hw_revid_reg_t revid; // [689:681]
    . . .
    ast_reg2hw_cacns_reg_t cacns; // [33:0]
  } ast_reg2hw_t;
. . .

I've made the above changes manualy in <>_reg_top.sv and <>_reg_pkg.sv and they works fine.

Regards, Jacob

Jacob-Levy avatar Jun 02 '21 14:06 Jacob-Levy

Are you just trying to handle writes to a hwext register? If so, I suggest you take a look at the AES block. For example, its CTRL_SHADOWED register is a hwext register that is writable from software. Or is there something else you're trying to achieve?

rswarbrick avatar Jun 08 '21 09:06 rswarbrick

I do more then that and I can not elaborate since it is part of a security feature. All I need is a acsess to the "raw" reg i/f of the TLUL..

Jacob-Levy avatar Jun 08 '21 09:06 Jacob-Levy

If you're doing something custom, maybe it's easier to instantiate another tlul_adapter_reg outside of the reg top block? I suspect much of the repeated stuff will be synthesized away anyway.

rswarbrick avatar Jun 08 '21 10:06 rswarbrick

Can we discuss on meet? slack?

Jacob-Levy avatar Jun 08 '21 11:06 Jacob-Levy

Now I understand, thanks! The plan: we add a flag to the block-level hjson. If that flag is set, the reg pkg defines <block>_reg2hw_reg_if_t like in your example and adds it to the reg2hw structure. That'll give your block access to the interface signals without needing to duplicate the TLUL adapter (which might be an FI issue). By default, the flag will be turned off, which avoids every other block needing a lint waiver for the stuff that it doesn't care about.

rswarbrick avatar Jun 08 '21 11:06 rswarbrick