2012-02-17 05:04:44 -05:00
|
|
|
from migen.fhdl.structure import *
|
2013-02-24 07:07:25 -05:00
|
|
|
from migen.fhdl.specials import Instance
|
2013-03-10 14:32:38 -04:00
|
|
|
from migen.fhdl.module import Module
|
2012-02-17 05:04:44 -05:00
|
|
|
from migen.bus import dfi
|
|
|
|
|
2013-03-10 14:32:38 -04:00
|
|
|
class S6DDRPHY(Module):
|
2012-02-19 12:43:42 -05:00
|
|
|
def __init__(self, a, ba, d):
|
2012-09-10 17:47:06 -04:00
|
|
|
inst_items = [
|
|
|
|
Instance.Parameter("NUM_AD", a),
|
|
|
|
Instance.Parameter("NUM_BA", ba),
|
|
|
|
Instance.Parameter("NUM_D", d),
|
2013-03-18 12:44:01 -04:00
|
|
|
Instance.Input("sys_clk", ClockSignal()),
|
|
|
|
Instance.Input("clk2x_270", ClockSignal("sys2x_270")),
|
|
|
|
Instance.Input("clk4x_wr", ClockSignal("sys4x_wr")),
|
|
|
|
Instance.Input("clk4x_rd", ClockSignal("sys4x_rd"))
|
2012-09-10 17:47:06 -04:00
|
|
|
]
|
|
|
|
for name, width, cl in [
|
|
|
|
("clk4x_wr_strb", 1, Instance.Input),
|
|
|
|
("clk4x_rd_strb", 1, Instance.Input),
|
2012-04-02 13:22:17 -04:00
|
|
|
|
2012-09-10 17:47:06 -04:00
|
|
|
("sd_a", a, Instance.Output),
|
|
|
|
("sd_ba", ba, Instance.Output),
|
|
|
|
("sd_cs_n", 1, Instance.Output),
|
|
|
|
("sd_cke", 1, Instance.Output),
|
|
|
|
("sd_ras_n", 1, Instance.Output),
|
|
|
|
("sd_cas_n", 1, Instance.Output),
|
|
|
|
("sd_we_n", 1, Instance.Output),
|
|
|
|
("sd_dq", d//2, Instance.InOut),
|
|
|
|
("sd_dm", d//16, Instance.Output),
|
|
|
|
("sd_dqs", d//16, Instance.InOut)
|
2012-02-17 05:04:44 -05:00
|
|
|
|
|
|
|
]:
|
2012-11-29 17:38:04 -05:00
|
|
|
s = Signal(width, name=name)
|
2012-02-17 05:04:44 -05:00
|
|
|
setattr(self, name, s)
|
2012-09-10 17:47:06 -04:00
|
|
|
inst_items.append(cl(name, s))
|
2012-02-17 05:04:44 -05:00
|
|
|
|
2012-02-19 12:43:42 -05:00
|
|
|
self.dfi = dfi.Interface(a, ba, d, 2)
|
2012-09-10 17:47:06 -04:00
|
|
|
inst_items += [Instance.Input(name, signal)
|
|
|
|
for name, signal in self.dfi.get_standard_names(True, False)]
|
|
|
|
inst_items += [Instance.Output(name, signal)
|
|
|
|
for name, signal in self.dfi.get_standard_names(False, True)]
|
2012-02-17 05:04:44 -05:00
|
|
|
|
2013-03-10 14:32:38 -04:00
|
|
|
self.specials += Instance("s6ddrphy", *inst_items)
|