2f263a21fcb641a3edd40b738a1946c958dec3dc
[libreriscv.git] / conferences / fosdem2024 / fosdem2024_tplaten / fosdem2024_tplaten.tex
1 \documentclass[slidestop]{beamer}
2 \usepackage{beamerthemesplit}
3 \usepackage{graphics}
4 \usepackage{pstricks}
5
6 \graphicspath{{./}}
7
8 \title{Using the ECP5 for Libre-SOC prototyping}
9 \author{Tobias Platen}
10
11
12 \begin{document}
13
14 \frame{
15 \begin{center}
16 \huge{Using the ECP5 for Libre-SOC prototyping}\\
17 \vspace{32pt}
18 \Large{Verification of the Libre-SOC core}\\
19 \Large{using an OrangeCrab feather form factor dev board}\\
20 \Large{and gram to drive the ddr3 ram and booting Linux}\\
21 \vspace{24pt}
22 \Large{FOSDEM2024}\\
23 \vspace{16pt}
24 \large{Sponsored by NLnet}\\
25 \vspace{6pt}
26 \large{\today}
27 \end{center}
28 }
29
30
31 \frame{\frametitle{Why using an ECP5 and OrangeCrab?}
32
33 \begin{itemize}
34 \item ECP5 and ICE40 have libre toolchains (Yosys, nextpnr)\vspace{6pt}
35 \item Microwatt already supports the OrangeCrab using LiteDRAM: \\
36 LiteDRAM depens on original Migen and does not fit into ls2\\
37 I was unable to rebuild the original one from Microwatt\\
38 and decided to continue working on (nMigen based) gram
39 \vspace{6pt}
40 \item ECP5 is big enough for prototyping the Libre-SOC core\\
41 When I started porting ls2 to the OrangeCrab I was able to\\
42 run coldboot.c and began adding support for gram
43 \vspace{6pt}
44 \item Because for 5 years I Always Wanted To Design A GPU
45 \vspace{6pt}
46 \item ICE40 also used by Valve and Bitcraze in several SteamVR
47 products and the Lighthouse positioning deck
48 \end{itemize}
49 }
50
51
52 \frame{\frametitle{Why nMigen and gram?}
53
54 \vspace{15pt}
55
56 \begin{itemize}
57 \item nMigen+LambdaSoC port of the LiteDRAM core\\
58 avoiding using old Migen and LiteX\\
59 only using nMigen used by Libre-SOC\vspace{10pt}
60 \item nMigen is much more powerful than Verilog and VHDL\\
61 and easier to use for anyone that knows python\\
62 (and works with yosys/nextpnr/gcc)\vspace{10pt}
63 \item gram is simplified, it only supports ECP5 atm\\
64 and maybe some Xilinx FPGAs in the future \vspace{10pt}
65 \item Wanting to learn how to use the dram phy that comes\\
66 with the ECP5. Then booting linux using the Libre-SOC core
67 \end{itemize}
68 }
69
70
71
72
73
74 \frame{\frametitle{How do DRAM interfaces work}
75 \vspace{9pt}
76 \begin{itemize}
77 \item Multiple generarions of DDR-SDRAM interfaces\\
78 POWER9: DDR4-SDRAM POWER10: DDR5-SDRAM
79 \vspace{3pt}
80 \item OrangeCrab has DDR3L Memory, 128 Mbytes (1Gbit)\\
81 64M x16, 1.35V low voltage operation (can boot linux)
82 \vspace{3pt}
83 \item See nmigen-boards for OrangeCrab pins \vspace{3pt}
84 \item Controller are found in gram and lite-dram\vspace{3pt}
85 \item Ideally gram and lite-dram should show identical behaviour\\
86 Reality: only lite-dram works out of the box
87 \vspace{3pt}
88 \item If it does not work debugging is hard\\
89 Found out that burstdet signal is not asserted on read
90 \end{itemize}
91 }
92
93 \frame{\frametitle{The ECP5 DRAM controller}
94
95 \begin{itemize}
96 \item see manual for ECP5 and ECP5-5G High-Speed I/O Interface\\
97 comes with many built-in blocks: DQSBUFM, DDRDLLA, ...\\
98 \textit{DQSBUFM} is the most interesting one\\
99 \vspace{6pt}
100 \item FPGA-TN-02035-1.3 documents DQSBUF \\
101 Data Strobe Control Block : Generates a BURSTDET output\\
102 that can be used to validate the READ pulse positioning\\
103 \vspace{6pt}
104 \item DQSBUFM element is used for all the DDR Memory\\
105 interfaces on ECP5 only. Other blocks used on Xilinx
106 \vspace{6pt}
107 \item Python implementation of DDR PHY for ECP5\\
108 git.libre-soc.org / gram.git / gram / phy / ecp5ddrphy.py\\
109 TODO same thing for microwatt / litedram\\
110 TODO http://isengaara.de/fosdem2024/ecp5ddrphy
111 %%% make url shortner
112 \vspace{6pt}
113 \end{itemize}
114 }
115
116
117
118 \frame{\frametitle{Typical DDR2/DDR3/DDR3L Memory Interface}
119 \begin{center}
120 \includegraphics[width=0.9\textwidth]{interface1.png}
121 \end{center}
122 }
123
124 \frame{\frametitle{DQSBUFM -- Inputs}
125 \begin{center}
126 \includegraphics[width=0.9\textwidth]{DQSBUFM_P1.png}
127 \end{center}
128 \begin{itemize}
129 \vspace{3pt}
130 \item BURSTDET used for read leveling
131 \item DATAVALID controls dfi.phases[0] and dfi.phases[1] latch
132 \end{itemize}
133 }
134
135 \frame{\frametitle{DQSBUFM -- Outputs}
136 \begin{center}
137 \includegraphics[width=0.9\textwidth]{DQSBUFM_P2.png}
138 \end{center}
139 \begin{itemize}
140 \vspace{3pt}
141 \item PAUSE controlled by init.pause and dqsbufm\_manager.pause
142 \item READCLKSEL used to set read leveling delay (3 bits)
143 \end{itemize}
144 }
145
146 \frame{\frametitle{How to use libgram}
147 \begin{itemize}
148 \item struct gramCtx with base addresses and user data
149 \item must call gram\_init(ctx, profile, ddr\_base, core\_base, phy\_base)
150 \vspace{6pt}
151 \item first phy is set to software control
152 \item init seq is peformed
153 \item then calibration is loaded
154 \item phy is set to hardware control back again
155 \vspace{6pt}
156 \item finally memtest must run, we can boot linux if passed
157 \vspace{6pt}
158 \item calibration is different from litedram
159 \end{itemize}
160 }
161
162 \frame{\frametitle{Read leveling in litedram}
163 \begin{itemize}
164 \item only read leveling used by ECP5
165 \item leveling must be done for each phy module
166 \vspace{6pt}
167 \item inner loop for bitslip
168 \item A test each read window (bitslip)
169 \item B find min/max delays
170 \item take bitslip with best score
171 \vspace{6pt}
172 \item Re-do leveling on best read window
173 \vspace{6pt}
174 \item Sync all DQSBUFM's before scan(A) / level(B)
175 \item Live demo using Microwatt
176 \end{itemize}
177 }
178
179 \frame{\frametitle{Write/readback test under software control}
180 \begin{itemize}
181 \item Generate pseudo-random sequence
182 \item Activate test row
183 \item Write pseudo-random sequence
184 \vspace{6pt}
185 \item ECP5: reset burstdet for current module
186 \item Read/Check pseudo-random sequence
187 \item Precharge
188 \vspace{6pt}
189 \item Read back test pattern
190 \item Verify bytes matching current module
191 \item ECP5: check burstdet for current module
192 \vspace{9pt}
193 \item DQSBUFM's not synced if burstdet is 0
194 \item not yet implemented in gram
195 \end{itemize}
196 }
197
198 \frame{\frametitle{Debugging with BeagleWire}
199 \begin{itemize}
200 \item Fully Open iCE40 FPGA BeagleBone Cape
201 \item 32 MB SDRAM and controller written in Verilog
202 \item GPMC port access from the BeagleBone
203 \vspace{6pt}
204 \item no port to nMigen yet, toolchain on BBB
205 \item connect to ECP5 to exchange data with host PC
206 \item use SPI or I2CSlave for debugging
207 \vspace{6pt}
208 \item use as ROM emulator TODO
209 \item intercept read/write to SDRAM
210 \item run gdbserver on BeagleBoneBlack
211 \vspace{9pt}
212 \item Long term: make EOMA68 card with Solid Silicon X1
213 \item Two FPGAs and 512MB of DDR3 RAM
214 \end{itemize}
215 }
216
217 \frame{\frametitle{Porting nMigen to BeagleWire}
218 \begin{itemize}
219 \item There is only a LiteX port ATM
220 \item Toolchain (yosys/arachne-pnr) running on BeagleBone
221 \item Use python to control cross compile
222 \vspace{6pt}
223 \item run yosys on host PC, replace arachne-pnr
224 \item generate bitstring for multiple FPGAs if needed
225 \item control flashing via ssh, upload bitstring via scp
226 \vspace{6pt}
227 \item Unrelated to Libre-SOC: plans to make Lighthouse PMOD
228 \item LibrePlanet 2022: The LibreVR Project
229 \item http://librevr.isengaara.de
230 \vspace{9pt}
231 \item VR Headset will depend on Libre-SOC GPU
232 \item run DOOM on iCE40/ECP5 FPGA -\> VGA output needed
233 \end{itemize}
234 }
235
236 % TODO: add one more slide
237
238 \frame{\frametitle{Summary}
239
240 \begin{itemize}
241 \item Microwatt can boot linux+buildroot on the OrangeCrab using LiteDRAM.
242 Libre-SOC using ls2 needs more work on gram, including porting to
243 other FPGAs.
244 \item High speed interfaces differ between FPGA models and vendors and are hard to debug
245 without using a simulator.
246 \item Software gets more complex for larger designs, development becomes
247 more expensive. Changes easily break everything.
248 \item Once DRAM is working we can add other interfaces.
249 \item Larger FPGA may be needed to prototype advanced features including
250 GPU und display controller
251 \item We can use the BeagleWire as a host computer interface
252 \end{itemize}
253 }
254
255
256 \frame{
257 \begin{center}
258 {\Huge The end\vspace{12pt}\\
259 Thank you\vspace{12pt}\\
260 Questions?\vspace{12pt}
261 }
262 \end{center}
263
264 \begin{itemize}
265 \item Discussion: http://lists.libre-soc.org
266 \item Freenode IRC \#libre-soc
267 \item http://libre-soc.org/
268 \item http://nlnet.nl/PET
269 \item https://libre-soc.org/nlnet/\#faq
270 \end{itemize}
271 }
272
273
274 \end{document}