litex/milkymist/s6ddrphy/__init__.py

52 lines
1.1 KiB
Python
Raw Normal View History

from migen.fhdl.structure import *
from migen.bus import dfi
class S6DDRPHY:
2012-02-19 12:43:42 -05:00
def __init__(self, a, ba, d):
ins = []
outs = []
inouts = []
for name, width, l in [
("clk2x_270", 1, ins),
("clk4x_wr", 1, ins),
("clk4x_wr_strb", 1, ins),
("clk4x_rd", 1, ins),
("clk4x_rd_strb", 1, ins),
("sd_clk_out_p", 1, outs),
("sd_clk_out_n", 1, outs),
("sd_a", a, outs),
("sd_ba", ba, outs),
("sd_cs_n", 1, outs),
("sd_cke", 1, outs),
("sd_ras_n", 1, outs),
("sd_cas_n", 1, outs),
("sd_we_n", 1, outs),
2012-02-19 12:43:42 -05:00
("sd_dq", d//2, inouts),
("sd_dm", d//16, outs),
("sd_dqs", d//16, inouts)
]:
s = Signal(BV(width), name=name)
setattr(self, name, s)
l.append((name, s))
2012-02-19 12:43:42 -05:00
self.dfi = dfi.Interface(a, ba, d, 2)
ins += self.dfi.get_standard_names(True, False)
outs += self.dfi.get_standard_names(False, True)
2012-02-19 12:43:42 -05:00
self._inst = Instance("s6ddrphy",
outs,
ins,
inouts,
[
("NUM_AD", a),
("NUM_BA", ba),
2012-02-19 12:43:42 -05:00
("NUM_D", d)
],
2012-02-19 12:43:42 -05:00
clkport="sys_clk")
def get_fragment(self):
return Fragment(instances=[self._inst])