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

266 lines
11 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 Frontend(
input clock,
reset,
auto_icache_master_out_a_ready,
output auto_icache_master_out_a_valid,
output [31:0] auto_icache_master_out_a_bits_address,
output auto_icache_master_out_a_bits_user_amba_prot_readalloc,
auto_icache_master_out_a_bits_user_amba_prot_writealloc,
input auto_icache_master_out_d_valid,
input [2:0] auto_icache_master_out_d_bits_opcode,
input [3:0] auto_icache_master_out_d_bits_size,
input [63:0] auto_icache_master_out_d_bits_data,
input auto_icache_master_out_d_bits_corrupt,
io_cpu_might_request,
io_cpu_req_valid,
input [33:0] io_cpu_req_bits_pc,
input io_cpu_req_bits_speculative,
io_cpu_resp_ready,
output io_cpu_resp_valid,
output [33:0] io_cpu_resp_bits_pc,
output [31:0] io_cpu_resp_bits_data,
output io_cpu_resp_bits_xcpt_pf_inst,
io_cpu_resp_bits_xcpt_gf_inst,
io_cpu_resp_bits_xcpt_ae_inst,
io_cpu_resp_bits_replay,
input io_cpu_btb_update_valid,
io_cpu_bht_update_valid,
io_cpu_flush_icache,
io_ptw_status_debug,
io_ptw_pmp_0_cfg_l,
input [1:0] io_ptw_pmp_0_cfg_a,
input io_ptw_pmp_0_cfg_x,
input [29:0] io_ptw_pmp_0_addr,
input [31:0] io_ptw_pmp_0_mask,
input io_ptw_pmp_1_cfg_l,
input [1:0] io_ptw_pmp_1_cfg_a,
input io_ptw_pmp_1_cfg_x,
input [29:0] io_ptw_pmp_1_addr,
input [31:0] io_ptw_pmp_1_mask,
input io_ptw_pmp_2_cfg_l,
input [1:0] io_ptw_pmp_2_cfg_a,
input io_ptw_pmp_2_cfg_x,
input [29:0] io_ptw_pmp_2_addr,
input [31:0] io_ptw_pmp_2_mask,
input io_ptw_pmp_3_cfg_l,
input [1:0] io_ptw_pmp_3_cfg_a,
input io_ptw_pmp_3_cfg_x,
input [29:0] io_ptw_pmp_3_addr,
input [31:0] io_ptw_pmp_3_mask,
input io_ptw_pmp_4_cfg_l,
input [1:0] io_ptw_pmp_4_cfg_a,
input io_ptw_pmp_4_cfg_x,
input [29:0] io_ptw_pmp_4_addr,
input [31:0] io_ptw_pmp_4_mask,
input io_ptw_pmp_5_cfg_l,
input [1:0] io_ptw_pmp_5_cfg_a,
input io_ptw_pmp_5_cfg_x,
input [29:0] io_ptw_pmp_5_addr,
input [31:0] io_ptw_pmp_5_mask,
input io_ptw_pmp_6_cfg_l,
input [1:0] io_ptw_pmp_6_cfg_a,
input io_ptw_pmp_6_cfg_x,
input [29:0] io_ptw_pmp_6_addr,
input [31:0] io_ptw_pmp_6_mask,
input io_ptw_pmp_7_cfg_l,
input [1:0] io_ptw_pmp_7_cfg_a,
input io_ptw_pmp_7_cfg_x,
input [29:0] io_ptw_pmp_7_addr,
input [31:0] io_ptw_pmp_7_mask,
input [63:0] io_ptw_customCSRs_csrs_0_value
);
wire [32:0] _io_cpu_npc_T;
wire fq_io_enq_valid;
wire [31:0] _tlb_io_resp_paddr;
wire _tlb_io_resp_pf_inst;
wire _tlb_io_resp_ae_inst;
wire _tlb_io_resp_cacheable;
wire _fq_io_enq_ready;
wire [4:0] _fq_io_mask;
wire _icache_io_resp_valid;
wire [31:0] _icache_io_resp_bits_data;
wire _icache_io_resp_bits_ae;
wire _GEN =
~(io_cpu_req_valid | io_cpu_flush_icache | io_cpu_bht_update_valid
| io_cpu_btb_update_valid) | io_cpu_might_request;
reg s1_valid;
reg s2_valid;
wire s0_valid =
io_cpu_req_valid | ~(_fq_io_mask[2]) | ~(_fq_io_mask[3]) & (~s1_valid | ~s2_valid)
| ~(_fq_io_mask[4]) & ~s1_valid & ~s2_valid;
reg [33:0] s1_pc;
reg s1_speculative;
reg [33:0] s2_pc;
reg s2_tlb_resp_pf_inst;
reg s2_tlb_resp_ae_inst;
reg s2_tlb_resp_cacheable;
wire _s2_xcpt_T = s2_tlb_resp_ae_inst | s2_tlb_resp_pf_inst;
reg s2_speculative;
wire [33:0] _ntpc_T = {s1_pc[33:2], 2'h0} + 34'h4;
reg s2_replay_REG;
wire s2_replay =
s2_valid & ~(_fq_io_enq_ready & fq_io_enq_valid) | s2_replay_REG;
wire icache_io_s2_kill =
s2_speculative & ~(s2_tlb_resp_cacheable & ~(io_ptw_customCSRs_csrs_0_value[3]))
| _s2_xcpt_T;
reg fq_io_enq_valid_REG;
assign fq_io_enq_valid =
fq_io_enq_valid_REG & s2_valid & (_icache_io_resp_valid | icache_io_s2_kill);
assign _io_cpu_npc_T =
io_cpu_req_valid ? io_cpu_req_bits_pc[33:1] : s2_replay ? s2_pc[33:1] : _ntpc_T[33:1];
wire _GEN_0 =
s2_speculative & io_ptw_customCSRs_csrs_0_value[3] & ~icache_io_s2_kill;
`ifndef SYNTHESIS
always @(posedge clock) begin
if ((`PRINTF_COND_) & ~reset & ~_GEN)
$fwrite(32'h80000002,
"Assertion failed\n at Frontend.scala:96 assert(!(io.cpu.req.valid || io.cpu.sfence.valid || io.cpu.flush_icache || io.cpu.bht_update.valid || io.cpu.btb_update.valid) || io.cpu.might_request)\n");
if ((`PRINTF_COND_) & ~reset & _GEN_0)
$fwrite(32'h80000002,
"Assertion failed\n at Frontend.scala:194 assert(!(s2_speculative && io.ptw.customCSRs.asInstanceOf[RocketCustomCSRs].disableSpeculativeICacheRefill && !icache.io.s2_kill))\n");
end // always @(posedge)
`endif // not def SYNTHESIS
always @(posedge clock) begin
if (~reset) begin
end
s1_valid <= s0_valid;
s1_pc <= {_io_cpu_npc_T, 1'h0};
s1_speculative <=
io_cpu_req_valid
? io_cpu_req_bits_speculative
: s2_replay ? s2_speculative : s1_speculative | s2_valid & ~s2_speculative;
if (~s2_replay) begin
s2_tlb_resp_pf_inst <= _tlb_io_resp_pf_inst;
s2_tlb_resp_ae_inst <= _tlb_io_resp_ae_inst;
s2_tlb_resp_cacheable <= _tlb_io_resp_cacheable;
end
fq_io_enq_valid_REG <= s1_valid;
if (reset) begin
s2_valid <= 1'h0;
s2_pc <= 34'h10000;
s2_speculative <= 1'h0;
s2_replay_REG <= 1'h1;
end
else begin
s2_valid <= ~s2_replay & ~io_cpu_req_valid;
if (~s2_replay) begin
s2_pc <= s1_pc;
s2_speculative <= s1_speculative;
end
s2_replay_REG <= s2_replay & ~s0_valid;
end
end // always @(posedge)
ICache icache (
.clock (clock),
.reset (reset),
.auto_master_out_a_ready (auto_icache_master_out_a_ready),
.auto_master_out_a_valid (auto_icache_master_out_a_valid),
.auto_master_out_a_bits_address
(auto_icache_master_out_a_bits_address),
.auto_master_out_a_bits_user_amba_prot_readalloc
(auto_icache_master_out_a_bits_user_amba_prot_readalloc),
.auto_master_out_a_bits_user_amba_prot_writealloc
(auto_icache_master_out_a_bits_user_amba_prot_writealloc),
.auto_master_out_d_valid (auto_icache_master_out_d_valid),
.auto_master_out_d_bits_opcode
(auto_icache_master_out_d_bits_opcode),
.auto_master_out_d_bits_size
(auto_icache_master_out_d_bits_size),
.auto_master_out_d_bits_data
(auto_icache_master_out_d_bits_data),
.auto_master_out_d_bits_corrupt
(auto_icache_master_out_d_bits_corrupt),
.io_req_valid (s0_valid),
.io_req_bits_addr ({_io_cpu_npc_T[31:0], 1'h0}),
.io_s1_paddr (_tlb_io_resp_paddr),
.io_s1_kill (io_cpu_req_valid | s2_replay),
.io_s2_kill (icache_io_s2_kill),
.io_s2_cacheable (s2_tlb_resp_cacheable),
.io_resp_valid (_icache_io_resp_valid),
.io_resp_bits_data (_icache_io_resp_bits_data),
.io_resp_bits_ae (_icache_io_resp_bits_ae),
.io_invalidate (io_cpu_flush_icache)
);
ShiftQueue fq (
.clock (clock),
.reset (reset | io_cpu_req_valid),
.io_enq_ready (_fq_io_enq_ready),
.io_enq_valid (fq_io_enq_valid),
.io_enq_bits_pc (s2_pc),
.io_enq_bits_data (_icache_io_resp_bits_data),
.io_enq_bits_xcpt_pf_inst (s2_tlb_resp_pf_inst),
.io_enq_bits_xcpt_ae_inst
(_icache_io_resp_valid & _icache_io_resp_bits_ae | s2_tlb_resp_ae_inst),
.io_enq_bits_replay (icache_io_s2_kill & ~_icache_io_resp_valid & ~_s2_xcpt_T),
.io_deq_ready (io_cpu_resp_ready),
.io_deq_valid (io_cpu_resp_valid),
.io_deq_bits_pc (io_cpu_resp_bits_pc),
.io_deq_bits_data (io_cpu_resp_bits_data),
.io_deq_bits_xcpt_pf_inst (io_cpu_resp_bits_xcpt_pf_inst),
.io_deq_bits_xcpt_ae_inst (io_cpu_resp_bits_xcpt_ae_inst),
.io_deq_bits_replay (io_cpu_resp_bits_replay),
.io_mask (_fq_io_mask)
);
ITLB tlb (
.io_req_bits_vaddr (s1_pc),
.io_resp_paddr (_tlb_io_resp_paddr),
.io_resp_pf_inst (_tlb_io_resp_pf_inst),
.io_resp_ae_inst (_tlb_io_resp_ae_inst),
.io_resp_cacheable (_tlb_io_resp_cacheable),
.io_ptw_status_debug (io_ptw_status_debug),
.io_ptw_pmp_0_cfg_l (io_ptw_pmp_0_cfg_l),
.io_ptw_pmp_0_cfg_a (io_ptw_pmp_0_cfg_a),
.io_ptw_pmp_0_cfg_x (io_ptw_pmp_0_cfg_x),
.io_ptw_pmp_0_addr (io_ptw_pmp_0_addr),
.io_ptw_pmp_0_mask (io_ptw_pmp_0_mask),
.io_ptw_pmp_1_cfg_l (io_ptw_pmp_1_cfg_l),
.io_ptw_pmp_1_cfg_a (io_ptw_pmp_1_cfg_a),
.io_ptw_pmp_1_cfg_x (io_ptw_pmp_1_cfg_x),
.io_ptw_pmp_1_addr (io_ptw_pmp_1_addr),
.io_ptw_pmp_1_mask (io_ptw_pmp_1_mask),
.io_ptw_pmp_2_cfg_l (io_ptw_pmp_2_cfg_l),
.io_ptw_pmp_2_cfg_a (io_ptw_pmp_2_cfg_a),
.io_ptw_pmp_2_cfg_x (io_ptw_pmp_2_cfg_x),
.io_ptw_pmp_2_addr (io_ptw_pmp_2_addr),
.io_ptw_pmp_2_mask (io_ptw_pmp_2_mask),
.io_ptw_pmp_3_cfg_l (io_ptw_pmp_3_cfg_l),
.io_ptw_pmp_3_cfg_a (io_ptw_pmp_3_cfg_a),
.io_ptw_pmp_3_cfg_x (io_ptw_pmp_3_cfg_x),
.io_ptw_pmp_3_addr (io_ptw_pmp_3_addr),
.io_ptw_pmp_3_mask (io_ptw_pmp_3_mask),
.io_ptw_pmp_4_cfg_l (io_ptw_pmp_4_cfg_l),
.io_ptw_pmp_4_cfg_a (io_ptw_pmp_4_cfg_a),
.io_ptw_pmp_4_cfg_x (io_ptw_pmp_4_cfg_x),
.io_ptw_pmp_4_addr (io_ptw_pmp_4_addr),
.io_ptw_pmp_4_mask (io_ptw_pmp_4_mask),
.io_ptw_pmp_5_cfg_l (io_ptw_pmp_5_cfg_l),
.io_ptw_pmp_5_cfg_a (io_ptw_pmp_5_cfg_a),
.io_ptw_pmp_5_cfg_x (io_ptw_pmp_5_cfg_x),
.io_ptw_pmp_5_addr (io_ptw_pmp_5_addr),
.io_ptw_pmp_5_mask (io_ptw_pmp_5_mask),
.io_ptw_pmp_6_cfg_l (io_ptw_pmp_6_cfg_l),
.io_ptw_pmp_6_cfg_a (io_ptw_pmp_6_cfg_a),
.io_ptw_pmp_6_cfg_x (io_ptw_pmp_6_cfg_x),
.io_ptw_pmp_6_addr (io_ptw_pmp_6_addr),
.io_ptw_pmp_6_mask (io_ptw_pmp_6_mask),
.io_ptw_pmp_7_cfg_l (io_ptw_pmp_7_cfg_l),
.io_ptw_pmp_7_cfg_a (io_ptw_pmp_7_cfg_a),
.io_ptw_pmp_7_cfg_x (io_ptw_pmp_7_cfg_x),
.io_ptw_pmp_7_addr (io_ptw_pmp_7_addr),
.io_ptw_pmp_7_mask (io_ptw_pmp_7_mask)
);
assign io_cpu_resp_bits_xcpt_gf_inst = 1'h0;
endmodule