add links
[libreriscv.git] / shakti / m_class.mdwn
1 # Shakti M-Class Libre SoC
2
3 This SoC is a propsed libre design that draws in expertise from mass-volume
4 SoCs of the past six years and beyond, and is being designed to cover just
5 as wide a range of target embedded / low-power / industrial markets as those
6 SoCs. Pincount is to be kept low in order to reduce cost as well as increase
7 yields.
8
9 * See <http://rise.cse.iitm.ac.in/shakti.html> M-Class for top-level
10 * See [[pinouts]] for auto-generated table of pinouts (including mux)
11 * See [[peripheralschematics]] for example Reference Layouts
12 * See [[ramanalysis]] for a comprehensive analysis of why DDR3 is to be used.
13 * See [[todo]] for a rough list of tasks (and link to bugtracker)
14
15 ## Rough specification.
16
17 Quad-core 28nm RISC-V 64-bit (RISCV64GC core with Vector SIMD Media / 3D
18 extensions), 300-pin 15x15mm BGA 0.8mm pitch, 32-bit DDR3/DDR3L/LPDDR3
19 memory interface and libre / open interfaces and accelerated hardware
20 functions suitable for the higher-end, low-power, embedded, industrial
21 and mobile space.
22
23 A 0.8mm pitch BGA allows relatively large (low-cost) VIA drill sizes
24 to be used (8-10mil) and 4-5mil tracks with 4mil clearance. For
25 details see
26 <http://processors.wiki.ti.com/index.php/General_hardware_design/BGA_PCB_design>
27
28 [[shakti_libre_riscv.jpg]]
29
30 ## Targetting full Libre Licensing to the bedrock.
31
32 The only barrier to being able to replicate the masks from scratch
33 is the proprietary cells (e.g. memory cells) designed by the Foundries:
34 there is a potential long-term strategy in place to deal with that issue.
35
36 The only proprietary interface utilised in the entire SoC is the DDR3
37 PHY plus Controller, which will be replaced in a future revision, making
38 the entire SoC exclusively designed and made from fully libre-licensed
39 BSD and LGPL openly and freely accessible VLSI and VHDL source.
40
41 In addition, no proprietary firmware whatsoever will be required to
42 operate or boot the device right from the bedrock: the entire software
43 stack will also be libre-licensed (even for programming the initial
44 proprietary DDR3 PHY+Controller)
45
46 # Inspiration from several sources
47
48 The design of this SoC is drawn from at least the following SoCs, which
49 have significant multiplexing for pinouts, reducing pincount whilst at
50 the same time permitting the SoC to be utilised across a very wide range
51 of markets:
52
53 * A10/A20 EVB <http://hands.com/~lkcl/eoma/A10-EVB-V1-2-20110726.pdf>
54 * RK3288 T-Firefly <http://www.t-firefly.com/download/firefly-rk3288/hardware/FR_RK3288_0930.pdf>
55 * Ingenic JZ4760B <ftp://ftp.ingenic.cn/SOC/JZ4760B/JZ4760B_DS_REVISION.PDF>
56 LEPUS Board <ftp://ftp.ingenic.cn/DevSupport/Hardware/RD4760B_LEPUS/RD4760B_LEPUS_V1.3.2.PDF>
57 * GPL-violating CT-PC89e <http://hands.com/~lkcl/seatron/>,
58 and <http://lkcl.net/arm_systems/CT-PC89E/> this was an 8.9in netbook
59 weighing only 0.72kg and having a 3 HOUR battery life on a single 2100mAh
60 cell, its casework alone inspired a decade of copycat china clone
61 netbooks as it was slowly morphed from its original 8.9in up to (currently)
62 an 11in form-factor almost a decade later in 2017.
63 * A64 Reference Designs for example this: <http://linux-sunxi.org/images/3/32/Banana_pi_BPI-M64-V1_1-Release_201609.pdf>
64
65 TI Boards such as the BeagleXXXX Series, or the Freescale iMX6
66 WandBoard etc., are, whilst interesting, have a different kind of focus
67 and "feel" about them, as they are typically designed by Western firms
68 with less access or knowledge of the kinds of low-cost tricks deployed
69 to ingenious and successful effect by Chinese Design Houses. Not only
70 that but they typically know the best components to buy. Western-designed
71 PCBs typically source exclusively from Digikey, AVNet, Mouser etc. and
72 the prices are often two to **TEN** times more costly as a result.
73
74 The TI and Freescale (now NXP) series SoCs themselves are also just as
75 interesting to study, but again have a subtly different focus: cost of
76 manufacture of PCBs utilising them not being one of those primary focii.
77 Freescale's iMX6 is well-known for its awesome intended lifespan and support:
78 **ninteen** years. That does however have some unintended knock-on effects
79 on its pricing.
80
81 Instead, the primary input is taken from Chinese-designed SoCs, where cost
82 and ease of production, manufacturing and design of a PCB using the planned
83 SoC, as well as support for high-volume mass-produced peripherals is
84 firmly a priority focus.
85
86 # Target Markets
87
88 * EOMA68 Computer Card form-factor (general-purpose, eco-conscious)
89 * Smartphone / Tablet (basically the same thing, different LCD/CTP size)
90 * Low-end (ChromeOS style) laptop
91 * Industrial uses when augmented by a suitable MCU (for ADC/DAC/CAN etc.)
92
93 ## Common Peripherals to majority of target markets
94
95 * SPI or 8080 or RGB/TTL or LVDS LCD display. SPI: 320x240. LVDS: 1440x900.
96 * LCD Backlight, requires GPIO power-control plus PWM for brightness control
97 * USB-OTG Port (OTG-Host, OTG Client, Charging capability)
98 * Baseband Modem (GSM / GPRS / 3G / LTE) requiring USB, UART, and PCM audio
99 * Bluetooth, requires either full UART or SD/MMC or USB, plus control GPIO
100 * WIFI, requires either USB (but with power penalties) or better SD/MMC
101 * SD/MMC for external MicroSD
102 * SD/MMC for on-PCB eMMC (care needed on power/boot sequence)
103 * NAND Flash (not recommended), requires 8080/ATI-style Bus with dedicated CS#
104 * Optional 4-wire SPI NAND/NOR for boot (XIP - Execute In-place - recommended).
105 * Audio over [[I2S]] (5-pin: 4 for output, 1 for input), fall-back to USB Audio
106 * Audio also over [[AC97]]
107 * Some additional SPI peripherals, e.g. connection to low-power MCU.
108 * GPIO (EINT-capable, with wakeup) for buttons, power, volume etc.
109 * Camera(s) either by CSI-1 (parallel CSI) or better by USB
110 * I2C sensors: accelerometer, compass, etc. Each requires EINT and RST GPIO.
111 * Capacitive Touchpanel (I2C and also requiring EINT and RST GPIO)
112 * Real-time Clock (usually an I2C device but may be on-board a support MCU)
113
114 ## Peripherals unique to laptop market
115
116 * Keyboard (USB or keyboard-matrix managed by MCU)
117 * USB, I2C or SPI Mouse-trackpad (plus button GPIO, EINT capable)
118
119 ## Peripherals common to laptop and Industrial Market
120
121 * Ethernet (RGMII or better 8080-style XT/AT/ATI MCU bus)
122
123 ## Augmentation by an embedded MCU
124
125 Some functions, particularly analog, are particularly tricky to implement
126 in an early SoC. In addition, CAN is still patented. For unusual, patented
127 or analog functionality such as CAN, RTC, ADC, DAC, SPDIF, One-wire Bus
128 and so on it is easier and simpler to deploy an ultra-low-cost low-speed
129 companion Micro-Controller such as the crystal-less STMS8003 ($0.24) or
130 the crystal-less STM32F072 or other suitable MCU, depending on requirements.
131 For high-speed interconnect it may be wired up as an SPI device, and for
132 lower-speed communication UART would be the simplest and easiest means of
133 two-way communication.
134
135 This technique can be deployed in all scenarios (phone, tablet, laptop,
136 industrial), and is an extremely low-cost way of getting RTC functionality
137 for example. The cost of, for example, dedicated I2C sensors that provide
138 RTC functionality, or ADC or DAC or "Digipot", are actually incredibly
139 high, relatively speaking. Some very simple software and a general-purpose
140 MCU does the exact same job. In particularly cost-sensitive applications,
141 DAC may be substituted by a PWM, an RC circuit, and an optional feedback
142 loop into an ADC pin to monitor situations where changing load on the RC
143 circuit alters the output voltage. All done entirely in the MCU's software.
144
145 An MCU may even be used to emulate SPI "XIP" (Execute in-place) NAND
146 memory, such that there is no longer a need to deploy a dedicated SPI
147 NOR bootloader IC (which are really quite expensive). By emulating
148 an SPI XIP device the SoC may boot from the NAND Flash storage built-in
149 to the embedded MCU, or may even feed the SoC data from a USB-OTG
150 or other interface. This makes for an extremely flexible bootloader
151 capability, without the need for totally redoing the SoC masks just to
152 add extra BOOTROM functions.
153
154 ## Common Internal (on-board) acceleration and hardware functions
155
156 * 2D accelerated display
157 * 3D accelerated graphics
158 * Video encode / decode
159 * Image encode / decode
160 * Crypto functions (SHA, Rijndael, DES, etc., Diffie-Hellman, RSA)
161 * Cryptographically-secure PRNG (hard to get right)
162
163 ### 2D acceleration
164
165 The ORSOC GPU contains basic primitives for 2D: rectangles, sprites,
166 image acceleration, scalable fonts, and Z-buffering and much more.
167
168 <https://opencores.org/project,orsoc_graphics_accelerator>
169
170 ### 3D acceleration
171
172 * MIAOW: ATI-compatible shader engine <http://miaowgpu.org/>
173 * ORSOC GPU contains some primitives that can be used
174 * SIMD RISC-V extensions can obviate the need for a "full" separate GPU
175
176 ### Video encode / decode
177
178 * video primitives <https://opencores.org/project,video_systems>
179 * MPEG decoder <https://opencores.org/project,mpeg2fpga>
180 * Google make free VP8 and VP9 hard macros available for production use only
181
182 ### Image encode / decode
183
184 partially covered by the ORSOC GPU
185
186 ### Crypto functions
187
188 TBD
189
190 ### Cryptographically-secure PRNG
191
192 TBD
193
194 # Proposed Interfaces
195
196 * Plain [[GPIO]] multiplexed with a [[pinmux]] onto (nearly) all other pins
197 * RGB/TTL up to 1440x900 @ 60fps, 24-bit colour
198 * 2x 1-lane SPI
199 * 1x 4-lane (quad) SPI
200 * 4x SD/MMC (1x 1/2/4/8-bit, 3x 1/2/4-bit)
201 * 2x full UART incl. CTS/RTS
202 * 3x UART (TX/RX only)
203 * 3x [[I2C]] (in case of address clashes between peripherals)
204 * 8080-style AT/XT/ATI MCU Bus Interface, with multiple (8x CS#) lines
205 * 3x [[PWM]]-capable GPIO
206 * 32x [[EINT]]-cable GPIO with full edge-triggered and low/high IRQ capability
207 * 1x [[I2S]] audio with 4-wire output and 1-wire input.
208 * 3x USB2 (ULPI for reduced pincount) each capable of USB-OTG support
209 * DDR3/DDR3L/LPDDR3 32-bit-wide memory controller
210
211 Some interfaces at:
212
213 * <https://github.com/RoaLogic/apb4_gpio>
214 * <https://github.com/sifive/sifive-blocks/tree/master/src/main/scala/devices/>
215 includes GPIO, SPI, UART, JTAG, I2C, PinCtrl, UART and PWM. Also included
216 is a Watchdog Timer and others.
217 * <https://github.com/sifive/freedom/blob/master/src/main/scala/everywhere/e300artydevkit/Platform.scala>
218 Pinmux ("IOF") for multiplexing several I/O functions onto a single pin
219 * <https://bitbucket.org/casl/c-class/src/0e77398a030bfd705930d0f1b8b9b5050d76e265/src/peripherals/?at=master>
220 including AXI, DMA, GPIO, I2C, JTAG, PLIC, QSPI, SDRAM, UART (and TCM?). FlexBus, HyperBus and xSPI to
221 be added.
222
223 List of Interfaces:
224
225 * [[I2C]]
226 * [[I2S]]
227 * [[PWM]]
228 * [[EINT]]
229 * [[FlexBus]]
230 * LCD / RGB/TTL [[RGBTTL]]
231 * [[SPI]]
232 * SD/MMC and eMMC [[sdmmc]]
233 * Pin Multiplexing [[pinmux]]
234 * Gigabit Ethernet [[RGMII]]
235
236 List of Internal Interfaces:
237
238 * [[AXI]]
239 * [[wishbone]]
240
241 # Items requiring clarification, or proposals TBD
242
243 ## Core Voltage Domains from the PMIC
244
245 See [[peripheralschematics]] - what default (start-up) voltage can the
246 core of the proposed 28nm SoC cope with for short durations? The AXP209
247 PMIC defaults to a 1.25v CPU core voltage, and 1.2v for the logic. It
248 can be changed by the SoC by communicating over I2C but the start-up
249 voltage of the PMIC may not be changed. What is the maximum voltage
250 that the SoC can run at, for short durations at a greatly-reduced clock rate?
251
252 ## 3.3v tolerance
253
254 Can the GPIO be made at least 3.3v tolerant?
255
256 ## Shakti Flexbus implementation: 32-bit word-aligned access
257
258 The FlexBus implementation may only make accesses onto the back-end
259 AXI bus on 32-bit word-aligned boundaries. How this affects FlexBus
260 memory accesses (read and write) on 8-bit and 16-bit boundaries is
261 yet to be determined. It is particularly relevant e.g. for 24-bit
262 pixel accesses on 8080 (MCU) style LCD controllers that have their
263 own on-board SRAM.
264
265 ## Confirmation of GPIO Power Domains
266
267 The proposed plan is to stick with a fixed 1.8v GPIO level across all
268 GPIO banks. However as outlined in the section above, this has some
269 distinct disadvantages, particularly for e.g. SRAM access over FlexBus:
270 that would often require a 50-way bi-directional level-shifter Bus IC,
271 with over 100 pins!
272
273 ## Proposal / Concept to include "Minion Cores" on a 7-way pinmux
274
275 The lowRISC team first came up with the idea, instead of having a pinmux,
276 to effectively bit-bang pretty much all GPIO using **multiple** 32-bit
277 RISC-V non-SMP integer-only cores each with a tiny instruction and data
278 cache (or, simpler, access to their own independent on-die SRAM).
279 The reasoning behind this is: if it's a dedicated core, it's not really
280 bit-banging any more. The technique is very commonly deployed, typically
281 using an 8051 MCU engine, as it means that a mass-produced peripheral may
282 be firmware-updated in the field for example if a Standard has unanticipated
283 flaws or otherwise requires updating.
284
285 The proposal here is to add four extra pin-mux selectors (an extra bit
286 to what is currently a 2-bit mux per pin), and for each GPIO bank to map to
287 one of four such ultra-small "Minion Cores". For each pin, Pin-mux 4 would
288 select the first Minion core, Pin-mux 5 would select the second and so on.
289 The sizes of the GPIO banks are as follows:
290
291 * Bank A: 16
292 * Bank B: 28
293 * Bank C: 24
294 * Bank D: 24
295 * Bank E: 24
296 * Bank F: 10
297
298 Therefore, it is proposed that each Minion Core have 28 EINT-capable
299 GPIOs, and that all but Bank A and F map their GPIO number (minus the
300 Bank Designation letter) direct to the Minion Core GPIOs. For Banks
301 A and F, the numbering is proposed to be concatenated, so that A0 through
302 A15 maps to a Minion Core's GPIO 0 to 15, and F0 to F10 map to a Minion
303 Core's GPIO 16 to 25 (another alternative idea would be to split Banks
304 A and F to complete B through E, taking them up to 32 I/O per Minion core).
305
306 With careful selection from different banks it should be possible to map
307 unused spare pins to a complete, contiguous, sequential set of any given
308 Minion Core, such that the Minion Core could then bit-bang anything up to
309 a 28-bit-wide Bus. Theoretically this could make up a second RGB/TTL
310 LCD interface with up to 24 bits per pixel.
311
312 For low-speed interfaces, particularly those with an independent clock
313 that the interface takes into account that the clock changes on a different
314 time-cycle from the data, this should work perfectly fine. Whether the
315 idea is practical for higher-speed interfaces or or not will critically
316 depend on whether the Minion Core can do mask-spread atomic
317 reads/writes from a register to/from memory-addressed GPIO or not,
318 and faster I/O streams will almost certainly require some form of
319 serialiser/de-serialiser hardware-assist, and definitely each their
320 own DMA Engine.
321
322 If the idea proves successful it would be extremely nice to have a
323 future version that has direct access to generic LVDS lines, plus
324 S8/10 ECC hardware-assist engines. If the voltage may be set externally
325 and accurate PLL clock timing provided, it may become possible to bit-bang
326 and software-emulate high-speed interfaces such as SATA, HDMI, PCIe and
327 many more.
328
329 # Research (to investigate)
330
331 * <https://level42.ca/projects/ultra64/Documentation/man/pro-man/pro25/index25.1.html>
332 * <http://n64devkit.square7.ch/qa/graphics/ucode.htm>
333 * <https://dac.com/media-center/exhibitor-news/synopsys%E2%80%99-designware-universal-ddr-memory-controller-delivers-30-percent> 110nm DDR3 PHY
334 [[!tag cpus]]
335