blob: b5f711d078ba3ce939b37b8b35089704c3038795 [file] [log] [blame]
manarabdelatya1553af2021-05-07 19:47:19 +02001.. raw:: html
2
3 <!---
4 # SPDX-FileCopyrightText: 2020 Efabless Corporation
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # SPDX-License-Identifier: Apache-2.0
19 -->
20
21Caravel Analog User Project
22===========================
23
24|License| |User CI| |Caravan Build|
25
manarabdelatydd3d8112021-05-08 18:32:32 +020026Table of contents
27=================
28
29- `Overview <#overview>`__
30- `Install Caravel <#install-caravel>`__
31- `Caravel Integration <#caravel-integration>`__
Manara1195922021-05-08 18:38:16 +020032
33 - `User Project: Power on Reset <#user-project-power-on-reset>`_
manarabdelatydd3d8112021-05-08 18:32:32 +020034 - `Verilog Integration <#verilog-integration>`__
Manara1195922021-05-08 18:38:16 +020035
manarabdelatydd3d8112021-05-08 18:32:32 +020036- `Running Full Chip Simulation <#running-full-chip-simulation>`__
Manar13f142e2021-05-08 18:43:17 +020037- `Analog Design Flow <#analog-design-flow>`__
manarabdelatydd3d8112021-05-08 18:32:32 +020038- `Other Miscellaneous Targets <#other-miscellaneous-targets>`_
39- `Checklist for Open-MPW
40 Submission <#checklist-for-open-mpw-submission>`__
41
42Overview
43========
44
45This repo contains a sample user project that utilizes the caravan chip (analog version of `caravel <https://github.com/efabless/caravel.git>`__) user space. The user project is a simple power-on-reset that showcases how to make use of caravan's user space utilities like IO pads, logic analyzer probes, and wishbone port. The repo also demonstrates the recommended structure for the open-mpw **analog** projects.
46
47Install Caravel
48===============
49
50To setup caravel, run the following:
51
52.. code:: bash
53
54 # By default, CARAVEL_ROOT is set to $(pwd)/caravel
55 # If you want to install caravel at a different location, run "export CARAVEL_ROOT=<caravel-path>"
56 # Disable submodule installation if needed by, run "export SUBMODULE=0"
57
58 git clone https://github.com/efabless/caravel_user_project_analog.git
59 cd caravel_user_project_analog
60 make install
61
62To update the installed caravel to the latest, run:
63
64.. code:: bash
65
66 make update_caravel
67
68To remove caravel, run
69
70.. code:: bash
71
72 make uninstall
73
74By default
75`caravel-lite <https://github.com/efabless/caravel-lite.git>`__ is
76installed. To install the full version of caravel, run this prior to
77calling make install.
78
79.. code:: bash
80
81 export CARAVEL_LITE=0
82
Manara1195922021-05-08 18:38:16 +020083Caravel Integration
84=====================
manarabdelatydd3d8112021-05-08 18:32:32 +020085
86
87User Project: Power on Reset
88----------------------------
89
Tim Edwardsc68f39e2021-05-08 13:47:45 -040090This is an example user analog project which breaks out the power-on-reset
91circuit used by the management SoC for power-up behavior so that the circuit
92input and output can be independently controlled and measured.
93
94The power-on-reset circuit itself is a simple, non-temperature-compensated
95analog delay calibrated to 15ms under nominal conditions, with a Schmitt
96trigger inverter to provide hysteresis around the trigger point to provide
97a clean output reset signal.
98
99The circuit provides a single high-voltage (3.3V domain) sense-inverted reset
100signal "porb_h" and complementary low-voltage (1.8V domain) reset signals
101"por_l" and "porb_l".
102
103The only input to the circuit is the 3.3V domain power supply itself.
104
manarabdelatydd3d8112021-05-08 18:32:32 +0200105
106Verilog Integration
107-------------------
108
109You need to create a wrapper around your macro that adheres to the
110template at
111`user\_analog_project\_wrapper <https://github.com/efabless/caravel/blob/master/verilog/rtl/__user_analog_project_wrapper.v>`__.
112The wrapper top module must be named ``user_analog_project_wrapper`` and must
113have the same input and output ports as the analog wrapper template. The wrapper gives access to the
114user space utilities provided by caravel like IO ports, logic analyzer
115probes, and wishbone bus connection to the management SoC.
116
Tim Edwardsc68f39e2021-05-08 13:47:45 -0400117The verilog modules instantiated in the wrapper module should represent
118the analog project; they need not be more than empty blocks, but it is
119encouraged to write a simple behavioral description of the analog circuit
120in standard verilog, using real-valued wires when necessary. This allows
121the whole system to be run in a verilog testbench and verify the connectivity
122to the padframe and management SoC, even if the testbench C code does nothing
123more than set the mode of each GPIO pin. The example top-level verilog code
124emulates the behavior of the power-on-reset delay after applying a valid
125power supply to the circuit.
126
manarabdelatydd3d8112021-05-08 18:32:32 +0200127
128Building the PDK
129================
130
131You have two options for building the pdk:
132
133- Build the pdk natively.
134
135Make sure you have `Magic VLSI Layout Tool <http://opencircuitdesign.com/magic/index.html>`__ `version 8.3.160 <https://github.com/RTimothyEdwards/magic/tree/8.3.160>`__ installed on your machine before building the pdk.
136
137.. code:: bash
138
139 # set PDK_ROOT to the path you wish to use for the pdk
140 export PDK_ROOT=<pdk-installation-path>
141
142 # you can optionally specify skywater-pdk and open-pdks commit used
143 # by setting and exporting SKYWATER_COMMIT and OPEN_PDKS_COMMIT
144 # if you do not set them, they default to the last verfied commits tested for this project
145
146 make pdk
147
148- Build the pdk using openlane's docker image which has magic installed.
149
150.. code:: bash
151
152 # set PDK_ROOT to the path you wish to use for the pdk
153 export PDK_ROOT=<pdk-installation-path>
154
155 # you can optionally specify skywater-pdk and open-pdks commit used
156 # by setting and exporting SKYWATER_COMMIT and OPEN_PDKS_COMMIT
157 # if you do not set them, they default to the last verfied commits tested for this project
158
159 make pdk-nonnative
160
161Running Full Chip Simulation
162============================
163
164First, you will need to install the simulation environment, by
165
166.. code:: bash
167
168 make simenv
169
170This will pull a docker image with the needed tools installed.
171
Manar520ff4a2021-05-08 18:39:47 +0200172To install the simulation environment locally, refer to `README <https://github.com/efabless/caravel_user_project_analog/blob/main/verilog/dv/README.md>`__
manarabdelatydd3d8112021-05-08 18:32:32 +0200173
174Then, run the RTL and GL simulation by
175
176.. code:: bash
177
178 export PDK_ROOT=<pdk-installation-path>
179 export CARAVEL_ROOT=$(pwd)/caravel
180 # specify simulation mode: RTL/GL
181 export SIM=RTL
182 # Run the mprj_por testbench, make verify-mprj_por
183 make verify-<testbench-name>
184
185The verilog test-benches are under this directory
186`verilog/dv <https://github.com/efabless/caravel_user_project_analog/tree/main/verilog/dv>`__.
187
Manar13f142e2021-05-08 18:43:17 +0200188
189Analog Design Flow
190===================
191
Tim Edwardsc68f39e2021-05-08 13:47:45 -0400192The example project uses a very simple analog design flow with schematics
193made with xschem, simulation done using ngspice, layout done with magic,
194and LVS verification done with netgen. Sources for the power-on-reset
195circuit are in the "xschem/" directory, which also includes a schematic
196representing the wrapper with all of its ports, for use in a testbench
197circuit. There are several testbenches in the example, starting from
198tests of the component devices to a full test of the completed project
199inside the wrapper.
200
201There is no automation in this project; the schematic and layout were
202done by hand, including both the power-on-reset block and the power and
203signal routing to the pins on the wrapper.
204
205The power-on-reset circuit itself is simple and is not compensated for
206temperature or voltage variation. When the power supply reaches a
207sufficient level, the voltage divider sets the gate voltage on an nFET
208device to draw a current of nominally 240nA. The testbench
209"threshold_test_tb.spice" does a DC sweep to find the gate voltage that
210produces this value. Next, a cascaded current mirror divides down the
211current by a factor of (roughly) 400. The testbench current_test.spice
212checks the current division value. Finally, the output ~600pA from the
213end of the current mirror is accumulated on a capacitor until the value
214trips the input of the 3.3V Schmitt trigger buffer from the
215sky130_fd_sd_hvl library. The capacitor is sized to peg the nominal
216time to trigger at 15ms. The schematic "example_por_tb.sch" sets up
217the testbench for this timing test.
218
219The output of the Schmitt trigger buffer becomes the high-voltage
220output, and is input to a standard buffer and inverter used as
221level shifters from the 3.3V domain to the 1.8V domain, producing
222complementary low-voltage outputs.
223
224The user project is formed from two power-on-reset circuits, one of
225which is connected to the user area VDDA1 power supply, and the other
226of which is connected to one of the analog I/O pads, used as a power
227supply input and connected to its voltage ESD clamp circuit. The
2283.3V domain outputs are connected directly to GPIO pads through the
229ESD (150 ohm series) connection. The 1.8V domain outputs are connected
230to GPIO pads through the usual I/O connections, with the corresponding
231user output enable (sense inverted) held low to keep the output always
232active.
233
234The C code testbench is in "verilog/dv/mprj_por/mprj_por.c" and only
235sets the GPIO pins used to the correct state (user output function).
236The POR circuit outputs are monitored by the testbench verilog file
237"mprj_por_tb.v" which will fail if the connections are wrong or if
238the behavioral POR verilog does not work as intended.
239
240Note that to properly test this circuit, the GPIO pins have to be
241configured for output to be seen and measured, implying that the
242management SoC power supply must be stable and the C program running
243off of the SPI flash before the user area power supplies are raised.
Manar13f142e2021-05-08 18:43:17 +0200244
Manar03aa1fa2021-09-21 01:41:29 +0200245**NOTE**
246
247 When running spice extraction on the user_analog_project_wrapper layout, it is recommended to use `ext2spice short resistor`.
248 This is to preserve all the different port names in the extracted netlist. In case you have two ports that are electrically shorted
249 in the layout, the `short resistor` option will tell magic not to merge the two shorted ports instead it adds zero-ohm ideal resistors
250 between the net names so that they can be kept as separate nets.
251
Manar13f142e2021-05-08 18:43:17 +0200252
manarabdelatydd3d8112021-05-08 18:32:32 +0200253Running Open-MPW Precheck Locally
254=================================
255
256You can install the precheck by running
257
258.. code:: bash
259
260 # By default, this install the precheck in your home directory
261 # To change the installtion path, run "export PRECHECK_ROOT=<precheck installation path>"
262 make precheck
263
264This will clone the precheck repo and pull the latest precheck docker image.
265
266
267Then, you can run the precheck by running
268Specify CARAVEL_ROOT before running any of the following,
269
270.. code:: bash
271
272 # export CARAVEL_ROOT=$(pwd)/caravel
273 export CARAVEL_ROOT=<path-to-caravel>
274 make run-precheck
275
276This will run all the precheck checks on your project and will retain the logs under the ``checks`` directory.
277
278Other Miscellaneous Targets
279============================
280
281The makefile provides a number of useful that targets that can run compress, uncompress, and run XOR checks on your design.
282
283Compress gds files and any file larger than 100MB (GH file size limit),
284
285.. code:: bash
286
287 make compress
288
289Uncompress files,
290
291.. code:: bash
292
293 make uncompress
294
295
296Specify ``CARAVEL_ROOT`` before running any of the following,
297
298.. code:: bash
299
300 # export CARAVEL_ROOT=$(pwd)/caravel
301 export CARAVEL_ROOT=<path-to-caravel>
302
303Run XOR check,
304
305.. code:: bash
306
307 make xor-analog-wrapper
308
309Checklist for Open-MPW Submission
310=================================
311
312
313|:heavy_check_mark:| The project repo adheres to the same directory structure in this repo.
314
315|:heavy_check_mark:| The project repo contain info.yaml at the project root.
316
317|:heavy_check_mark:| Top level macro is named ``user_analog_project_wrapper``.
318
319|:heavy_check_mark:| Full Chip Simulation passes for RTL and GL (gate-level)
320
Jeff DiCorpo19a3e1f2021-10-24 10:08:46 -0700321|:heavy_check_mark:| The project contains a spice netlist for the ``user_analog_project_wrapper`` at netgen/user_analog_project_wrapper.spice
322
manarabdelatydd3d8112021-05-08 18:32:32 +0200323|:heavy_check_mark:| The hardened Macros are LVS and DRC clean
324
325|:heavy_check_mark:| The ``user_analog_project_wrapper`` adheres to empty wrapper template order specified at `user_analog_project_wrapper_empty <https://github.com/efabless/caravel/blob/master/mag/user_analog_project_wrapper_empty.mag>`__
326
327|:heavy_check_mark:| XOR check passes with zero total difference.
328
329|:heavy_check_mark:| Open-MPW-Precheck tool runs successfully.
330
331
manarabdelatya1553af2021-05-07 19:47:19 +0200332.. |License| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
333 :target: https://opensource.org/licenses/Apache-2.0
Manar7b7b2f62021-05-07 19:52:47 +0200334.. |User CI| image:: https://github.com/efabless/caravel_user_project_analog/actions/workflows/user_project_ci.yml/badge.svg
335 :target: https://github.com/efabless/caravel_user_project_analog/actions/workflows/user_project_ci.yml
336.. |Caravan Build| image:: https://github.com/efabless/caravel_user_project_analog/actions/workflows/caravan_build.yml/badge.svg
337 :target: https://github.com/efabless/caravel_user_project_analog/actions/workflows/caravan_build.yml