exp: N=16 timing closure fixed (EXP-0056), weight-reuse gives real 7.16x memory speedup without DDR3 (EXP-0057)
EXP-0056: N_SLOTS=16 failed timing on LFE5U-85F (23-24MHz vs 64MHz
target). First hypothesis (dependency_manager.v's serial ready-scan)
was wrong but real -- built and verified priority_encoder_lsb.v (a
generic recursive tree encoder) and dependency_manager_fast.v, bit-
exact equivalent to the original, but integrated it made no real
difference (24.26MHz). The real cause, found from nextpnr's own
critical-path report: nms_activation_fill_ctrl_v3.v's balanced max-
tree was only ever extended to N_SLOTS in {1,2,4,8}, silently falling
back to the original slow scan for 16. Added the missing case
(nms_activation_fill_ctrl_v3_n16.v), verified isolated (10017/10017)
and functionally (D-Stress N=16 still 256/256 bit-exact). Real result:
71.01MHz, PASS at 64MHz (single seed so far).
EXP-0057: built layer_weight_buffer.v, a double-buffered per-layer
weight scratchpad (fill one buffer in the background from SDRAM while
compute reads many times from the other -- weight-stationary reuse,
as opposed to D-Stress's own deliberately zero-reuse pattern). Wired
to the real sdram_controller_openrow.v + sdram_model.v, no new
hardware. For the same 32768 bytes of useful data: zero-reuse costs
27048 real cycles, reuse costs 3777 -- 7.16x real measured speedup on
the SAME SDR SDRAM, no DDR3, no clock change. This is the answer to
whether DDR3 is necessary for a workload class that actually has
reuse (e.g. conv-style face recognition, unlike D-Stress) -- it isn't,
at least not for this reason.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MUG92aM9m68TRc4rG55BcC
This commit is contained in:
@@ -0,0 +1,279 @@
|
||||
//--------------------------------------------------------------------------------
|
||||
// Auto-generated by LiteX (9ad3ecf74) on 2026-09-16 08:16:18
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// CSR Includes.
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
#include <generated/soc.h>
|
||||
#ifndef __GENERATED_CSR_H
|
||||
#define __GENERATED_CSR_H
|
||||
#include <stdint.h>
|
||||
#include <system.h>
|
||||
#ifndef CSR_ACCESSORS_DEFINED
|
||||
#include <hw/common.h>
|
||||
#endif /* ! CSR_ACCESSORS_DEFINED */
|
||||
|
||||
#ifndef CSR_BASE
|
||||
#define CSR_BASE 0x0L
|
||||
#endif /* ! CSR_BASE */
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// CSR Registers/Fields Definition.
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
/* DDRCTRL Registers */
|
||||
#define CSR_DDRCTRL_BASE (CSR_BASE + 0x0L)
|
||||
#define CSR_DDRCTRL_INIT_DONE_ADDR (CSR_BASE + 0x0L)
|
||||
#define CSR_DDRCTRL_INIT_DONE_SIZE 1
|
||||
#define CSR_DDRCTRL_INIT_ERROR_ADDR (CSR_BASE + 0x4L)
|
||||
#define CSR_DDRCTRL_INIT_ERROR_SIZE 1
|
||||
|
||||
/* DDRCTRL Fields */
|
||||
|
||||
/* DDRPHY Registers */
|
||||
#define CSR_DDRPHY_BASE (CSR_BASE + 0x800L)
|
||||
#define CSR_DDRPHY_DLY_SEL_ADDR (CSR_BASE + 0x800L)
|
||||
#define CSR_DDRPHY_DLY_SEL_SIZE 1
|
||||
#define CSR_DDRPHY_RDLY_DQ_RST_ADDR (CSR_BASE + 0x804L)
|
||||
#define CSR_DDRPHY_RDLY_DQ_RST_SIZE 1
|
||||
#define CSR_DDRPHY_RDLY_DQ_INC_ADDR (CSR_BASE + 0x808L)
|
||||
#define CSR_DDRPHY_RDLY_DQ_INC_SIZE 1
|
||||
#define CSR_DDRPHY_RDLY_DQ_BITSLIP_RST_ADDR (CSR_BASE + 0x80cL)
|
||||
#define CSR_DDRPHY_RDLY_DQ_BITSLIP_RST_SIZE 1
|
||||
#define CSR_DDRPHY_RDLY_DQ_BITSLIP_ADDR (CSR_BASE + 0x810L)
|
||||
#define CSR_DDRPHY_RDLY_DQ_BITSLIP_SIZE 1
|
||||
#define CSR_DDRPHY_BURSTDET_CLR_ADDR (CSR_BASE + 0x814L)
|
||||
#define CSR_DDRPHY_BURSTDET_CLR_SIZE 1
|
||||
#define CSR_DDRPHY_BURSTDET_SEEN_ADDR (CSR_BASE + 0x818L)
|
||||
#define CSR_DDRPHY_BURSTDET_SEEN_SIZE 1
|
||||
|
||||
/* DDRPHY Fields */
|
||||
|
||||
/* SDRAM Registers */
|
||||
#define CSR_SDRAM_BASE (CSR_BASE + 0x1000L)
|
||||
#define CSR_SDRAM_DFII_CONTROL_ADDR (CSR_BASE + 0x1000L)
|
||||
#define CSR_SDRAM_DFII_CONTROL_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_ADDR (CSR_BASE + 0x1004L)
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_ISSUE_ADDR (CSR_BASE + 0x1008L)
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_ISSUE_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_ADDRESS_ADDR (CSR_BASE + 0x100cL)
|
||||
#define CSR_SDRAM_DFII_PI0_ADDRESS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_BADDRESS_ADDR (CSR_BASE + 0x1010L)
|
||||
#define CSR_SDRAM_DFII_PI0_BADDRESS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_WRDATA_ADDR (CSR_BASE + 0x1014L)
|
||||
#define CSR_SDRAM_DFII_PI0_WRDATA_SIZE 2
|
||||
#define CSR_SDRAM_DFII_PI0_RDDATA_ADDR (CSR_BASE + 0x101cL)
|
||||
#define CSR_SDRAM_DFII_PI0_RDDATA_SIZE 2
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_ADDR (CSR_BASE + 0x1024L)
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_ISSUE_ADDR (CSR_BASE + 0x1028L)
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_ISSUE_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_ADDRESS_ADDR (CSR_BASE + 0x102cL)
|
||||
#define CSR_SDRAM_DFII_PI1_ADDRESS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_BADDRESS_ADDR (CSR_BASE + 0x1030L)
|
||||
#define CSR_SDRAM_DFII_PI1_BADDRESS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_WRDATA_ADDR (CSR_BASE + 0x1034L)
|
||||
#define CSR_SDRAM_DFII_PI1_WRDATA_SIZE 2
|
||||
#define CSR_SDRAM_DFII_PI1_RDDATA_ADDR (CSR_BASE + 0x103cL)
|
||||
#define CSR_SDRAM_DFII_PI1_RDDATA_SIZE 2
|
||||
|
||||
/* SDRAM Fields */
|
||||
#define CSR_SDRAM_DFII_CONTROL_SEL_OFFSET 0
|
||||
#define CSR_SDRAM_DFII_CONTROL_SEL_SIZE 1
|
||||
#define CSR_SDRAM_DFII_CONTROL_CKE_OFFSET 1
|
||||
#define CSR_SDRAM_DFII_CONTROL_CKE_SIZE 1
|
||||
#define CSR_SDRAM_DFII_CONTROL_ODT_OFFSET 2
|
||||
#define CSR_SDRAM_DFII_CONTROL_ODT_SIZE 1
|
||||
#define CSR_SDRAM_DFII_CONTROL_RESET_N_OFFSET 3
|
||||
#define CSR_SDRAM_DFII_CONTROL_RESET_N_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_CS_OFFSET 0
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_CS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_WE_OFFSET 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_WE_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_CAS_OFFSET 2
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_CAS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_RAS_OFFSET 3
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_RAS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_WREN_OFFSET 4
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_WREN_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_RDEN_OFFSET 5
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_RDEN_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_CS_TOP_OFFSET 6
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_CS_TOP_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_CS_BOTTOM_OFFSET 7
|
||||
#define CSR_SDRAM_DFII_PI0_COMMAND_CS_BOTTOM_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_CS_OFFSET 0
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_CS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_WE_OFFSET 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_WE_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_CAS_OFFSET 2
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_CAS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_RAS_OFFSET 3
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_RAS_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_WREN_OFFSET 4
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_WREN_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_RDEN_OFFSET 5
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_RDEN_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_CS_TOP_OFFSET 6
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_CS_TOP_SIZE 1
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_CS_BOTTOM_OFFSET 7
|
||||
#define CSR_SDRAM_DFII_PI1_COMMAND_CS_BOTTOM_SIZE 1
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// CSR Registers Access Functions.
|
||||
//--------------------------------------------------------------------------------
|
||||
|
||||
#ifndef LITEX_CSR_ACCESS_FUNCTIONS
|
||||
#define LITEX_CSR_ACCESS_FUNCTIONS 1
|
||||
#endif
|
||||
|
||||
#if LITEX_CSR_ACCESS_FUNCTIONS
|
||||
|
||||
/* DDRCTRL Access Functions */
|
||||
static inline uint32_t ddrctrl_init_done_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x0L));
|
||||
}
|
||||
static inline void ddrctrl_init_done_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x0L));
|
||||
}
|
||||
static inline uint32_t ddrctrl_init_error_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x4L));
|
||||
}
|
||||
static inline void ddrctrl_init_error_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x4L));
|
||||
}
|
||||
|
||||
/* DDRPHY Access Functions */
|
||||
static inline uint32_t ddrphy_dly_sel_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x800L));
|
||||
}
|
||||
static inline void ddrphy_dly_sel_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x800L));
|
||||
}
|
||||
static inline uint32_t ddrphy_rdly_dq_rst_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x804L));
|
||||
}
|
||||
static inline void ddrphy_rdly_dq_rst_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x804L));
|
||||
}
|
||||
static inline uint32_t ddrphy_rdly_dq_inc_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x808L));
|
||||
}
|
||||
static inline void ddrphy_rdly_dq_inc_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x808L));
|
||||
}
|
||||
static inline uint32_t ddrphy_rdly_dq_bitslip_rst_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x80cL));
|
||||
}
|
||||
static inline void ddrphy_rdly_dq_bitslip_rst_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x80cL));
|
||||
}
|
||||
static inline uint32_t ddrphy_rdly_dq_bitslip_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x810L));
|
||||
}
|
||||
static inline void ddrphy_rdly_dq_bitslip_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x810L));
|
||||
}
|
||||
static inline uint32_t ddrphy_burstdet_clr_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x814L));
|
||||
}
|
||||
static inline void ddrphy_burstdet_clr_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x814L));
|
||||
}
|
||||
static inline uint32_t ddrphy_burstdet_seen_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x818L));
|
||||
}
|
||||
|
||||
/* SDRAM Access Functions */
|
||||
static inline uint32_t sdram_dfii_control_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x1000L));
|
||||
}
|
||||
static inline void sdram_dfii_control_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x1000L));
|
||||
}
|
||||
static inline uint32_t sdram_dfii_pi0_command_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x1004L));
|
||||
}
|
||||
static inline void sdram_dfii_pi0_command_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x1004L));
|
||||
}
|
||||
static inline uint32_t sdram_dfii_pi0_command_issue_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x1008L));
|
||||
}
|
||||
static inline void sdram_dfii_pi0_command_issue_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x1008L));
|
||||
}
|
||||
static inline uint32_t sdram_dfii_pi0_address_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x100cL));
|
||||
}
|
||||
static inline void sdram_dfii_pi0_address_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x100cL));
|
||||
}
|
||||
static inline uint32_t sdram_dfii_pi0_baddress_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x1010L));
|
||||
}
|
||||
static inline void sdram_dfii_pi0_baddress_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x1010L));
|
||||
}
|
||||
static inline uint64_t sdram_dfii_pi0_wrdata_read(void) {
|
||||
uint64_t r = csr_read_simple((CSR_BASE + 0x1014L));
|
||||
r <<= 32;
|
||||
r |= csr_read_simple((CSR_BASE + 0x1018L));
|
||||
return r;
|
||||
}
|
||||
static inline void sdram_dfii_pi0_wrdata_write(uint64_t v) {
|
||||
csr_write_simple(v >> 32, (CSR_BASE + 0x1014L));
|
||||
csr_write_simple(v, (CSR_BASE + 0x1018L));
|
||||
}
|
||||
static inline uint64_t sdram_dfii_pi0_rddata_read(void) {
|
||||
uint64_t r = csr_read_simple((CSR_BASE + 0x101cL));
|
||||
r <<= 32;
|
||||
r |= csr_read_simple((CSR_BASE + 0x1020L));
|
||||
return r;
|
||||
}
|
||||
static inline uint32_t sdram_dfii_pi1_command_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x1024L));
|
||||
}
|
||||
static inline void sdram_dfii_pi1_command_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x1024L));
|
||||
}
|
||||
static inline uint32_t sdram_dfii_pi1_command_issue_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x1028L));
|
||||
}
|
||||
static inline void sdram_dfii_pi1_command_issue_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x1028L));
|
||||
}
|
||||
static inline uint32_t sdram_dfii_pi1_address_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x102cL));
|
||||
}
|
||||
static inline void sdram_dfii_pi1_address_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x102cL));
|
||||
}
|
||||
static inline uint32_t sdram_dfii_pi1_baddress_read(void) {
|
||||
return csr_read_simple((CSR_BASE + 0x1030L));
|
||||
}
|
||||
static inline void sdram_dfii_pi1_baddress_write(uint32_t v) {
|
||||
csr_write_simple(v, (CSR_BASE + 0x1030L));
|
||||
}
|
||||
static inline uint64_t sdram_dfii_pi1_wrdata_read(void) {
|
||||
uint64_t r = csr_read_simple((CSR_BASE + 0x1034L));
|
||||
r <<= 32;
|
||||
r |= csr_read_simple((CSR_BASE + 0x1038L));
|
||||
return r;
|
||||
}
|
||||
static inline void sdram_dfii_pi1_wrdata_write(uint64_t v) {
|
||||
csr_write_simple(v >> 32, (CSR_BASE + 0x1034L));
|
||||
csr_write_simple(v, (CSR_BASE + 0x1038L));
|
||||
}
|
||||
static inline uint64_t sdram_dfii_pi1_rddata_read(void) {
|
||||
uint64_t r = csr_read_simple((CSR_BASE + 0x103cL));
|
||||
r <<= 32;
|
||||
r |= csr_read_simple((CSR_BASE + 0x1040L));
|
||||
return r;
|
||||
}
|
||||
#endif /* LITEX_CSR_ACCESS_FUNCTIONS */
|
||||
|
||||
#endif /* ! __GENERATED_CSR_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
//--------------------------------------------------------------------------------
|
||||
// Auto-generated by LiteX (9ad3ecf74) on 2026-09-16 08:16:18
|
||||
//--------------------------------------------------------------------------------
|
||||
#ifndef __GENERATED_GIT_H
|
||||
#define __GENERATED_GIT_H
|
||||
|
||||
#define LITEX_GIT_SHA1 "9ad3ecf74"
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
//--------------------------------------------------------------------------------
|
||||
// Auto-generated by LiteX (9ad3ecf74) on 2026-09-16 08:16:18
|
||||
//--------------------------------------------------------------------------------
|
||||
#ifndef __GENERATED_MEM_H
|
||||
#define __GENERATED_MEM_H
|
||||
|
||||
#ifndef CSR_BASE
|
||||
#define CSR_BASE 0x00000000L
|
||||
#define CSR_BASE_VA 0x00000000L
|
||||
#define CSR_SIZE 0x00010000
|
||||
#endif
|
||||
|
||||
#ifndef MEM_REGIONS
|
||||
#define MEM_REGIONS "CSR 0x00000000 0x10000 "
|
||||
#endif
|
||||
|
||||
#ifndef MEM_REGIONS_DETAILS
|
||||
#define MEM_REGIONS_DETAILS "Region Origin End Size \nCSR 0x00000000 0x0000ffff 0x10000 "
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,115 @@
|
||||
#ifndef __GENERATED_SDRAM_PHY_H
|
||||
#define __GENERATED_SDRAM_PHY_H
|
||||
|
||||
#include <hw/common.h>
|
||||
#include <generated/csr.h>
|
||||
|
||||
#define DFII_CONTROL_SEL 0x01
|
||||
#define DFII_CONTROL_CKE 0x02
|
||||
#define DFII_CONTROL_ODT 0x04
|
||||
#define DFII_CONTROL_RESET_N 0x08
|
||||
|
||||
#define DFII_COMMAND_CS 0x01
|
||||
#define DFII_COMMAND_WE 0x02
|
||||
#define DFII_COMMAND_CAS 0x04
|
||||
#define DFII_COMMAND_RAS 0x08
|
||||
#define DFII_COMMAND_WRDATA 0x10
|
||||
#define DFII_COMMAND_RDDATA 0x20
|
||||
|
||||
#define SDRAM_PHY_ECP5DDRPHY
|
||||
#define SDRAM_PHY_XDR 2
|
||||
#define SDRAM_PHY_DATABITS 16
|
||||
#define SDRAM_PHY_DFI_DATABITS 64
|
||||
#define SDRAM_PHY_PHASES 2
|
||||
#define SDRAM_PHY_CL 6
|
||||
#define SDRAM_PHY_CWL 5
|
||||
#define SDRAM_PHY_RDPHASE 0
|
||||
#define SDRAM_PHY_WRPHASE 1
|
||||
#define SDRAM_PHY_READ_LEVELING_CAPABLE
|
||||
#define SDRAM_PHY_DQ_DQS_RATIO 8
|
||||
#define SDRAM_PHY_MODULES 2
|
||||
#define SDRAM_PHY_DELAYS 8
|
||||
#define SDRAM_PHY_BITSLIPS 4
|
||||
#define SDRAM_PHY_DDR3
|
||||
#define SDRAM_PHY_SUPPORTED_MEMORY 0x0000000020000000ULL
|
||||
|
||||
void cdelay(int i);
|
||||
|
||||
__attribute__((unused)) static inline void command_p0(int cmd)
|
||||
{
|
||||
sdram_dfii_pi0_command_write(cmd);
|
||||
sdram_dfii_pi0_command_issue_write(1);
|
||||
}
|
||||
__attribute__((unused)) static inline void command_p1(int cmd)
|
||||
{
|
||||
sdram_dfii_pi1_command_write(cmd);
|
||||
sdram_dfii_pi1_command_issue_write(1);
|
||||
}
|
||||
|
||||
#define DFII_PIX_DATA_SIZE CSR_SDRAM_DFII_PI0_WRDATA_SIZE
|
||||
|
||||
static inline unsigned long sdram_dfii_pix_wrdata_addr(int phase)
|
||||
{
|
||||
switch (phase) {
|
||||
case 0: return CSR_SDRAM_DFII_PI0_WRDATA_ADDR;
|
||||
case 1: return CSR_SDRAM_DFII_PI1_WRDATA_ADDR;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
static inline unsigned long sdram_dfii_pix_rddata_addr(int phase)
|
||||
{
|
||||
switch (phase) {
|
||||
case 0: return CSR_SDRAM_DFII_PI0_RDDATA_ADDR;
|
||||
case 1: return CSR_SDRAM_DFII_PI1_RDDATA_ADDR;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define DDRX_MR_WRLVL_ADDRESS 1
|
||||
#define DDRX_MR_WRLVL_RESET 6
|
||||
#define DDRX_MR_WRLVL_BIT 7
|
||||
|
||||
static inline void init_sequence(void)
|
||||
{
|
||||
/* Release reset */
|
||||
sdram_dfii_pi0_address_write(0x0);
|
||||
sdram_dfii_pi0_baddress_write(0);
|
||||
sdram_dfii_control_write(DFII_CONTROL_ODT|DFII_CONTROL_RESET_N);
|
||||
cdelay(50000);
|
||||
|
||||
/* Bring CKE high */
|
||||
sdram_dfii_pi0_address_write(0x0);
|
||||
sdram_dfii_pi0_baddress_write(0);
|
||||
sdram_dfii_control_write(DFII_CONTROL_CKE|DFII_CONTROL_ODT|DFII_CONTROL_RESET_N);
|
||||
cdelay(10000);
|
||||
|
||||
/* Load Mode Register 2, CWL=5 */
|
||||
sdram_dfii_pi0_address_write(0x200);
|
||||
sdram_dfii_pi0_baddress_write(2);
|
||||
command_p0(DFII_COMMAND_RAS|DFII_COMMAND_CAS|DFII_COMMAND_WE|DFII_COMMAND_CS);
|
||||
|
||||
/* Load Mode Register 3 */
|
||||
sdram_dfii_pi0_address_write(0x0);
|
||||
sdram_dfii_pi0_baddress_write(3);
|
||||
command_p0(DFII_COMMAND_RAS|DFII_COMMAND_CAS|DFII_COMMAND_WE|DFII_COMMAND_CS);
|
||||
|
||||
/* Load Mode Register 1 */
|
||||
sdram_dfii_pi0_address_write(0x6);
|
||||
sdram_dfii_pi0_baddress_write(1);
|
||||
command_p0(DFII_COMMAND_RAS|DFII_COMMAND_CAS|DFII_COMMAND_WE|DFII_COMMAND_CS);
|
||||
|
||||
/* Load Mode Register 0, CL=6, BL=8 */
|
||||
sdram_dfii_pi0_address_write(0x320);
|
||||
sdram_dfii_pi0_baddress_write(0);
|
||||
command_p0(DFII_COMMAND_RAS|DFII_COMMAND_CAS|DFII_COMMAND_WE|DFII_COMMAND_CS);
|
||||
cdelay(200);
|
||||
|
||||
/* ZQ Calibration */
|
||||
sdram_dfii_pi0_address_write(0x400);
|
||||
sdram_dfii_pi0_baddress_write(0);
|
||||
command_p0(DFII_COMMAND_WE|DFII_COMMAND_CS);
|
||||
cdelay(200);
|
||||
|
||||
}
|
||||
|
||||
#endif /* __GENERATED_SDRAM_PHY_H */
|
||||
@@ -0,0 +1,55 @@
|
||||
//--------------------------------------------------------------------------------
|
||||
// Auto-generated by LiteX (9ad3ecf74) on 2026-09-16 08:16:18
|
||||
//--------------------------------------------------------------------------------
|
||||
#ifndef __GENERATED_SOC_H
|
||||
#define __GENERATED_SOC_H
|
||||
#include <stdint.h>
|
||||
#define CONFIG_PLATFORM_NAME "platform"
|
||||
#define CONFIG_CLOCK_FREQUENCY 75000000
|
||||
#define CONFIG_CPU_TYPE_NONE
|
||||
#define CONFIG_CPU_VARIANT_STANDARD
|
||||
#define CONFIG_CPU_FAMILY
|
||||
#define CONFIG_CPU_NAME "None"
|
||||
#define CONFIG_CPU_HUMAN_NAME "Unknown"
|
||||
#define CONFIG_CSR_DATA_WIDTH 32
|
||||
#define CONFIG_CSR_ALIGNMENT 32
|
||||
#define CONFIG_CSR_ORDERING_BIG
|
||||
#define CONFIG_BUS_STANDARD "wishbone"
|
||||
#define CONFIG_BUS_DATA_WIDTH 32
|
||||
#define CONFIG_BUS_ADDRESS_WIDTH 32
|
||||
#define CONFIG_BUS_BURSTING 0
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
static inline const char * config_platform_name_read(void) {
|
||||
return "platform";
|
||||
}
|
||||
static inline uint32_t config_clock_frequency_read(void) {
|
||||
return 75000000;
|
||||
}
|
||||
static inline const char * config_cpu_name_read(void) {
|
||||
return "None";
|
||||
}
|
||||
static inline const char * config_cpu_human_name_read(void) {
|
||||
return "Unknown";
|
||||
}
|
||||
static inline uint32_t config_csr_data_width_read(void) {
|
||||
return 32;
|
||||
}
|
||||
static inline uint32_t config_csr_alignment_read(void) {
|
||||
return 32;
|
||||
}
|
||||
static inline const char * config_bus_standard_read(void) {
|
||||
return "wishbone";
|
||||
}
|
||||
static inline uint32_t config_bus_data_width_read(void) {
|
||||
return 32;
|
||||
}
|
||||
static inline uint32_t config_bus_address_width_read(void) {
|
||||
return 32;
|
||||
}
|
||||
static inline uint32_t config_bus_bursting_read(void) {
|
||||
return 0;
|
||||
}
|
||||
#endif // !__ASSEMBLER__
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user