parameterCONTROL_ADDR='h1000,// AXI write address of control write registers
parameterCONTROL_ADDR_MASK='h1400,// AXI write address of control registers
parameterBUSY_WR_ADDR='h1800,// AXI write address to generate busy
parameterBUSY_WR_ADDR_MASK='h1c00,// AXI write address mask to generate busy
parameterDLY_LD_REL='h080,// address to generate delay load
parameterDLY_LD_REL_MASK='h380,// address mask to generate delay load
parameterDLY_SET_REL='h070,// address to generate delay set
parameterDLY_SET_REL_MASK='h3ff,// address mask to generate delay set
parameterRUN_CHN_REL='h000,// address to set sequnecer channel and run (4 LSB-s - channel)
parameterRUN_CHN_REL_MASK='h3f0,// address mask to generate sequencer channel/run
parameterPATTERNS_REL='h020,// address to set DQM and DQS patterns (16'h0055)
parameterPATTERNS_REL_MASK='h3ff,// address mask to set DQM and DQS patterns
parameterPATTERNS_TRI_REL='h021,// address to set DQM and DQS tristate on/off patterns {dqs_off,dqs_on, dq_off,dq_on} - 4 bits each
parameterPATTERNS_TRI_REL_MASK='h3ff,// address mask to set DQM and DQS tristate patterns
parameterWBUF_DELAY_REL='h022,// extra delay (in mclk cycles) to add to write buffer enable (DDR3 read data)
parameterWBUF_DELAY_REL_MASK='h3ff,// address mask to set extra delay
parameterPAGES_REL='h023,// address to set buffer pages {port1_page[1:0],port1_int_page[1:0],port0_page[1:0],port0_int_page[1:0]}
parameterPAGES_REL_MASK='h3ff,// address mask to set DQM and DQS patterns
parameterCMDA_EN_REL='h024,// address to enable('h825)/disable('h824) command/address outputs
parameterCMDA_EN_REL_MASK='h3fe,// address mask for command/address outputs
parameterSDRST_ACT_REL='h026,// address to activate('h827)/deactivate('h826) active-low reset signal to DDR3 memory
parameterSDRST_ACT_REL_MASK='h3fe,// address mask for reset DDR3
parameterCKE_EN_REL='h028,// address to enable('h829)/disable('h828) CKE signal to memory
parameterCKE_EN_REL_MASK='h3fe,// address mask for command/address outputs
parameterDCI_RST_REL='h02a,// address to activate('h82b)/deactivate('h82a) Zynq DCI calibrate circuitry
parameterDCI_RST_REL_MASK='h3fe,// address mask for DCI calibrate circuitry
parameterDLY_RST_REL='h02c,// address to activate('h82d)/deactivate('h82c) delay calibration circuitry
parameterDLY_RST_REL_MASK='h3fe,// address mask for delay calibration circuitry
parameterEXTRA_REL='h02e,// address to set extra parameters (currently just inv_clk_div)
parameterEXTRA_REL_MASK='h3ff,// address mask for extra parameters
parameterREFRESH_EN_REL='h030,// address to enable('h31) and disable ('h30) DDR refresh
parameterREFRESH_EN_REL_MASK='h3fe,// address mask to enable/disable DDR refresh
parameterREFRESH_PER_REL='h032,// address to set refresh period in 32 x tCK
parameterREFRESH_PER_REL_MASK='h3ff,// address mask set refresh period
parameterREFRESH_ADDR_REL='h033,// address to set sequencer start address for DDR refresh
parameterREFRESH_ADDR_REL_MASK='h3ff// address mask set refresh sequencer address
)(
inputclk,
inputmclk,
inputrst,
input[AXI_WR_ADDR_BITS-1:0]pre_waddr,// AXI write address, before actual writes (to generate busy), valid@start_burst
inputstart_wburst,// burst start - should generate ~ready (should be AND-ed with !busy internally)
input[AXI_WR_ADDR_BITS-1:0]waddr,// write address, valid with wr_en
inputwr_en,// write enable
input[31:0]wdata,// write data, valid with waddr and wr_en
outputbusy,// interface busy (combinatorial delay from start_wburst and pre_addr
// control signals
// control: sequencer run
output[10:0]run_addr,// Start address of the physical sequencer (MSB = 0 - "manual", 1 -"auto")
output[3:0]run_chn,// channel number to use for I/O buffers
outputrun_seq,// single mclk pulse to start sequencer
// simple arbitration (should not start if higher priority, busy or run_seq)
inputrun_seq_rq_in,// higher priority request to run sequence
outputrun_seq_rq_gen,// this wants to run sequencer
inputrun_seq_busy,// sequencer is busy or access granted to other master (should be on staring nearest cycle)
output[10:0]refresh_address,
output[7:0]refresh_period,
outputrefresh_set,
outputrefresh_en,
// output run_seq_granted, // this module got sequencer access granted
// input run_done; // output - will go through other channel - sequencer done (add busy?)
// control: delays and mmcm setup
output[7:0]dly_data,// 8-bit IDELAY/ODELAY (fine) and MMCM phase shift
output[6:0]dly_addr,// address to select delay register
outputld_delay,// write dly_data to dly_address, one mclk active pulse
outputdly_set,// transfer (activate) all delays simultaneosly, 1 mclk pulse
// control: additional signals
outputcmda_en,// tri-state all command and address lines to DDR chip
outputddr_rst,// generate DDR3 memory reset signal
outputdci_rst,// active high - reset DCI circuitry
outputdly_rst,// active high - delay calibration circuitry
outputddr_cke,// control DDR3 memory CKE signal
outputinv_clk_div,// invert clk_div to ISERDES
output[7:0]dqs_pattern,// DQS pattern during write (normally 8'h55)
output[7:0]dqm_pattern,// DQM pattern (just for testing, should be 8'h0)
output[3:0]dq_tri_on_pattern,
output[3:0]dq_tri_off_pattern,
output[3:0]dqs_tri_on_pattern,
output[3:0]dqs_tri_off_pattern,
output[3:0]wbuf_delay,
// control: buffers pages
output[1:0]port0_page,// port 0 buffer read page (to be controlled by arbiter later, set to 2'b0)
output[1:0]port0_int_page,// port 0 PHY-side write to buffer page (to be controlled by arbiter later, set to 2'b0)
output[1:0]port1_page,// port 1 buffer write page (to be controlled by arbiter later, set to 2'b0)
output[1:0]port1_int_page// port 1 PHY-side buffer read page (to be controlled by arbiter later, set to 2'b0)
);
localparamDQSTRI_FIRST=4'h3;// DQS tri-state control word, first when enabling output
localparamDQSTRI_LAST=4'hc;// DQS tri-state control word, first after disabling output
localparamDQTRI_FIRST=4'h7;// DQ tri-state control word, first when enabling output
localparamDQTRI_LAST=4'he;// DQ tri-state control word, first after disabling output
localparamWBUF_DLY_DFLT=4'h6;// extra delay (in mclk cycles) to add to write buffer enable (DDR3 read data)
localparamDLY_LD_ADDR=CONTROL_ADDR|DLY_LD_REL;// address to generate delay load
localparamDLY_LD_ADDR_MASK=CONTROL_ADDR_MASK|DLY_LD_REL_MASK;// address mask to generate delay load
localparamDLY_SET_ADDR=CONTROL_ADDR|DLY_SET_REL;// address to generate delay set
localparamDLY_SET_ADDR_MASK=CONTROL_ADDR_MASK|DLY_SET_REL_MASK;// address mask to generate delay set
localparamRUN_CHN_ADDR=CONTROL_ADDR|RUN_CHN_REL;// address to set sequnecer channel and run (4 LSB-s - channel)
localparamRUN_CHN_ADDR_MASK=CONTROL_ADDR_MASK|RUN_CHN_REL_MASK;// address mask to generate sequencer channel/run
localparamPATTERNS_ADDR=CONTROL_ADDR|PATTERNS_REL;// address to set DQM and DQS patterns (16'h0055)
localparamPATTERNS_ADDR_MASK=CONTROL_ADDR_MASK|PATTERNS_REL_MASK;// address mask to set DQM and DQS patterns
localparamPATTERNS_TRI_ADDR=CONTROL_ADDR|PATTERNS_TRI_REL;//address to set DQM and DQS tristate on/off patterns {dqs_off,dqs_on, dq_off,dq_on} - 4 bits each
localparamPATTERNS_TRI_ADDR_MASK=CONTROL_ADDR_MASK|PATTERNS_TRI_REL_MASK;// address mask to set DQM and DQS tristate patterns
localparamWBUF_DELAY_ADDR=CONTROL_ADDR|WBUF_DELAY_REL;// extra delay (in mclk cycles) to add to write buffer enable (DDR3 read data)
localparamWBUF_DELAY_ADDR_MASK=CONTROL_ADDR_MASK|WBUF_DELAY_REL_MASK;// address mask to set extra delay
localparamPAGES_ADDR=CONTROL_ADDR|PAGES_REL;// address to set buffer pages {port1_page[1:0],port1_int_page[1:0],port0_page[1:0],port0_int_page[1:0]}
localparamPAGES_ADDR_MASK=CONTROL_ADDR_MASK|PAGES_REL_MASK;// address mask to set DQM and DQS patterns
localparamCMDA_EN_ADDR=CONTROL_ADDR|CMDA_EN_REL;// address to enable('h823)/disable('h822) command/address outputs
localparamCMDA_EN_ADDR_MASK=CONTROL_ADDR_MASK|CMDA_EN_REL_MASK;// address mask for command/address outputs
localparamSDRST_ACT_ADDR=CONTROL_ADDR|SDRST_ACT_REL;// address to activate('h825)/deactivate('h8242) active-low reset signal to DDR3 memory
localparamSDRST_ACT_ADDR_MASK=CONTROL_ADDR_MASK|SDRST_ACT_REL_MASK;// address mask for reset DDR3
localparamDCI_RST_ADDR=CONTROL_ADDR|DCI_RST_REL;// address to activate/deactivate Zynq DCI calibrate circuitry
localparamDCI_RST_ADDR_MASK=CONTROL_ADDR_MASK|DCI_RST_REL_MASK;// address mask for DCI calibrate circuitry
localparamDLY_RST_ADDR=CONTROL_ADDR|DLY_RST_REL;// address to activate/deactivate delay calibration circuitry
localparamDLY_RST_ADDR_MASK=CONTROL_ADDR_MASK|DLY_RST_REL_MASK;// address mask for delay calibration circuitry
localparamCKE_EN_ADDR=CONTROL_ADDR|CKE_EN_REL;// address to enable('h827)/disable('h826) CKE signal to memory
localparamCKE_EN_ADDR_MASK=CONTROL_ADDR_MASK|CKE_EN_REL_MASK;// address mask for CKE
localparamEXTRA_ADDR=CONTROL_ADDR|EXTRA_REL;// address to set extra parameters (currently just inv_clk_div)
localparamEXTRA_ADDR_MASK=CONTROL_ADDR_MASK|EXTRA_REL_MASK;// address mask for extra parameters
localparamREFRESH_EN_ADDR=CONTROL_ADDR|REFRESH_EN_REL;// address to enable('h31) and disable ('h30) DDR refresh
localparamREFRESH_EN_ADDR_MASK=CONTROL_ADDR_MASK|REFRESH_EN_REL_MASK;// address mask to enable/disable DDR refresh
localparamREFRESH_PER_ADDR=CONTROL_ADDR|REFRESH_PER_REL;// address to set refresh period in 32 x tCK
localparamREFRESH_PER_ADDR_MASK=CONTROL_ADDR_MASK|REFRESH_PER_REL_MASK;// address mask set refresh period
localparamREFRESH_ADDR_ADDR=CONTROL_ADDR|REFRESH_ADDR_REL;// address to set sequencer start address for DDR refresh
localparamREFRESH_ADDR_ADDR_MASK=CONTROL_ADDR_MASK|REFRESH_ADDR_REL_MASK;// address mask set refresh sequencer address
reg[10:0]refresh_address_r;
reg[7:0]refresh_period_r;
regrefresh_set_r,refresh_set_r0;
regrefresh_ld_addr;
regrefresh_en_r;
wirerefresh_set_w;// just decoded
assignrefresh_address=refresh_address_r;
assignrefresh_period=refresh_period_r;
assignrefresh_set=refresh_set_r;
assignrefresh_en=refresh_en_r;
regbusy_r=0;
regselected=0;
regselected_busy=0;// decoded from address, if false - busy_r is ignored (always ready)
wirefifo_half_empty;// just debugging with (* keep = "true" *)
wire[AXI_WR_ADDR_BITS-1:0]waddr_fifo_out;
wire[31:0]wdata_fifo_out;
// reg fifo_re; // wrong, need to have (fifo!=1) || !re
wirefifo_nempty;
wirefifo_re;
reg[AXI_WR_ADDR_BITS-1:0]waddr_fifo_out_r;
reg[31:0]wdata_fifo_out_r;
regdly_ld_r=0;
regdly_set_r=0;
regrun_seq_r=0;
reg[7:0]dqs_pattern_r;// DQS pattern during write (normally 8'h55)
reg[7:0]dqm_pattern_r;// DQM pattern (just for testing, should be 8'h0)
reg[1:0]port0_page_r;// port 0 buffer read page (to be controlled by arbiter later, set to 2'b0)
reg[1:0]port0_int_page_r;// port 0 PHY-side write to buffer page (to be controlled by arbiter later, set to 2'b0)
reg[1:0]port1_page_r;// port 1 buffer write page (to be controlled by arbiter later, set to 2'b0)
reg[1:0]port1_int_page_r;// port 1 PHY-side buffer read page (to be controlled by arbiter later, set to 2'b0)
regcmda_en_r;// enable (tri-state off) all command and address lines to DDR chip
regddr_rst_r;// generate DDR3 memory reset
regdci_rst_r;// active high - reset DCI circuitry
regdly_rst_r;// active high - reset delay calibration circuitry
assigndly_data=wdata_fifo_out_r[7:0];// IgnoreThisWarning VivadoSynthesis WARNING: [Synth 8-3936] Found unconnected internal register 'wdata_fifo_out_r_reg' and it is trimmed from '32' to '11' bits. [ddrc_control.v:100]
assigndly_addr=waddr_fifo_out_r[6:0];// IgnoreThisWarning VivadoSynthesis WARNING: [Synth 8-3936] Found unconnected internal register 'waddr_fifo_out_r_reg' and it is trimmed from '12' to '7' bits. [ddrc_control.v:101]