462bc05dceccc154fc220ef3b4f2f06c3e5f9e35
[libreriscv.git] / docs / pinmux.mdwn
1 # Pinmux, IO Pads, and JTAG Boundary scan
2
3 Links:
4
5 * <http://www2.eng.cam.ac.uk/~dmh/4b7/resource/section14.htm>
6 * <https://ftp.libre-soc.org/Pin_Control_Subsystem_Overview.pdf>
7 * <https://bugs.libre-soc.org/show_bug.cgi?id=50>
8
9 Managing IO on an ASIC is nowhere near as simple as on an FPGA.
10 An FPGA has built-in IO Pads, the wires terminate inside an
11 existing silicon block which has been tested for you. In an
12 ASIC, a bi-directional IO Pad requires three wires (in, out,
13 out-enable) to be routed right the way from the ASIC, all
14 the way to the IO PAD, where only then does a wire bond connect
15 it to a single pin.
16
17 [[!img CH02-44.gif]]
18
19 Designing an ASIC, there is no guarantee that the IO pad is
20 working when manufactured. Worse, the peripheral could be
21 faulty. How can you tell what the cause is? There are two
22 possible faults, but only one symptom ("it dunt wurk").
23 This problem is what JTAG Boundary Scan is designed to solve.
24 JTAG can be operated from an external digital clock,
25 at very low frequencies (5 khz is perfectly acceptable)
26 so there is very little risk of clock skew during that testing.
27
28 Additionally, an SoC is designed to be low cost, to use low cost
29 packaging. ASICs are typically 32 to 128 pins QFP
30 only in the Embedded
31 Controller range, and between 300 to 650 FBGA in the Tablet /
32 Smartphone range, absolute maximum of 19 mm on a side.
33 1,000 pin packages common to Intel desktop processors are
34 absolutely out of the question.
35
36 (*With each pin wire bond smashing
37 into the ASIC using purely heat of impact to melt the wire,
38 cracks in the die can occur. The more times
39 the bonding equipment smashes into the die, the higher the
40 chances of irreversible damage, hence why larger pin packaged
41 ASICs are much more expensive: not because of their manufacturing
42 cost but because far more of them fail due to having been
43 literally hit with a hammer many more times*)
44
45 Yet, the expectation from the market is to be able to fit 1,000++
46 pins worth of peripherals into only 200 to 400 worth of actual
47 IO Pads. The solution here: a GPIO Pinmux, described in some
48 detail here <https://ftp.libre-soc.org/Pin_Control_Subsystem_Overview.pdf>
49
50 This page goes over the details and issues involved in creating
51 an ASIC that combines **both** JTAG Boundary Scan **and** GPIO
52 Muxing, down to layout considerations using coriolis2.
53
54 # JTAG Boundary Scan
55
56 JTAG Scanning is a (paywalled) IEEE Standard: 1149.1 which with
57 a little searching can be found online. Its purpose is to allow
58 a well-defined method of testing ASIC IO pads that a Foundry or
59 ASIC test house may apply easily with off-the-shelf equipment.
60 Scan chaining can also connect multiple ASICs together so that
61 the same test can be run on a large batch of ASICs at the same
62 time.
63
64 IO Pads come in four primary different types:
65
66 * Input
67 * Output
68 * Output with Tristate (enable)
69 * Bi-directional Input/Output with direction enable
70
71 Interestingly these can all be synthesised from one
72 Bi-directional IO Pad. Other features such as Differential
73 Pairs may also be constructed from an inverter and a pair
74 of IO Pads. Other more advanced features include pull-up
75 and pull-down resistors, Schmidt triggering for interrupts,
76 different drive strengths, and so on, but the basics are
77 that the Pad is either an input, or an output, or both.
78
79 The JTAG Boundary Scan therefore needs to know what type
80 each pad is (In/Out/Bi) and has to "insert" itself in between
81 the wires, which may be just an input, or just an output,
82 and, if bi-directional, an "output enable" line.
83
84 The "insertion" (or, "Tap") into those wires requires a
85 pair of Muxes for each wire. Under normal operation
86 the Muxes bypass JTAG entirely: the IO Pad is connected
87 directly to the Core (a hardware term for a "peripheral",
88 in Software terminology).
89
90 When JTAG Scan is enabled, then for every pin that is
91 "tapped into", the Muxes flip such that:
92
93 * The IO Pad is connected directly to latches controlled
94 by the JTAG Shift Register
95 * The Core (peripheral) likewise but to *different bits*
96 from those that the Pad is connected to
97
98 In this way, not only can JTAG control or read the IO Pad,
99 but it can also read or control the Core (peripheral).
100 This is its entire purpose: to allow for the detection
101 and triaging of faults.
102
103 <img src="https://libre-soc.org/shakti/m_class/JTAG/jtag-block.jpg"
104 width=500 />
105
106 [[!img gpio_block.png]]