s6ddrphy: style and other minor fixes

This commit is contained in:
Sebastien Bourdeauducq 2013-07-10 20:39:53 +02:00
parent 60f1585fef
commit 26ff6f2a9c
4 changed files with 28 additions and 28 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@ tools/flterm
tools/mkmmimg tools/mkmmimg
tools/byteswap tools/byteswap
software/include/hw/csr.h software/include/hw/csr.h
software/include/hw/sdram_phy.h
software/videomixer/dvisampler0.c software/videomixer/dvisampler0.c
software/videomixer/dvisampler0.h software/videomixer/dvisampler0.h
software/videomixer/dvisampler1.c software/videomixer/dvisampler1.c

View File

@ -67,14 +67,13 @@ def get_csr_header(csr_base, bank_array, interrupt_map):
return r return r
def get_sdram_phy_header(sdram_phy): def get_sdram_phy_header(sdram_phy):
if sdram_phy.phy_settings.type not in ["SDR", "DDR", "LPDDR", "DDR2"]: if sdram_phy.phy_settings.type not in ["SDR", "DDR", "LPDDR", "DDR2"]:
raise NotImplementedError("sdram phy header generator only supports SDR, DDR, LPDDR and DDR2") raise NotImplementedError("The SDRAM PHY header generator only supports SDR, DDR, LPDDR and DDR2")
r = "#ifndef __HW_SDRAM_PHY_H\n#define __SDRAM_PHY_H\n" r = "#ifndef __HW_SDRAM_PHY_H\n#define __HW_SDRAM_PHY_H\n"
r += "#include <hw/common.h>\n#include <hw/csr.h>\n#include <hw/flags.h>\n\n" r += "#include <hw/common.h>\n#include <hw/csr.h>\n#include <hw/flags.h>\n\n"
r += "extern void cdelay(int i);\n" r += "static void cdelay(int i);\n"
# #
# commands_px functions # commands_px functions
@ -126,7 +125,7 @@ static void command_p{n}(int cmd)
return r return r
r += "static void init_sequence(void) {\n" r += "static void init_sequence(void)\n{\n"
cl = sdram_phy.phy_settings.cl cl = sdram_phy.phy_settings.cl

View File

@ -18,7 +18,6 @@
# Todo: # Todo:
# - use CSR for bitslip? # - use CSR for bitslip?
# - move sdram clk generation to phy?
from migen.fhdl.std import * from migen.fhdl.std import *
from migen.bus.dfi import * from migen.bus.dfi import *
@ -26,7 +25,6 @@ from migen.genlib.record import *
class S6DDRPHY(Module): class S6DDRPHY(Module):
def __init__(self, pads, phy_settings, bitslip): def __init__(self, pads, phy_settings, bitslip):
if phy_settings.type not in ["DDR", "LPDDR", "DDR2"]: if phy_settings.type not in ["DDR", "LPDDR", "DDR2"]:
raise NotImplementedError("S6DDRPHY only supports DDR, LPDDR and DDR2") raise NotImplementedError("S6DDRPHY only supports DDR, LPDDR and DDR2")
@ -48,8 +46,6 @@ class S6DDRPHY(Module):
# sdram_full_rd_clk : full rate sdram write clk # sdram_full_rd_clk : full rate sdram write clk
sd_sys = getattr(self.sync, "sys") sd_sys = getattr(self.sync, "sys")
sd_sdram_half = getattr(self.sync, "sdram_half") sd_sdram_half = getattr(self.sync, "sdram_half")
sd_sdram_full_wr = getattr(self.sync, "sdram_full_wr")
sd_sdram_full_rd = getattr(self.sync, "sdram_full_rd")
sys_clk = ClockSignal("sys") sys_clk = ClockSignal("sys")
sdram_half_clk = ClockSignal("sdram_half") sdram_half_clk = ClockSignal("sdram_half")
@ -102,10 +98,10 @@ class S6DDRPHY(Module):
# #
# Bitslip # Bitslip
# #
bitslip_cnt = Signal(4) bitslip_cnt = Signal(4)
bitslip_inc = Signal() bitslip_inc = Signal()
sd_sys +=[ sd_sys += [
If(bitslip_cnt==bitslip, If(bitslip_cnt==bitslip,
bitslip_inc.eq(0) bitslip_inc.eq(0)
).Else( ).Else(
@ -120,7 +116,10 @@ class S6DDRPHY(Module):
sdram_half_clk_n = Signal() sdram_half_clk_n = Signal()
self.comb += sdram_half_clk_n.eq(~sdram_half_clk) self.comb += sdram_half_clk_n.eq(~sdram_half_clk)
postamble, drive_dqs, dqs_t_d0, dqs_t_d1 = (Signal() for i in range(4)) postamble = Signal()
drive_dqs = Signal()
dqs_t_d0 = Signal()
dqs_t_d1 = Signal()
dqs_o = Signal(d//8) dqs_o = Signal(d//8)
dqs_t = Signal(d//8) dqs_t = Signal(d//8)
@ -131,7 +130,6 @@ class S6DDRPHY(Module):
] ]
for i in range(d//8): for i in range(d//8):
# DQS output # DQS output
self.specials += Instance("ODDR2", self.specials += Instance("ODDR2",
Instance.Parameter("DDR_ALIGNMENT", "C1"), Instance.Parameter("DDR_ALIGNMENT", "C1"),
@ -182,28 +180,32 @@ class S6DDRPHY(Module):
for i in range(2*nphases)] for i in range(2*nphases)]
for n, phase in enumerate(self.dfi.phases): for n, phase in enumerate(self.dfi.phases):
self.comb +=[ self.comb += [
d_dfi[n].wrdata.eq(phase.wrdata), d_dfi[n].wrdata.eq(phase.wrdata),
d_dfi[n].wrdata_mask.eq(phase.wrdata_mask), d_dfi[n].wrdata_mask.eq(phase.wrdata_mask),
d_dfi[n].wrdata_en.eq(phase.wrdata_en), d_dfi[n].wrdata_en.eq(phase.wrdata_en),
d_dfi[n].rddata_en.eq(phase.rddata_en), d_dfi[n].rddata_en.eq(phase.rddata_en),
] ]
sd_sys +=[ sd_sys += [
d_dfi[nphases+n].wrdata.eq(phase.wrdata), d_dfi[nphases+n].wrdata.eq(phase.wrdata),
d_dfi[nphases+n].wrdata_mask.eq(phase.wrdata_mask) d_dfi[nphases+n].wrdata_mask.eq(phase.wrdata_mask)
] ]
drive_dq, drive_dq_n, d_drive_dq, d_drive_dq_n = (Signal() for i in range(4)) drive_dq = Signal()
self.comb +=[ drive_dq_n = Signal()
d_drive_dq = Signal()
d_drive_dq_n = Signal()
self.comb += [
drive_dq_n.eq(~drive_dq), drive_dq_n.eq(~drive_dq),
d_drive_dq_n.eq(~d_drive_dq) d_drive_dq_n.eq(~d_drive_dq)
] ]
dq_t, dq_o, dq_i = (Signal(d) for i in range(3)) dq_t = Signal(d)
dq_o = Signal(d)
dq_i = Signal(d)
for i in range(d): for i in range(d):
# Data serializer # Data serializer
self.specials += Instance("OSERDES2", self.specials += Instance("OSERDES2",
Instance.Parameter("DATA_WIDTH", 4), Instance.Parameter("DATA_WIDTH", 4),
@ -240,7 +242,7 @@ class S6DDRPHY(Module):
Instance.Output("SHIFTOUT2"), Instance.Output("SHIFTOUT2"),
Instance.Output("SHIFTOUT3"), Instance.Output("SHIFTOUT3"),
Instance.Output("SHIFTOUT4"), Instance.Output("SHIFTOUT4"),
) )
# Data deserializer # Data deserializer
self.specials += Instance("ISERDES2", self.specials += Instance("ISERDES2",
@ -272,7 +274,7 @@ class S6DDRPHY(Module):
Instance.Output("VALID"), Instance.Output("VALID"),
Instance.Output("INCDEC"), Instance.Output("INCDEC"),
Instance.Output("SHIFTOUT") Instance.Output("SHIFTOUT")
) )
# Data buffer # Data buffer
self.specials += Instance("IOBUF", self.specials += Instance("IOBUF",
@ -280,10 +282,9 @@ class S6DDRPHY(Module):
Instance.Output("O", dq_i[i]), Instance.Output("O", dq_i[i]),
Instance.Input("T", dq_t[i]), Instance.Input("T", dq_t[i]),
Instance.InOut("IO", pads.dq[i]) Instance.InOut("IO", pads.dq[i])
) )
for i in range(d//8): for i in range(d//8):
# Mask serializer # Mask serializer
self.specials += Instance("OSERDES2", self.specials += Instance("OSERDES2",
Instance.Parameter("DATA_WIDTH", 4), Instance.Parameter("DATA_WIDTH", 4),
@ -320,7 +321,7 @@ class S6DDRPHY(Module):
Instance.Output("SHIFTOUT2"), Instance.Output("SHIFTOUT2"),
Instance.Output("SHIFTOUT3"), Instance.Output("SHIFTOUT3"),
Instance.Output("SHIFTOUT4"), Instance.Output("SHIFTOUT4"),
) )
# #
@ -329,7 +330,6 @@ class S6DDRPHY(Module):
self.comb += drive_dq.eq(d_dfi[phy_settings.wrphase].wrdata_en) self.comb += drive_dq.eq(d_dfi[phy_settings.wrphase].wrdata_en)
sd_sys += d_drive_dq.eq(drive_dq) sd_sys += d_drive_dq.eq(drive_dq)
d_dfi_wrdata_en = Signal() d_dfi_wrdata_en = Signal()
sd_sys += d_dfi_wrdata_en.eq(d_dfi[phy_settings.wrphase].wrdata_en) sd_sys += d_dfi_wrdata_en.eq(d_dfi[phy_settings.wrphase].wrdata_en)

View File

@ -8,7 +8,7 @@
#include "sdram.h" #include "sdram.h"
void cdelay(int i) static void cdelay(int i)
{ {
while(i > 0) { while(i > 0) {
__asm__ volatile("nop"); __asm__ volatile("nop");