接口类型转换
本帖最后由 小南鲸-FPGA 于 2024-11-28 17:58 编辑<p>将sramif模块中的bankA和bankB转换为AXI-Stream接口,应当如何解决这个问题?(求助大佬)</p>
<p> </p>
<p> </p>
<p>module sramif #(</p>
<p> parameter integer NUM_CPUS = 1,</p>
<p> parameter integer AXI_SRAM_ID = 12</p>
<p>)(<br />
// ACE slave interface<br />
(* mark_debug = "true" *) output wire ace_awready_o,<br />
(* mark_debug = "true" *) input wire ace_awvalid_i,<br />
input wire [(AXI_SRAM_ID-1):0] ace_awid_i,<br />
(* mark_debug = "true" *) input wire ace_awaddr_i,<br />
(* mark_debug = "true" *) input wire ace_awlen_i,<br />
(* mark_debug = "true" *) input wire ace_awsize_i,<br />
(* mark_debug = "true" *) input wire ace_awburst_i,<br />
//input wire ace_awbar_i,<br />
//input wire ace_awdomain_i,<br />
input wire ace_awlock_i,<br />
input wire ace_awcache_i,<br />
input wire ace_awprot_i,<br />
//input wire ace_awsnoop_i,<br />
//input wire ace_awunique_i,<br />
(* mark_debug = "true" *) output wire ace_wready_o,<br />
(* mark_debug = "true" *) input wire ace_wvalid_i,<br />
//input wire ace_wid_i,<br />
(* mark_debug = "true" *) input wire ace_wdata_i,<br />
(* mark_debug = "true" *) input wire ace_wstrb_i,<br />
(* mark_debug = "true" *) input wire ace_wlast_i,<br />
input wire ace_bready_i,<br />
output wire ace_bvalid_o,<br />
output wire [(AXI_SRAM_ID-1):0] ace_bid_o,<br />
output wire ace_bresp_o,<br />
output wire ace_arready_o,<br />
input wire ace_arvalid_i,<br />
input wire [(AXI_SRAM_ID-1):0] ace_arid_i,<br />
input wire ace_araddr_i,<br />
input wire ace_arlen_i,<br />
input wire ace_arsize_i,<br />
input wire ace_arburst_i,<br />
//input wire ace_arbar_i,<br />
//input wire ace_ardomain_i,<br />
input wire ace_arlock_i,<br />
input wire ace_arcache_i,<br />
input wire ace_arprot_i,<br />
//input wire ace_arsnoop_i,<br />
input wire ace_rready_i,<br />
output wire ace_rvalid_o,<br />
output wire [(AXI_SRAM_ID-1):0] ace_rid_o,<br />
output wire ace_rdata_o,<br />
output wire ace_rresp_o,<br />
output wire ace_rlast_o,</p>
<p> input wire clk,<br />
input wire reset_n,</p>
<p> // npu axi register<br />
input logic fifo_count ,</p>
<p> // npu register interface<br />
output logic sys_addr , // System Interface<br />
output logic sys_wr , // System Interface<br />
output logic sys_wr_val , // System Interface<br />
output logic sys_rd , // System Interface<br />
input sys_ack , // System Interface<br />
input sys_rd_val , // System Interface</p>
<p> // npu data sram interface<br />
output logic bankA_dma_cs ,<br />
output logic bankA_dma_we ,<br />
output logic bankA_dma_addr , <br />
output logic bankA_dma_din , <br />
output logic bankA_dma_byte_en ,<br />
input bankA_dma_dout , <br />
output logic bankB_dma_cs ,<br />
output logic bankB_dma_we ,<br />
output logic bankB_dma_addr , <br />
output logic bankB_dma_din , <br />
output logic bankB_dma_byte_en ,<br />
input bankB_dma_dout ,<br />
// npu lut sram<br />
output logic dma_lut_cs ,<br />
output logic dma_lut_we ,<br />
output logic dma_lut_addr ,<br />
output logic dma_lut_din ,<br />
output logic dma_lut_byte_en ,<br />
input dma_lut_dout ,</p>
<p> // Command manager interface<br />
output logic cmd_cs ,<br />
output logic cmd_we ,<br />
output logic cmd_addr ,<br />
input logic cmd_out ,<br />
output logic cmd <br />
/*<br />
input wire bist_mode ,<br />
// clk / rst_n <br />
input wire i_apb_clk ,</p>
<p> // apb port <br />
input wire i_psel ,<br />
input wire i_paddr ,<br />
input wire i_penable ,<br />
input wire i_pwrite ,<br />
input wire i_pwdata ,<br />
output wire o_prdata ,<br />
output wire npum_ctrl , //default:0<br />
output wire npum_ramclk */<br />
);</p>
<p> localparam ADDR_WIDTH = 32;<br />
//----------------------------------------------------------------------------<br />
// Signal declarations<br />
//----------------------------------------------------------------------------<br />
//reg ace_rready_i_tmp;<br />
//always@(posedge clk)begin<br />
// ace_rready_i_tmp <= ace_rready_i;<br />
//end<br />
logic len_addr_count;<br />
logic len_addr_count_d1;</p>
<p> // Read/write arbitration<br />
reg write_sel;<br />
wire nxt_write_sel;<br />
wire write_sel_we;</p>
<p> // Unpacked address/control<br />
wire [(ADDR_WIDTH-1):0] unpk_wr_addr;<br />
wire unpk_wr_last;<br />
wire unpk_wr_valid;<br />
wire unpk_wr_ready;<br />
wire [(ADDR_WIDTH-1):0] unpk_rd_addr;<br />
wire unpk_rd_last;<br />
wire unpk_rd_valid;<br />
wire unpk_rd_ready;<br />
reg unpk_rd_valid_d1;<br />
reg unpk_rd_last_d1;<br />
reg unpk_rd_last_d2;</p>
<p> // ACE signals<br />
wire ace_awready;<br />
wire ace_arready;<br />
reg [(AXI_SRAM_ID-1):0] ace_arid_reg;<br />
reg [(AXI_SRAM_ID-1):0] ace_arid_d2;<br />
wire ace_arid_reg_we;<br />
reg [(AXI_SRAM_ID-1):0] ace_rid;<br />
wire ace_rid_we;<br />
reg [(AXI_SRAM_ID-1):0] ace_bid;<br />
wire ace_bid_we;<br />
reg ace_wready;<br />
wire nxt_ace_wready;<br />
reg ace_bvalid;<br />
wire nxt_ace_bvalid;<br />
wire ace_bresp;<br />
reg ace_rdata;<br />
reg ace_rvalid;<br />
wire nxt_ace_rvalid;<br />
reg ace_rlast;<br />
reg ace_rlast_temp;<br />
wire ace_rresp;</p>
<p> // Validation read/write<br />
wire val_read;<br />
reg val_read_d1; // read data delay one cycle<br />
reg val_read_d2; // read data delay two cycle<br />
wire val_rd_data; // Read data<br />
wire val_rd_data_big; // Read data<br />
wire val_write;<br />
wire val_rd_ongoing;<br />
reg val_rd_ongoing_reg;</p>
<p> logic unpk_wr_valid_d1;<br />
logic unpk_wr_valid_d2;<br />
logic preproc_valid;<br />
logic pre_type;<br />
logic bvalid_delay;<br />
logic ace_wvalid_d1;<br />
logic wstart;<br />
<br />
logic empty;<br />
logic empty_b1;<br />
logic almost_empty;<br />
/*<br />
//apb signals<br />
wire o_sw_SLEEP_P0;<br />
wire o_sw_SLEEP_P1;<br />
wire o_sw_SLEEP_P2;<br />
wire o_sw_SLEEP_P3;<br />
wire o_sw_SLEEP_P4;<br />
wire o_sw_SLEEP_P5;<br />
wire o_sw_SLEEP_P6;<br />
wire o_sw_SLEEP_P7;<br />
wire o_sw_SLEEP_P8;<br />
wire o_sw_SLEEP_P9;<br />
wire o_sw_SLEEP_P10;<br />
wire o_sw_SLEEP_P11;<br />
wire o_sw_SLEEP_P12;<br />
wire o_sw_SLEEP_P13;<br />
wire o_sw_SLEEP_P14;<br />
wire o_sw_SLEEP_P15;</p>
<p><br />
apb_reg_memctl u_apb_reg_memctl<br />
(<br />
.i_clk (i_apb_clk ),<br />
.i_rst_n (reset_n ),<br />
.i_psel (i_psel ),<br />
.i_paddr (i_paddr ),<br />
.i_penable (i_penable ),<br />
.i_pwrite (i_pwrite ),<br />
.i_pwdata (i_pwdata ),<br />
.o_prdata (o_prdata ),<br />
.o_sw_SLEEP_P0 (o_sw_SLEEP_P0 ),<br />
.o_sw_SLEEP_P1 (o_sw_SLEEP_P1 ),<br />
.o_sw_SLEEP_P2 (o_sw_SLEEP_P2 ),<br />
.o_sw_SLEEP_P3 (o_sw_SLEEP_P3 ),<br />
.o_sw_SLEEP_P4 (o_sw_SLEEP_P4 ),<br />
.o_sw_SLEEP_P5 (o_sw_SLEEP_P5 ),<br />
.o_sw_SLEEP_P6 (o_sw_SLEEP_P6 ),<br />
.o_sw_SLEEP_P7 (o_sw_SLEEP_P7 ),<br />
.o_sw_SLEEP_P8 (o_sw_SLEEP_P8 ),<br />
.o_sw_SLEEP_P9 (o_sw_SLEEP_P9 ),<br />
.o_sw_SLEEP_P10(o_sw_SLEEP_P10),<br />
.o_sw_SLEEP_P11(o_sw_SLEEP_P11),<br />
.o_sw_SLEEP_P12(o_sw_SLEEP_P12),<br />
.o_sw_SLEEP_P13(o_sw_SLEEP_P13),<br />
.o_sw_SLEEP_P14(o_sw_SLEEP_P14),<br />
.o_sw_SLEEP_P15(o_sw_SLEEP_P15),<br />
.o_sw_NPUM_CTRL(npum_ctrl ) <br />
);</p>
<p> //----------------------------------------------------------------------------<br />
//Power Down Mode<br />
//----------------------------------------------------------------------------<br />
ca53_cell_clkgate clkgate_ram_clk0 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P0 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk1 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P1 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk2 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P2 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk3 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P3 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk4 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P4 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk5 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P5 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk6 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P6 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk7 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P7 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk8 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P8 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk9 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P9 ), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk10 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P10), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk11 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P11), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk12 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P12), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk13 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P13), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk14 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P14), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
ca53_cell_clkgate clkgate_ram_clk15 (.clk_i(clk),.clk_enable_i(!o_sw_SLEEP_P15), .clk_senable_i(bist_mode),.clk_gated_o(npum_ramclk));<br />
*/<br />
//----------------------------------------------------------------------------<br />
// ACE address unpacking<br />
//<br />
// An ACE read/write request can specify a burst while only providing the<br />
// address for the first transfer in the burst. To access the validation<br />
// memory resources these 'packed' addresses are unpacked into a series of<br />
// requests, each providing the full address.<br />
//----------------------------------------------------------------------------</p>
<p> // Write channel<br />
execution_tb_ace_intf_addr_unpack #(.ADDR_WIDTH(ADDR_WIDTH))<br />
u_execution_tb_ace_intf_addr_unpack_wr<br />
(// Clocks and resets<br />
.clk (clk),<br />
.reset_n (reset_n),</p>
<p> // ACE write address channel<br />
.ace_axaddr_i (ace_awaddr_i),<br />
.ace_axburst_i (ace_awburst_i),<br />
.ace_axsize_i (ace_awsize_i),<br />
.ace_axlen_i (ace_awlen_i),<br />
.ace_axprot_i (ace_awprot_i),<br />
.ace_axvalid_i (ace_awvalid_i),<br />
.ace_axready_o (ace_awready),</p>
<p> .len_addr_count (len_addr_count),</p>
<p> // Unpacked write address/control<br />
.unpk_addr_o (unpk_wr_addr),<br />
.unpk_last_o (unpk_wr_last),<br />
.unpk_valid_o (unpk_wr_valid),<br />
.unpk_ready_i (unpk_wr_ready)<br />
);<br />
// The ACE write address channel is stalled until the ACE write channel<br />
// provides data on a completed W channel handshake.<br />
//<br />
// However, for the last beat of the burst the stall is extended until the end<br />
// of the ACE write response channel handshake. This is required so that no<br />
// other requests on the AW channel are started until the current request has<br />
// completely cleared; the address unpacker can only handle a single<br />
// outstanding write.<br />
assign unpk_wr_ready = (ace_wvalid_i & ace_wready & ~unpk_wr_last) |<br />
(ace_bvalid & ace_bready_i);</p>
<p> // Read channel<br />
execution_tb_ace_intf_addr_unpack<br />
u_execution_tb_ace_intf_addr_unpack_rd<br />
(// Clocks and resets<br />
.clk (clk),<br />
.reset_n (reset_n),</p>
<p> // ACE read address channel<br />
.ace_axaddr_i (ace_araddr_i),<br />
.ace_axburst_i (ace_arburst_i),<br />
.ace_axsize_i (ace_arsize_i),<br />
.ace_axlen_i (ace_arlen_i),<br />
.ace_axprot_i (ace_arprot_i),<br />
.ace_axvalid_i (ace_arvalid_i),<br />
.ace_axready_o (ace_arready),</p>
<p> .len_addr_count (),</p>
<p> // Unpacked write address channel<br />
.unpk_addr_o (unpk_rd_addr),<br />
.unpk_last_o (unpk_rd_last),<br />
.unpk_valid_o (unpk_rd_valid),<br />
.unpk_ready_i (unpk_rd_ready)<br />
);</p>
<p> always @ (posedge clk or negedge reset_n)<br />
if(!reset_n)<br />
len_addr_count_d1 <= {8{1'b0}};<br />
else<br />
len_addr_count_d1 <= len_addr_count;</p>
<p><br />
// The ACE read address channel stalls until the read is issued to the<br />
// validation subsystem.<br />
assign unpk_rd_ready = val_read;</p>
<p><br />
//----------------------------------------------------------------------------<br />
// ACE transaction IDs<br />
//----------------------------------------------------------------------------</p>
<p> // ARID register:<br />
// Capture ARID on a completed ACE AR handskake to form the correct ID for<br />
// the read response<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
ace_arid_reg <= {(AXI_SRAM_ID){1'b0}};<br />
else if (ace_arid_reg_we)<br />
ace_arid_reg <= ace_arid_i;</p>
<p> assign ace_arid_reg_we = ace_arready & ace_arvalid_i;<br />
<br />
// read data delay a cycle and rid need delay a cycle<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
ace_arid_d2 <= {(AXI_SRAM_ID){1'b0}};<br />
else<br />
ace_arid_d2 <= ace_arid_reg;<br />
// else if (ace_arid_reg_we)<br />
// //ace_arid_d2 <= ace_arid_i;<br />
// ace_arid_d2 <= ace_arid_reg;</p>
<p> // RID:<br />
// RID will normally be from ace_arid_reg, but because we can accept the<br />
// next AR request while waiting for the previous request's RREADY we have<br />
// to cover this extra window.<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
ace_rid <= {(AXI_SRAM_ID){1'b0}};<br />
else if (ace_rid_we)<br />
ace_rid <= ace_arid_d2;</p>
<p> assign ace_rid_we = unpk_rd_valid_d1 & ~(ace_rlast & ace_rvalid & ~ace_rready_i);<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
unpk_rd_valid_d1 <= 1'b0;<br />
else<br />
unpk_rd_valid_d1 <= unpk_rd_valid;</p>
<p><br />
// BID:<br />
// Takes a copy of AWID when the write address handshake is complete.<br />
// Bits of the ID contains the CPU number of the CPU that made the<br />
// request.<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
ace_bid <= {(AXI_SRAM_ID){1'b0}};<br />
else if (ace_bid_we)<br />
ace_bid <= ace_awid_i;</p>
<p> assign ace_bid_we = ace_awready & ace_awvalid_i;</p>
<p><br />
//----------------------------------------------------------------------------<br />
// Write channel handshake<br />
//<br />
// Once a write address handshake has completed, writes for that transaction<br />
// do not incur any stalls. Therefore WREADY is brought high after a write<br />
// address handshake and stays high until the handshake for the last data<br />
// beat completes and the write response has handshaked.<br />
//<br />
// We must wait for the write response handshake to complete so as not to<br />
// handshake any new write transactions that the processor may have<br />
// presented.<br />
//----------------------------------------------------------------------------</p>
<p> always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
ace_wready <= 1'b0;<br />
else<br />
ace_wready <= nxt_ace_wready;</p>
<p> assign nxt_ace_wready = unpk_wr_valid & preproc_valid & // Ongoing write<br />
~(ace_wvalid_i & ace_wready & ace_wlast_i) & // Not last beat<br />
~ace_bvalid; // Not waiting for BREAD</p>
<p> // unpk_valid delay one cycle for val_write_i<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
unpk_wr_valid_d1 <= 1'b0;<br />
else<br />
unpk_wr_valid_d1 <= unpk_wr_valid;<br />
// unpk_valid delay 2 cycle for val_write_i<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
unpk_wr_valid_d2 <= 1'b0;<br />
else<br />
unpk_wr_valid_d2 <= unpk_wr_valid_d1;</p>
<p> //----------------------------------------------------------------------------<br />
// Write response channel handshake<br />
//<br />
// The write response is driven after the final beat of write data has been<br />
// written (i.e. its write handshake has completed.) BVALID stays high<br />
// until the processor completes the handshake.<br />
//----------------------------------------------------------------------------</p>
<p> always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
ace_bvalid <= 1'b0;<br />
else<br />
ace_bvalid <= nxt_ace_bvalid;</p>
<p> //assign nxt_ace_bvalid = ~bvalid_delay & ((ace_wvalid_i & ace_wready & unpk_wr_last) | ace_bvalid) &<br />
assign nxt_ace_bvalid = ((ace_wvalid_i & ace_wready & unpk_wr_last) | ace_bvalid) &<br />
~(ace_bvalid & ace_bready_i);</p>
<p> assign ace_bresp = 2'b00; // OKAY response</p>
<p><br />
//----------------------------------------------------------------------------<br />
// Read channel data register and handshake<br />
//<br />
// Read data from the validation memory model is registered before being<br />
// sent to the processor.<br />
//<br />
// RVALID is set high at the same time and stays high until the processor<br />
// completes the handshake.<br />
//----------------------------------------------------------------------------</p>
<p>// always @ (posedge clk or negedge reset_n)<br />
// if (!reset_n)<br />
// ace_rdata <= {128{1'b0}};<br />
// else if (val_read_d2)<br />
// ace_rdata <= val_rd_data_big;</p>
<p>sramif_fifo u_sramif_fifo(<br />
.clk (clk ),<br />
.rst_n (reset_n ),<br />
.flush ( 1'b0 ),<br />
.write (val_read_d2 ),<br />
.data_in (val_rd_data_big ),<br />
.read (~empty & ace_rready_i ),<br />
.data_out (ace_rdata ),<br />
.full ( ),<br />
.almost_empty (almost_empty ),<br />
.empty_b1 (empty_b1 ),<br />
.empty (empty )<br />
);</p>
<p>assign val_rd_data_big = {val_rd_data, val_rd_data, val_rd_data, val_rd_data};<br />
assign val_rd_data_big = {val_rd_data, val_rd_data, val_rd_data, val_rd_data};<br />
assign val_rd_data_big = {val_rd_data, val_rd_data, val_rd_data, val_rd_data};<br />
assign val_rd_data_big = {val_rd_data, val_rd_data, val_rd_data, val_rd_data};</p>
<p> // RVALID<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
ace_rvalid <= 1'b0;<br />
else<br />
ace_rvalid <= nxt_ace_rvalid;</p>
<p> assign nxt_ace_rvalid = val_rd_ongoing | (ace_rvalid & ~ace_rready_i);</p>
<p> // Drive RLAST from the unpacked interface when the read is ongoing<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
ace_rlast <= 1'b0;<br />
else if (ace_rvalid & ace_rready_i & ace_rlast)<br />
ace_rlast <= 1'b0;<br />
else if (val_read_d2)<br />
ace_rlast <= unpk_rd_last_d2;</p>
<p> always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
unpk_rd_last_d1 <= 1'b0;<br />
else<br />
unpk_rd_last_d1 <= unpk_rd_last;<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
unpk_rd_last_d2 <= 1'b0;<br />
else<br />
unpk_rd_last_d2 <= unpk_rd_last_d1;</p>
<p> // The validation memories never give an error response<br />
assign ace_rresp = 2'b00; // OKAY response</p>
<p><br />
//----------------------------------------------------------------------------<br />
// Validation read/write valid<br />
//<br />
// A read to the validation memory interface is valid when the address<br />
// unpacker signals a valid read and we are not waiting on RREADY (which<br />
// stalls the next read.)<br />
//<br />
// Since write data is accepted as soon as it is provided by the processor,<br />
// a write to the validation memory interface is valid when there's<br />
// a completed ACE write channel handshake.<br />
//----------------------------------------------------------------------------</p>
<p> assign val_read = unpk_rd_valid & ~(ace_rvalid & ~ace_rready_i);<br />
assign val_write = ace_wvalid_i & ((ace_wready & pre_type != 2'h2) | <br />
(unpk_wr_valid_d1 & pre_type == 2'h2 & (!unpk_wr_valid_d2 || wstart ||<br />
(len_addr_count != len_addr_count_d1 && len_addr_count_d1 != 8'b0))));</p>
<p>// assign val_write = ace_wvalid_i & ((ace_wready & pre_type != 2'h2) | <br />
// (unpk_wr_valid_d1 & pre_type == 2'h2 & (!unpk_wr_valid_d2 || <br />
// (len_addr_count != len_addr_count_d1 && len_addr_count_d1 != 8'b0))));</p>
<p> always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
wstart <= 1'b0;<br />
else if(unpk_wr_valid_d1 && ~unpk_wr_valid_d2 && ~ace_wvalid_i)<br />
wstart <= 1'b1;<br />
else if(ace_wvalid_i)<br />
wstart <= 1'b0;<br />
<br />
// assign val_write = ace_wvalid_i & ((ace_wready & pre_type != 2'h2) | (unpk_wr_valid_d1 & ~unpk_wr_valid_d2 & pre_type == 2'h2));<br />
// write data valid after unpk wr addr valid one cycle<br />
// assign val_write = ace_wvalid_i & ace_wready;</p>
<p> always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
val_read_d1 <= 1'b0;<br />
else<br />
val_read_d1 <= val_read;<br />
always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
val_read_d2 <= 1'b0;<br />
else<br />
val_read_d2 <= val_read_d1;</p>
<p> // Set a flag when a read is sent to the validation components and stays high<br />
// until the read data is presented to the ACE interface, accounting for any<br />
// stalls from the RVALID/RREADY handshake<br />
assign val_rd_ongoing = ~empty_b1 | (val_rd_ongoing_reg & ~(ace_rvalid & ace_rready_i));</p>
<p> always @ (posedge clk or negedge reset_n)<br />
if (!reset_n)<br />
val_rd_ongoing_reg <= 1'b0;<br />
else<br />
val_rd_ongoing_reg <= val_rd_ongoing;</p>
<p><br />
//----------------------------------------------------------------------------<br />
// Output assignments<br />
//----------------------------------------------------------------------------</p>
<p>// wire val_read_o, // Read valid<br />
wire [(ADDR_WIDTH-1):0] val_rd_addr; // Read address<br />
// wire val_write_o, // Write valid<br />
wire [(ADDR_WIDTH-1):0] val_wr_addr; // Write address<br />
wire val_wr_strb; // Write strobes<br />
wire val_wr_data; // Write data</p>
<p> // Validation memory interface<br />
//assign val_read = val_read;<br />
assign val_rd_addr = unpk_rd_addr;<br />
//assign val_write = val_write;<br />
assign val_wr_addr = unpk_wr_addr;<br />
// change little-big endian<br />
assign val_wr_data = {ace_wdata_i, ace_wdata_i, ace_wdata_i, ace_wdata_i};<br />
assign val_wr_data = {ace_wdata_i, ace_wdata_i, ace_wdata_i, ace_wdata_i};<br />
assign val_wr_data = {ace_wdata_i, ace_wdata_i, ace_wdata_i, ace_wdata_i};<br />
assign val_wr_data = {ace_wdata_i, ace_wdata_i, ace_wdata_i, ace_wdata_i};<br />
//assign val_wr_data = ace_wdata_i;<br />
//assign val_wr_strb = ace_wstrb_i;<br />
assign val_wr_strb = {ace_wstrb_i, ace_wstrb_i,ace_wstrb_i,ace_wstrb_i,<br />
ace_wstrb_i, ace_wstrb_i,ace_wstrb_i,ace_wstrb_i,<br />
ace_wstrb_i, ace_wstrb_i,ace_wstrb_i,ace_wstrb_i,<br />
ace_wstrb_i, ace_wstrb_i,ace_wstrb_i,ace_wstrb_i};</p>
<p> //reg ace_rvalid_o_tmp;<br />
//reg ace_rid_o_tmp;<br />
//reg ace_rresp_o_tmp;<br />
//reg ace_rlast_o_tmp;<br />
//always@(posedge clk)begin<br />
// ace_rvalid_o_tmp <= ace_rid ;<br />
// ace_rid_o_tmp <= ace_rresp ;<br />
// ace_rresp_o_tmp <= ace_rlast ;<br />
// ace_rlast_o_tmp <= ace_rvalid ;<br />
//end</p>
<p> // ACE outputs<br />
assign ace_awready_o = ace_awready;<br />
assign ace_wready_o = ace_wready;<br />
assign ace_bvalid_o = ace_bvalid;<br />
assign ace_bid_o = ace_bid;<br />
assign ace_bresp_o = ace_bresp;<br />
assign ace_arready_o = ace_arready;<br />
assign ace_rvalid_o = ace_rvalid;<br />
assign ace_rid_o = ace_rid;<br />
assign ace_rdata_o = ace_rdata;<br />
//assign ace_rdata_o = val_rd_data;<br />
assign ace_rresp_o = ace_rresp;<br />
assign ace_rlast_o = ace_rlast;</p>
<p><br />
//----------------------------------------------------------------------------<br />
// System address decoder<br />
//<br />
// The validation memory starts at address 0x000_0000_0000 and aliases<br />
// through the whole memory map, except for the region 0x000_1300_0000 to<br />
// 0x000_13FF_FFFF which is reserved for the tube and trickbox registers.<br />
//<br />
// This region contains:<br />
//<br />
// 0x000_1300_0000 : Tube<br />
// 0x000_1300_0008 : Trickbox - FIQ counter load<br />
// 0x000_1300_000C : Trickbox - FIQ clear<br />
//<br />
// Other locations in the trickbox region are reserved.<br />
//----------------------------------------------------------------------------</p>
<p> sramif_decoder<br />
u_sramif_decoder<br />
(<br />
.clk (clk),<br />
.reset_n (reset_n),</p>
<p> // Read port<br />
.val_read_i (val_read),<br />
.val_rd_addr_i (val_rd_addr),<br />
.val_rd_data_o (val_rd_data),</p>
<p> // Write port<br />
.val_write_i (val_write),<br />
.val_wr_addr_i (val_wr_addr),<br />
.val_wr_strb_i (val_wr_strb),<br />
.val_wr_data_i (val_wr_data),</p>
<p> // unpack address<br />
// a cycle ahead w_data_en<br />
.unpk_valid_i (unpk_wr_valid),<br />
<br />
// axi fifo register interface<br />
.fifo_count (fifo_count),</p>
<p> // preprocess interface<br />
.preproc_valid (preproc_valid),<br />
.pre_type (pre_type),<br />
.bvalid_delay (bvalid_delay),</p>
<p> // sram interface<br />
.bankA_dma_cs ( bankA_dma_cs ),<br />
.bankA_dma_we ( bankA_dma_we ),<br />
.bankA_dma_addr ( bankA_dma_addr ),<br />
.bankA_dma_din ( bankA_dma_din ),<br />
.bankA_dma_byte_en ( bankA_dma_byte_en ),<br />
.bankA_dma_dout ( bankA_dma_dout ),<br />
.bankB_dma_cs ( bankB_dma_cs ),<br />
.bankB_dma_we ( bankB_dma_we ),<br />
.bankB_dma_addr ( bankB_dma_addr ),<br />
.bankB_dma_din ( bankB_dma_din ),<br />
.bankB_dma_byte_en ( bankB_dma_byte_en ),<br />
.bankB_dma_dout ( bankB_dma_dout ),</p>
<p> // lut sram interface<br />
.dma_lut_cs ( dma_lut_cs ),<br />
.dma_lut_we ( dma_lut_we ),<br />
.dma_lut_addr ( dma_lut_addr ),<br />
.dma_lut_din ( dma_lut_din ),<br />
.dma_lut_byte_en ( dma_lut_byte_en ),<br />
.dma_lut_dout ( dma_lut_dout ),<br />
<br />
// npu reg interface<br />
.sys_addr ( sys_addr ),<br />
.sys_wr ( sys_wr ),<br />
.sys_wr_val ( sys_wr_val ),<br />
.sys_rd ( sys_rd ),<br />
.sys_ack ( sys_ack ),<br />
.sys_rd_val ( sys_rd_val ),</p>
<p> // npu command sram interface<br />
.cmd_cs ( cmd_cs ),<br />
.cmd_we ( cmd_we ),<br />
.cmd_addr ( cmd_addr ),<br />
.cmd_out ( cmd_out ),<br />
.cmd ( cmd ) </p>
<p> );</p>
<p>endmodule<br />
</p>
12345323865 发表于 2024-11-29 15:17
**** 作者被禁止或删除 内容自动屏蔽 ****
<p>?</p>
<p> </p>
页:
[1]