@@ -18,8 +18,8 @@ def __init__(self):
1818 super ().__init__ ({
1919 "clk" : Out (OutputPinSignature (1 )),
2020 "csn" : Out (OutputPinSignature (1 )),
21- "d" : Out ( BidirPinSignature ( 4 )),
22- })
21+ } |
22+ { f"d { n } " : Out ( BidirPinSignature ( 1 )) for n in range ( 4 ) })
2323
2424 def create (self , * , path = (), src_loc_at = 0 ):
2525 return QSPIPins (path = path , src_loc_at = 1 + src_loc_at )
@@ -83,32 +83,28 @@ def elaborate(self, platform):
8383 spi_ready = Signal ()
8484 # TODO : QSPI
8585
86- m .submodules .spimemio = Instance (
87- "spimemio" ,
88- i_clk = ClockSignal (),
89- i_resetn = ~ ResetSignal (),
90- i_valid = self .data_bus .cyc & self .data_bus .stb ,
91- o_ready = spi_ready ,
92- i_addr = Cat (Const (0 , 2 ), self .data_bus .adr ), # Hack to force a 1MB offset
93- o_rdata = self .data_bus .dat_r ,
94- o_flash_csb = self .flash .csn .o ,
95- o_flash_clk = self .flash .clk .o ,
96- o_flash_io0_oe = self .flash .d .oe [0 ],
97- o_flash_io1_oe = self .flash .d .oe [1 ],
98- o_flash_io2_oe = self .flash .d .oe [2 ],
99- o_flash_io3_oe = self .flash .d .oe [3 ],
100- o_flash_io0_do = self .flash .d .o [0 ],
101- o_flash_io1_do = self .flash .d .o [1 ],
102- o_flash_io2_do = self .flash .d .o [2 ],
103- o_flash_io3_do = self .flash .d .o [3 ],
104- i_flash_io0_di = self .flash .d .i [0 ],
105- i_flash_io1_di = self .flash .d .i [1 ],
106- i_flash_io2_di = self .flash .d .i [2 ],
107- i_flash_io3_di = self .flash .d .i [3 ],
108- i_cfgreg_we = ctrl_bridge .cfgreg_we ,
109- i_cfgreg_di = ctrl_bridge .cfgreg_di ,
110- o_cfgreg_do = ctrl_bridge .cfgreg_do ,
111- )
86+ verilog_map = {
87+ "i_clk" : ClockSignal (),
88+ "i_resetn" : ~ ResetSignal (),
89+ "i_valid" : self .data_bus .cyc & self .data_bus .stb ,
90+ "o_ready" : spi_ready ,
91+ "i_addr" : Cat (Const (0 , 2 ), self .data_bus .adr ), # Hack to force a 1MB offset
92+ "o_rdata" : self .data_bus .dat_r ,
93+ "o_flash_csb" : self .flash .csn .o ,
94+ "o_flash_clk" : self .flash .clk .o ,
95+ "i_cfgreg_we" : ctrl_bridge .cfgreg_we ,
96+ "i_cfgreg_di" : ctrl_bridge .cfgreg_di ,
97+ "o_cfgreg_do" : ctrl_bridge .cfgreg_do ,
98+ } | {
99+ f"o_flash_io{ n } _oe" : getattr (self .flash , f"d{ n } " ).oe for n in range (4 )
100+ } | {
101+ f"o_flash_io{ n } _o" : getattr (self .flash , f"d{ n } " ).o for n in range (4 )
102+ } | {
103+ f"o_flash_io{ n } _i" : getattr (self .flash , f"d{ n } " ).i for n in range (4 )
104+ }
105+
106+ m .submodules .spimemio = Instance ("spimemio" , ** verilog_map )
107+
112108 # From https://github.com/im-tomu/foboot/blob/master/hw/rtl/picorvspi.py
113109 read_active = Signal ()
114110 with m .If (self .data_bus .stb & self .data_bus .cyc & ~ read_active ):
0 commit comments