class S6DDRPHY:
def __init__(self, a, ba, d):
- ins = []
- outs = []
- inouts = []
-
- for name in [
- "clk2x_270",
- "clk4x_wr",
- "clk4x_wr_strb",
- "clk4x_rd",
- "clk4x_rd_strb"
- ]:
- s = Signal(name=name)
- setattr(self, name, s)
- ins.append((name, s))
-
- self._sd_pins = []
- for name, width, l in [
- ("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),
- ("sd_dq", d//2, inouts),
- ("sd_dm", d//16, outs),
- ("sd_dqs", d//16, inouts)
+ inst_items = [
+ Instance.Parameter("NUM_AD", a),
+ Instance.Parameter("NUM_BA", ba),
+ Instance.Parameter("NUM_D", d),
+ Instance.ClockPort("sys_clk")
+ ]
+ for name, width, cl in [
+ ("clk2x_270", 1, Instance.Input),
+ ("clk4x_wr", 1, Instance.Input),
+ ("clk4x_wr_strb", 1, Instance.Input),
+ ("clk4x_rd", 1, Instance.Input),
+ ("clk4x_rd_strb", 1, Instance.Input),
+
+ ("sd_clk_out_p", 1, Instance.Output),
+ ("sd_clk_out_n", 1, Instance.Output),
+ ("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)
]:
s = Signal(BV(width), name=name)
setattr(self, name, s)
- l.append((name, s))
- self._sd_pins.append(s)
+ inst_items.append(cl(name, s))
self.dfi = dfi.Interface(a, ba, d, 2)
- ins += self.dfi.get_standard_names(True, False)
- outs += self.dfi.get_standard_names(False, True)
+ 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)]
- self._inst = Instance("s6ddrphy",
- outs,
- ins,
- inouts,
- [
- ("NUM_AD", a),
- ("NUM_BA", ba),
- ("NUM_D", d)
- ],
- clkport="sys_clk")
+ self._inst = Instance("s6ddrphy", *inst_items)
def get_fragment(self):
- return Fragment(instances=[self._inst], pads=set(self._sd_pins))
+ return Fragment(instances=[self._inst])