Files
gps/hardware/generated/genesys2-soc-verilog/IBuf.sv
T
2026-08-06 22:14:52 +03:00

133 lines
5.2 KiB
Systemverilog

// Generated by CIRCT firtool-1.151.0
// Users can define 'PRINTF_COND' to add an extra gate to prints.
`ifndef PRINTF_COND_
`ifdef PRINTF_COND
`define PRINTF_COND_ (`PRINTF_COND)
`else // PRINTF_COND
`define PRINTF_COND_ 1
`endif // PRINTF_COND
`endif // not def PRINTF_COND_
module IBuf(
input clock,
reset,
output io_imem_ready,
input io_imem_valid,
input [33:0] io_imem_bits_pc,
input [31:0] io_imem_bits_data,
input io_imem_bits_xcpt_pf_inst,
io_imem_bits_xcpt_gf_inst,
io_imem_bits_xcpt_ae_inst,
io_imem_bits_replay,
io_kill,
output [33:0] io_pc,
input io_inst_0_ready,
output io_inst_0_valid,
io_inst_0_bits_xcpt0_pf_inst,
io_inst_0_bits_xcpt0_gf_inst,
io_inst_0_bits_xcpt0_ae_inst,
io_inst_0_bits_xcpt1_pf_inst,
io_inst_0_bits_xcpt1_gf_inst,
io_inst_0_bits_xcpt1_ae_inst,
io_inst_0_bits_replay,
io_inst_0_bits_rvc,
output [31:0] io_inst_0_bits_inst_bits,
output [4:0] io_inst_0_bits_inst_rd,
io_inst_0_bits_inst_rs1,
io_inst_0_bits_inst_rs2,
io_inst_0_bits_inst_rs3,
output [31:0] io_inst_0_bits_raw
);
wire [1:0] nReady;
wire _exp_io_rvc;
reg nBufValid;
reg [33:0] buf_pc;
reg [31:0] buf_data;
reg buf_xcpt_pf_inst;
reg buf_xcpt_gf_inst;
reg buf_xcpt_ae_inst;
reg buf_replay;
wire [1:0] _GEN = {1'h0, io_imem_bits_pc[1]};
wire [1:0] _nIC_T_2 = 2'h2 - _GEN;
wire [1:0] _GEN_0 = {1'h0, nBufValid};
wire [1:0] _nICReady_T = nReady - _GEN_0;
wire _nBufValid_T = nReady >= _GEN_0;
wire [1:0] _nBufValid_T_6 = _nIC_T_2 - _nICReady_T;
wire [190:0] _icData_T_4 =
{63'h0,
{4{io_imem_bits_data[31:16]}},
io_imem_bits_data,
{2{io_imem_bits_data[15:0]}}} << {185'h0, _GEN_0 - 2'h2 - _GEN, 4'h0};
wire [62:0] _icMask_T_2 = 63'hFFFFFFFF << {58'h0, nBufValid, 4'h0};
wire [31:0] inst =
_icData_T_4[95:64] & _icMask_T_2[31:0] | buf_data & ~(_icMask_T_2[31:0]);
wire [3:0] _valid_T = 4'h1 << (io_imem_valid ? _nIC_T_2 : 2'h0) + _GEN_0;
wire [1:0] _valid_T_1 = _valid_T[1:0] - 2'h1;
wire [1:0] _bufMask_T_1 = (2'h1 << _GEN_0) - 2'h1;
wire [1:0] buf_replay_0 = buf_replay ? _bufMask_T_1 : 2'h0;
wire [1:0] ic_replay =
buf_replay_0 | (io_imem_bits_replay ? _valid_T_1 & ~_bufMask_T_1 : 2'h0);
wire full_insn = _exp_io_rvc | _valid_T_1[1] | buf_replay_0[0];
wire [2:0] _io_inst_0_bits_xcpt1_WIRE_1 =
_exp_io_rvc
? 3'h0
: {_bufMask_T_1[1] ? buf_xcpt_pf_inst : io_imem_bits_xcpt_pf_inst,
_bufMask_T_1[1] ? buf_xcpt_gf_inst : io_imem_bits_xcpt_gf_inst,
_bufMask_T_1[1] ? buf_xcpt_ae_inst : io_imem_bits_xcpt_ae_inst};
assign nReady = full_insn ? (_exp_io_rvc ? 2'h1 : 2'h2) : 2'h0;
always @(posedge clock) begin
automatic logic _GEN_1;
_GEN_1 = io_imem_valid & _nBufValid_T & _nICReady_T < _nIC_T_2 & ~(_nBufValid_T_6[1]);
if (reset)
nBufValid <= 1'h0;
else
nBufValid <=
~io_kill
& (io_inst_0_ready
? (_GEN_1
? _nBufValid_T_6[0]
: ~(_nBufValid_T | ~nBufValid) & nBufValid - nReady[0])
: nBufValid);
if (io_inst_0_ready & _GEN_1) begin
automatic logic [63:0] _buf_data_T_1 =
{{2{io_imem_bits_data[31:16]}}, io_imem_bits_data}
>> {58'h0, _GEN + _nICReady_T, 4'h0};
buf_pc <=
{io_imem_bits_pc[33:2], 2'h0}
| {32'h0, io_imem_bits_pc[1:0] + {_nICReady_T[0], 1'h0}};
buf_data <= {16'h0, _buf_data_T_1[15:0]};
buf_xcpt_pf_inst <= io_imem_bits_xcpt_pf_inst;
buf_xcpt_gf_inst <= io_imem_bits_xcpt_gf_inst;
buf_xcpt_ae_inst <= io_imem_bits_xcpt_ae_inst;
buf_replay <= io_imem_bits_replay;
end
end // always @(posedge)
RVCExpander exp (
.io_in (inst),
.io_out_bits (io_inst_0_bits_inst_bits),
.io_out_rd (io_inst_0_bits_inst_rd),
.io_out_rs1 (io_inst_0_bits_inst_rs1),
.io_out_rs2 (io_inst_0_bits_inst_rs2),
.io_out_rs3 (io_inst_0_bits_inst_rs3),
.io_rvc (_exp_io_rvc)
);
assign io_imem_ready =
io_inst_0_ready & _nBufValid_T & (_nICReady_T >= _nIC_T_2 | ~(_nBufValid_T_6[1]));
assign io_pc = nBufValid ? buf_pc : io_imem_bits_pc;
assign io_inst_0_valid = _valid_T_1[0] & full_insn;
assign io_inst_0_bits_xcpt0_pf_inst =
_bufMask_T_1[0] ? buf_xcpt_pf_inst : io_imem_bits_xcpt_pf_inst;
assign io_inst_0_bits_xcpt0_gf_inst =
_bufMask_T_1[0] ? buf_xcpt_gf_inst : io_imem_bits_xcpt_gf_inst;
assign io_inst_0_bits_xcpt0_ae_inst =
_bufMask_T_1[0] ? buf_xcpt_ae_inst : io_imem_bits_xcpt_ae_inst;
assign io_inst_0_bits_xcpt1_pf_inst = _io_inst_0_bits_xcpt1_WIRE_1[2];
assign io_inst_0_bits_xcpt1_gf_inst = _io_inst_0_bits_xcpt1_WIRE_1[1];
assign io_inst_0_bits_xcpt1_ae_inst = _io_inst_0_bits_xcpt1_WIRE_1[0];
assign io_inst_0_bits_replay = ic_replay[0] | ~_exp_io_rvc & ic_replay[1];
assign io_inst_0_bits_rvc = _exp_io_rvc;
assign io_inst_0_bits_raw = inst;
endmodule