`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// company: 
// engineer: 
// 
// create date:    11:56:45 07/11/2019 
// design name: 
// module name:    adc_init_interface 
// project name: 
// target devices: 
// tool versions: 
// description: 
//
// dependencies: 
//
// revision: 
// revision 0.01 - file created
// additional comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module	AdcInitInterface	
#(
	parameter	DelayValue		=	24000,
	parameter	LengthWidth		=	2000,
	parameter	DataWidth		=	24,
	parameter	DataNum			=	26
)
(
    input	wire	Clk_i,
	input	wire	Rst_i,
	
	output	wire	AdcMosi_o,
	output	wire	AdcClk_o,
	output	wire	AdcCs_o,
	output	wire	AdcRst_o
);
//================================================================================
//  reg/wire
//================================================================================	
	wire			adcRstDone;
	wire			adcFilteredRst;
//================================================================================
//  instantiations
//================================================================================	

ResetFilter #(
    .STAGE_NUM      (4),
    .RESET_FRONT    ("RISING")
) 
adcResetFilter 
(
    .clk_i          (Clk_i),
    .rst_i          (Rst_i),
    .perm_i         (1'b0),
    .filtered_rst_o (adcFilteredRst)
);

AdcInitRst
#(
	.DELAY_VALUE    (DelayValue),	//задержка перед выдачей reset'а
	.LENGTH_WIDTH   (LengthWidth)		//длительность сигнала reset
) 
AdcInitRst 
(
	.clk_i      (Clk_i),
	.rst_i      (adcFilteredRst),
	.signal_o   (AdcRst_o),
	.done_o     (adcRstDone)
);

PeriphSpiInit 
#(
	.DATA_WIDTH             (DataWidth),
	.DATA_NUM               (DataNum), 
	.ROM_INIT_FILE          ("C:/Users/User/Desktop/4portCompact/S5443/S5443_M/S5443.srcs/sources_1/new/AdcInit/initFiles/AdcInitData.txt"),
	.FILE_DATA_BASE         ("HEX"),
	.SPI_CLK_DIVISOR_POWER  (4),
	.SPI_CPOL               (0),
	.SPI_CPHA               (0),
	.SPI_DATA_DIRECTION     ("MSB"),
	.SPI_EN_START_DELAY     ("YES")
) 
PeriphSpiInitController 
(
	.clk_i                  (Clk_i),
	.rst_i                  (adcFilteredRst),
	.enable_i               (adcRstDone),
	.mosi_o                 (AdcMosi_o),
	.sck_o                  (AdcClk_o),
	.ss_o                   (AdcCs_o),
	.done_o                 ()
);

endmodule
