|
| 1 | +# Building OpenROAD with ORFS |
| 2 | + |
| 3 | +You can build OpenROAD from source either in a Docker image or locally if you have a supported machine. |
| 4 | +The full instructions are at ORFS, but this is a document of what has worked for us. |
| 5 | + |
| 6 | +Most people will not need to build OpenROAD from source. I encourage you to use |
| 7 | +the [ORFS Installation](/orfs-installation.md) to avoid this unless you need to |
| 8 | +modify the source code. |
| 9 | + |
| 10 | +*BEWARE*, if you have local versions of tools installed, they will get priority |
| 11 | +over the compiled versions in the Docker image. This includes Yosys, OpenSTA, |
| 12 | +and OpenROAD. If you took CSE 125/225, you may have Yosys installed locally! |
| 13 | + |
| 14 | +# Clone the repository |
| 15 | + |
| 16 | +All step need to do this: |
| 17 | + |
| 18 | +```bash |
| 19 | +git clone https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts.git |
| 20 | +cd OpepNROAD-flow-scripts |
| 21 | +``` |
| 22 | + |
| 23 | +# Docker |
| 24 | + |
| 25 | +## Dependencies |
| 26 | + |
| 27 | +The dependencies are installed inside the Docker image, so you do not need to install them. |
| 28 | +You do nee to [install docker](docker.md), though. |
| 29 | + |
| 30 | +## Building the Docker image |
| 31 | + |
| 32 | +You only need to run the build command: |
| 33 | + |
| 34 | +```bash |
| 35 | +./build_openroad.sh |
| 36 | +``` |
| 37 | + |
| 38 | +as Docker is the default build method. |
| 39 | + |
| 40 | +### Debug symbols |
| 41 | + |
| 42 | +*I don't use this flow, so if you have a suggestion, please let me know!* |
| 43 | + |
| 44 | +*NOTE* the --openroad-args are not passed to the Docker build scripts, so you cannot enable debug like the |
| 45 | +Local build method. |
| 46 | + |
| 47 | +It does look like the docker build flow doesn't use the CMAKE parameters passed to the script: |
| 48 | + |
| 49 | +``` |
| 50 | +# 22 175.4 [INFO] ./tools/OpenROAD/etc/Build.sh -dir=/OpenROAD-flow-scripts/tools/OpenROAD/build -threads=128 -cmake= -D CMAKE_INSTALL_PREFIX=/OpenROAD-flow-scripts/tools/install/OpenROAD -D CMAKE_INSTALL_RPATH=/OpenROAD-flow-scripts/dependencies/lib:/OpenROAD-flow-scripts/dependencies/lib64 -D CMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE |
| 51 | +``` |
| 52 | + |
| 53 | +This is where it is called for local: |
| 54 | + |
| 55 | +``` |
| 56 | +build_openroad.sh |
| 57 | +``` |
| 58 | + |
| 59 | +``` |
| 60 | +254: eval ${NICE} ./tools/OpenROAD/etc/Build.sh -dir="$DIR/tools/OpenROAD/build" -threads=${PROC} -cmake=\'${OPENROAD_APP_ARGS}\' |
| 61 | +``` |
| 62 | + |
| 63 | +This is where it is called for docker: |
| 64 | + |
| 65 | +``` |
| 66 | +tools/OpenROAD/docker/Dockerfile.builder |
| 67 | +``` |
| 68 | + |
| 69 | +``` |
| 70 | +21:RUN ./etc/Build.sh -compiler=${compiler} -threads=${numThreads} -deps-prefixes-file=${depsPrefixFile} |
| 71 | +``` |
| 72 | + |
| 73 | +Docker.builder docker image gets built from DockerHelper.sh, but that doesn't take any of the args in build_openroad.sh: |
| 74 | + |
| 75 | +``` |
| 76 | + ./etc/DockerHelper.sh create -target=builder -os="${DOCKER_OS_NAME}" -threads="${PROC}" |
| 77 | +``` |
| 78 | + |
| 79 | +## Using OpenROAD in Docker |
| 80 | + |
| 81 | +This is very similar to the ORFS docker image that you used in the [walkthrough](/orfs-walkthrough.md) |
| 82 | +except that you need to specify a local docker image and tag: |
| 83 | + |
| 84 | +```bash |
| 85 | +``` |
| 86 | + |
| 87 | +# Local |
| 88 | + |
| 89 | +## Dependencies |
| 90 | + |
| 91 | +You need to run the commands in ```setup.sh``` to install dependencies. This does three things. |
| 92 | +You can run this script if you are root access, but I break down each step since some do not |
| 93 | +require root access. |
| 94 | + |
| 95 | +1. (NO ROOT) It recursively clones the repsositories needed to build OpenROAD: |
| 96 | + |
| 97 | +```bash |
| 98 | +git submodule update --init --recursive |
| 99 | +``` |
| 100 | + |
| 101 | +(Note, you could have run --recursive when you clone the repository as well, |
| 102 | +but this is a good way to ensure you have the latest submodules.) |
| 103 | + |
| 104 | +2. (NEEDS ROOT) Install system dependencies: |
| 105 | + |
| 106 | +```bash |
| 107 | +sudo ./etc/DependencyInstaller.sh -base |
| 108 | +``` |
| 109 | + |
| 110 | +This is a script that comes with ORFS. It will install the dependencies |
| 111 | +assuming that you have a supported OS. |
| 112 | + |
| 113 | +3. (NO ROOT) Install the other common depdencies: |
| 114 | + |
| 115 | +```bash |
| 116 | +./etc/DependencyInstaller.sh -common -prefix="./dependencies" |
| 117 | +``` |
| 118 | + |
| 119 | +This builds things such as specific versions of SWIG, cmake, etc. in the |
| 120 | +subdirectory "dependencies". |
| 121 | + |
| 122 | +## Building the code |
| 123 | + |
| 124 | +tl;dr My command line looks like this: |
| 125 | + |
| 126 | +```bash |
| 127 | +source dev_env.sh |
| 128 | +./build_openroad.sh --no_init --openroad-args "-DCMAKE_BUILD_TYPE=DEBUG" --local |
| 129 | +``` |
| 130 | + |
| 131 | +The dev environment ensures that you use the dependencies in "./dependencies". |
| 132 | +To compile the code locally (not in Docker), you specify ```--local```. |
| 133 | + |
| 134 | +To add debug symbols, you can specify the ```--openroad-args``` flag with and |
| 135 | +argument to cmake. |
| 136 | + |
| 137 | +The ```--no_init``` flag is used to not re-initialize the submodules. In |
| 138 | +addition to this, you can specify to use a particular repository and branch of |
| 139 | +code with: ```--or_repo <REPO> --or_branch <BRANCH>```. By default this is the |
| 140 | +ORFS repo and branch. I usually manually clone it and use the no init option. |
| 141 | + |
| 142 | +```bash |
| 143 | +./build_openroad.sh --local |
| 144 | +``` |
| 145 | + |
| 146 | +This will update submodules to the version needed by the current commit. |
| 147 | + |
| 148 | +# Using OpenROAD |
| 149 | + |
| 150 | +To set your path with the newly built openroad, you should source the environment script: |
| 151 | + |
| 152 | +```bash |
| 153 | +source env.sh |
| 154 | +``` |
| 155 | + |
| 156 | +You can then see that you are using the correct version of OpenROAD by running: |
| 157 | + |
| 158 | +```bash |
| 159 | +which openroad |
| 160 | +``` |
| 161 | + |
| 162 | +which should point to |
| 163 | + |
| 164 | +``` |
| 165 | +OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad |
| 166 | +``` |
| 167 | + |
| 168 | +## OpenROAD Regression Tests |
| 169 | + |
| 170 | +You can run regression tests for OpenROAD overall by doing: |
| 171 | + |
| 172 | +```bash |
| 173 | +cd tools/OpenROAD/tests |
| 174 | +# For a single test |
| 175 | +./regression gcd_nangate45 |
| 176 | +# For all the tests (very slow!) |
| 177 | +./regression.sh |
| 178 | +``` |
| 179 | + |
| 180 | +or just: |
| 181 | + |
| 182 | +```bash |
| 183 | +openroad gcd_nangate45.tcl |
| 184 | +``` |
| 185 | + |
| 186 | +## Module Regression Tests |
| 187 | + |
| 188 | +You can run regression tests for a specific submodule like this: |
| 189 | + |
| 190 | +```bash |
| 191 | +cd tools/OpenROAD/src/rsz/tests |
| 192 | +# Run all the tests, with 10 threads |
| 193 | +./regression -j 10 |
| 194 | +# Run the tests that match the regex |
| 195 | +./regression -R repair_setup |
| 196 | +# Run a regression test TCL directly |
| 197 | +openroad repair_setup1.tcl |
| 198 | +``` |
| 199 | + |
| 200 | +The correct log output of a regression test is saved with the extension ".ok" |
| 201 | +and the correct Verilog or DEF is saved with ".vok" and ".defok", respectively. |
| 202 | +To determine correctness, the final result is compared with these. A simple |
| 203 | +diff is usually used unless the test has equivalence checking enabled. |
| 204 | + |
| 205 | +The outputs of the regression test will be saved in the results subdirectory. |
| 206 | +The log is called ```<TEST>-tcl.log``` and the diff with the ".ok" log is in |
| 207 | +```<TEST>-tcl.diff```. If there is a Verilog or DEF output, it is saved with |
| 208 | +the extension ```<TEST>_out-tcl.v``` (or def). |
0 commit comments