module TOP_RAM_SPI (i_clk,i_res_L,i_addr,i_wdata,i_write,i_read,o_rdata,o_SPI_Clk,o_SPI_Data,o_CS_L ); input i_clk,i_res_L; input [31:0] i_addr, i_wdata; input i_write,i_read; output [31:0] o_rdata; output o_SPI_Clk,o_SPI_Data; output reg o_CS_L; wire w_data_rdy; wire [15:0] w_data; wire w_data_req; SPI_RAM DataGEN(.i_clk(i_clk),.i_res_L(i_res_L), .i_address(i_addr), .o_readdata(o_rdata), .i_writedata(i_wdata), .i_read(i_read), .i_write(i_write), .i_rdy(w_data_req),.o_data(w_data),.o_valid(w_data_rdy)); SPI_Master16bit SPI_GEN(.i_Rst_L(i_res_L),.i_Clk(i_clk), .i_TX_Byte(w_data),.i_TX_DV(w_data_rdy),.o_TX_Ready(w_data_req), .o_SPI_Clk(o_SPI_Clk),.o_SPI_MOSI(o_SPI_Data)); // Purpose: Add clock delay to signals for alignment. always @(posedge i_clk or negedge i_res_L) begin if (~i_res_L) begin o_CS_L <= 1'b0; end else o_CS_L <= w_data_req; end endmodule