├── .gitattributes ├── .gitignore ├── DEVELOPMENT.md ├── LICENSE ├── README.md ├── azure-pipelines.yml ├── build-data ├── darwin │ └── environment.yml ├── include │ ├── libftdi1 │ │ └── ftdi.h │ └── libusb-1.0 │ │ └── libusb.h ├── lib │ ├── linux_aarch64 │ │ ├── libftdi1.a │ │ └── libusb-1.0.a │ ├── linux_armv7l │ │ ├── libftdi1.a │ │ └── libusb-1.0.a │ ├── linux_i686 │ │ ├── libftdi1.a │ │ └── libusb-1.0.a │ ├── linux_x86_64 │ │ ├── libftdi1.a │ │ └── libusb-1.0.a │ ├── windows_amd64 │ │ ├── libftdi1.a │ │ └── libusb-1.0.a │ └── windows_x86 │ │ ├── libftdi1.a │ │ └── libusb-1.0.a ├── linux_x86_64 │ ├── libpython3.8-minimal_3.8.2-1ubuntu1.1_amd64.deb │ └── libpython3.8-stdlib_3.8.2-1ubuntu1.1_amd64.deb ├── test │ ├── top.json │ ├── top.pcf │ └── top_pre_pack.py └── yosys-config ├── build.sh ├── build_bba.sh ├── clean.sh ├── patches ├── ghdl │ ├── ghdl_largs.patch │ ├── ghdl_version.patch │ └── libghdl_static.patch └── yosys │ └── yosys_ghdl.patch └── scripts ├── _common.sh ├── build_setup.sh ├── bundle_make.sh ├── bundle_python.sh ├── compile_avy.sh ├── compile_boolector.sh ├── compile_dfu_util.sh ├── compile_ecpprog.sh ├── compile_ghdl.sh ├── compile_icestorm.sh ├── compile_iverilog.sh ├── compile_nextpnr_ecp5.sh ├── compile_nextpnr_ecp5_bba.sh ├── compile_nextpnr_ice40.sh ├── compile_openfpgaloader.sh ├── compile_sby.sh ├── compile_yices2.sh ├── compile_yosys.sh ├── compile_z3.sh ├── darwin_patch.sh ├── install_dependencies.sh ├── test ├── install_toolchain.sh ├── run_tests.sh ├── test_binaries_execute.sh ├── test_ecp5_blinky.sh ├── test_ghdl_yosys.sh ├── test_ice40_blinky.sh ├── test_nextpnr_python.sh ├── test_nmigen.sh └── test_sby.sh ├── test_bin.sh └── travis_trigger.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # mark all files as not text to disable any EOL conversions 2 | * -text 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .sconsign.dblite 2 | *.out 3 | *.vcd 4 | *.tar.gz 5 | libftdi.a 6 | _builds/ 7 | _packages/ 8 | _upstream/ 9 | .env 10 | -------------------------------------------------------------------------------- /DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | # General Guidelines 2 | 3 | The goal of this project is to make it as easy as possible to get up and running with open source FPGA tools. A secondary goal is to provide the same set of tools and features on all platforms, wherever possible. 4 | 5 | To achieve these goals, some compromises have been made: 6 | * Static linking is used in almost all cases - removing dependencies on external shared libraries means this package should be all you need to run the tools. The major downside of this approach is that some tools are not designed to be built statically, which can make it harder or near-impossible to include them. 7 | * The goal is not to rely on any absolute install prefixes - tools must be able to find any files they need at runtime by using relative paths wherever possible. This also enables multiple versions of the tools to be installed without conflicting. 8 | * The package is provided as a simple compressed archive - no package managers are used. This makes installation simple, but the downside is that **before accepting a contribution adding a new tool, we need to consider how much larger it makes the overall package**. 9 | 10 | # Development 11 | 12 | ## Build Prerequisites 13 | At present, all of the builds are run on their native platform (no cross-compiling). 14 | 15 | **Windows** 16 | 17 | 1. Install MSYS2 - install options: 18 | * Use [chocolately](https://chocolatey.org/) and run `choco install msys2` 19 | * Install using instructions on [the MSYS2 website](https://www.msys2.org/) 20 | 2. Run the MinGW64 bash environment `mingw64.exe` (not the MSYS2 or MinGW32 environments). 21 | 22 | **macOS** 23 | 24 | 1. Install [Xcode 11.4.1](https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_11.4.1/Xcode_11.4.1.xip) to `/Applications/Xcode_11.4.1.app` (other versions might work but this is untested and unsupported) 25 | 26 | *Note that this requires macOS 10.15.2+ as a build-time dependency. The resulting builds should work on versions as old as macOS 10.10* 27 | 28 | 2. Install [Homebrew](https://brew.sh/) 29 | 30 | **Linux** 31 | 1. Create an Ubuntu 20.04 environment: 32 | * The `ubuntu:20.04` docker container is a good option and this is the approach the CI build uses 33 | * A virtual machine or even WSL on Windows will work too 34 | * Running on bare metal is of course fine too, but other versions of Ubuntu are untested and unsupported. 35 | 36 | *Note that Ubuntu 20.04 is only a build-time dependency. The resulting builds are intended to run on any Linux distro* 37 | 38 | 2. Make sure the `sudo` package is installed (it is not installed by default in the docker image) 39 | 40 | ## Running a Build 41 | 42 | **WARNING**: The scripts will attempt to automatically install build dependencies by default! If you don't want this you can disable it first with `export INSTALL_DEPS=0`. 43 | 44 | The details of the required dependencies will not be documented here, so it is recommended to just let the scripts handle it - you can see what will be installed in `scripts/install_dependencies.sh` 45 | 46 | Build: 47 | 48 | ``` 49 | bash build.sh 50 | ``` 51 | *Note: the build will automatically check the number of cores on your system and run parallel jobs.* 52 | 53 | Clean: 54 | 55 | ``` 56 | bash clean.sh 57 | ``` 58 | 59 | *Note: various parts of the scripts currently assume a clean working directory so it is best to run a clean before starting a new build.* 60 | 61 | Current architectures: 62 | * linux_x86_64 63 | * windows_amd64 64 | * darwin 65 | 66 | Final packages will be deployed in the `./_packages/build_/` directory. 67 | 68 | By default the scripts will not build nextpnr-ecp5. See [this section](#building-nextpnr-ecp5) for details on how to build this too. 69 | 70 | ## Disabling parts of the build 71 | 72 | The build scripts define many variables that may be used to disable parts of the build during development - see `build.sh` for details. 73 | 74 | If you place a `.env` file in the root of the repo then the bash scripts will source it. You can use this as a convenient way to locally override these variables without accidentally committing changes (the file is already in `.gitignore`). 75 | 76 | ## Building nextpnr-ecp5 77 | 78 | These scripts currently require an Ubuntu 20.04 environment ([as specified here](#prerequisites)) to generate the ECP5 device databases. The device databases are represented as a text-based set of instructions for the nextpnr Binary Blob Assembler (a "BBA file"). It is important that the same nextpnr and libtrellis git commits are used for the whole build to avoid the BBA files getting out of sync with the compiled code. 79 | 80 | In the Ubuntu 20.04 environment, run: 81 | 82 | `./build_bba.sh` 83 | 84 | This will result in a package generated at: 85 | 86 | `./_packages/build_linux_x86_64/ecp5-bba-noarch-nightly.tar.gz` 87 | 88 | If you are building in the same working folder, you can then simply run: 89 | 90 | `COMPILE_NEXTPNR_ECP5=1 ./build.sh ` 91 | 92 | If you are building the bba files in a separate working folder, you will need to `mkdir -p ./_packages/build_linux_x86_64/` and then copy the bba package into `./_packages/build_linux_x86_64/ecp5-bba-noarch-nightly.tar.gz` before running `build.sh` (this is how the CI build works) 93 | 94 | Some other info that may be useful if trying to build nextpnr on a new platform: 95 | 96 | * The text BBA files are architecture independent. 97 | * The binary output from bbasm works for any architecture provided that the correct endianness was set. This is worth paying attention to if e.g. cross-building for a big-endian platform on an x86 host 98 | * The BBA files cannot be generated without a version of libtrellis built with python bindings enabled (they are used by a python script). 99 | * Nextpnr-ecp5 links against libtrellis but does not need the python bindings. 100 | * Nextpnr is linked against a static libpython.a to enable an embedded python interpreter that may be used to set up clock constraints, manually place elements, etc. This embedded interpreter needs the modules in `lib/python3.` to function. It is far from perfect - many modules that have been copied over are likely to fail to load since they have dependencies on shared libraries from the build host that we have not bundled. 101 | * Normally nextpnr's CMakeLists.txt will handle the bba generation transparently during the build. The reason for pre-generating BBA files on a linux host was historically because the Windows builds were built with MSVC. Using MSVC enabled linking the official Windows CPython builds as the embedded python interpreter, but building libtrellis with python bindings enabled was difficult under MSVC. Since then, the embedded python interpreter has been changed to a MinGW built version of python. The BBA generation has remained the same because: 102 | 103 | 1. It was easier not to change things. Getting libtrellis to build with python bindings on all platforms should be possible in theory but might require a little more work. 104 | 2. This foundation should hopefully make it slightly easier to set up a cross-compile for other platforms (e.g. ARM) 105 | 3. We can slightly reduce the size of the resulting executable by disabling the python bindings in libtrellis. 106 | 4. The BBA files take a while to generate and it seems silly to generate the same thing multiple times. 107 | 108 | ## Misc Information: 109 | 110 | *libftdi1.a* and *libusb-1.0.a* files have been generated for Linux using the [Tools-system scripts](https://github.com/FPGAwars/tools-system) to allow static linking without a dependency on libudev (which is part of systemd and doesn't make for very portable binaries). -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FPGA-Toolchain 2 | [![Build Status](https://dev.azure.com/open-tool-forge/fpga-toolchain/_apis/build/status/YosysHQ.fpga-toolchain?branchName=main)](https://dev.azure.com/open-tool-forge/fpga-toolchain/_build/latest?definitionId=4&branchName=main) 3 | [![Discord](https://img.shields.io/discord/613131135903596547?logo=discord)](https://discord.gg/s9sMfyx) 4 | 5 | ## !!This Project is No Longer Maintained!! 6 | Builds have stopped running, past releases will remain archived here for anyone that was depending on them in their workflow. 7 | 8 | **I recommend taking a look at [oss-cad-suite-build](https://github.com/YosysHQ/oss-cad-suite-build) for a similar package which is actively maintained by YosysHQ**. 9 | 10 | A more detailed list of various alternative packagings of these tools with various advantages and disadvantages can be found [here](https://github.com/hdl/packages). 11 | 12 | ## Introduction 13 | Multi-platform nightly builds of open source FPGA tools. 14 | 15 | Currently included: 16 | 17 | * [Yosys](https://github.com/YosysHQ/yosys): RTL synthesis with extensive Verilog 2005 support 18 | * [GHDL Yosys Plugin](https://github.com/ghdl/ghdl-yosys-plugin): experimental VHDL synthesis, built in to Yosys for your convenience! 19 | * [GHDL](https://github.com/ghdl/ghdl): CLI tool supporting the Yosys plugin 20 | * [SymbiYosys](https://github.com/YosysHQ/SymbiYosys): Yosys-based formal hardware verification 21 | * [Boolector](http://fmv.jku.at/boolector/): Engine for SymbiYosys 22 | * [Yices2](http://yices.csl.sri.com/): Engine for SymbiYosys 23 | * [Z3](https://github.com/Z3Prover/z3/wiki): Engine for SymbiYosys 24 | * [Project Trellis](https://github.com/SymbiFlow/prjtrellis): Tools for working with Lattice ECP5 bitstreams 25 | * [Project IceStorm](https://github.com/cliffordwolf/icestorm): Tools for working with Lattice ICE40 bitstreams 26 | * [nextpnr](https://github.com/YosysHQ/nextpnr): Timing-driven place and route for both ICE40 and ECP5 architectures 27 | * [dfu-util](http://dfu-util.sourceforge.net/): Device Firmware Upgrade Utilities 28 | * [ecpprog](https://github.com/gregdavill/ecpprog): A basic driver for FTDI based JTAG probes, to program ECP5 FPGAs 29 | * [openFPGALoader](https://github.com/trabucayre/openFPGALoader): Universal utility for programming FPGA 30 | 31 | 32 | 33 | 34 | These tools are under active development (as are these build scripts), so 35 | please be prepared for things to break from time to time. In most cases you should be able 36 | to roll back to an older version while you wait for a fix. 37 | 38 | Builds run at 0400 UTC daily from the master branch of each project. 39 | 40 | ## Installation 41 | 42 | 1. Download an archive matching your OS from [the releases page](https://github.com/YosysHQ/fpga-toolchain/releases). 43 | 2. Extract the archive to a location of your choice 44 | 3. Add the `bin` folder to your `PATH`: 45 | 46 | ``` 47 | MacOS and Linux: export PATH="/fpga-toolchain/bin:$PATH" 48 | Windows Powershell: $ENV:PATH = "\fpga-toolchain\bin;" + $ENV:PATH 49 | Windows cmd.exe: PATH=\fpga-toolchain\bin;%PATH% 50 | ``` 51 | 52 | Windows users that prefer to use WSL can download `fpga-toolchain-linux*` to build under WSL and then use the native tools from `fpga-toolchain-progtools-windows*` to program their boards (since USB devices are not currently accessible in the WSL environment). 53 | 54 | These builds should work for macOS 10.10 or newer - please report a bug if you have issues! 55 | 56 | If you see errors about missing libraries (`.so`/`.dll`/`.dylib`) please report them in an issue here. 57 | 58 | ## Using GHDL 59 | 60 | If you would like to use the experimental GHDL Yosys plugin for VHDL on Linux or MacOS, you will 61 | need to set the `GHDL_PREFIX` environment variable. e.g. `export GHDL_PREFIX=/fpga-toolchain/lib/ghdl`. On Windows this is not necessary. 62 | 63 | If you are using an existing Makefile set up for ghdl-yosys-plugin and see `ERROR: This version of yosys is built without plugin support` you probably need to remove `-m ghdl` from your yosys parameters. This is because the plugin is typically loaded from a separate file but it is provided built into yosys in this package. 64 | 65 | ## Getting Help 66 | 67 | If you run into issues with these tools, please consider reporting an issue to the authors of the tools - we are just compiling them here! If you think your issue relates to *the way we have compiled them* then it is more appropriate to open a GitHub issue here. 68 | 69 | If you aren't sure where to report your issue or don't feel it fits on GitHub, you can also try sending a message in the `#yosyshq` channel on [1BitSquared's Discord server](https://discord.gg/s9sMfyx). 70 | 71 | ## Related Projects 72 | 73 | For portable WASM builds of these tools, check out [YoWASP](http://yowasp.org/). Also check out [nMigen](https://github.com/nmigen/nmigen) for a powerful python-based approach to hardware description. 74 | 75 | ## Credits 76 | 77 | This is built on the work done by [Sean Cross (xobs)](https://github.com/xobs) for [fomu-toolchain](https://github.com/im-tomu/fomu-toolchain), 78 | which was built on the original work by [FPGAWars](https://github.com/FPGAwars): 79 | 80 | * [Jesús Arroyo Torrens](https://github.com/Jesus89) 81 | * [Juan González (Obijuan)](https://github.com/Obijuan) 82 | * [Carlos Venegas](https://github.com/cavearr) 83 | * [Miodrag Milanovic](https://github.com/mmicko) 84 | 85 | ## Contributing 86 | 87 | Contributions are welcome, see [DEVELOPMENT.md](DEVELOPMENT.md) for guidelines and technical details. 88 | 89 | ## License 90 | 91 | Licensed under a GPL v3 and [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/). 92 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | branches: 3 | exclude: 4 | # main branch publishes releases - avoid merges triggering a new release 5 | - main 6 | 7 | schedules: 8 | - cron: "0 4 * * *" 9 | displayName: Nightly build at 0400 UTC 10 | branches: 11 | include: 12 | - main 13 | always: true 14 | 15 | variables: 16 | - name: INSTALL_DEPS 17 | value: "1" 18 | - name: CLEAN_AFTER_BUILD 19 | value: "1" 20 | - name: STRIP_SYMBOLS 21 | value: "1" 22 | - name: COMPILE_DFU_UTIL 23 | value: "1" 24 | - name: COMPILE_YOSYS 25 | value: "1" 26 | - name: COMPILE_SBY 27 | value: "1" 28 | - name: COMPILE_Z3 29 | value: "1" 30 | - name: COMPILE_BOOLECTOR 31 | value: "1" 32 | - name: COMPILE_AVY 33 | value: "0" # deliberately disabled 34 | - name: COMPILE_YICES2 35 | value: "1" 36 | - name: COMPILE_ICESTORM 37 | value: "1" 38 | - name: COMPILE_NEXTPNR_ICE40 39 | value: "1" 40 | - name: COMPILE_NEXTPNR_ECP5 41 | value: "1" 42 | - name: COMPILE_ECPPROG 43 | value: "1" 44 | - name: COMPILE_OPENFPGALOADER 45 | value: "1" 46 | - name: COMPILE_IVERILOG 47 | value: "0" # deliberately disabled 48 | - name: COMPILE_GHDL 49 | value: "1" 50 | - name: BUNDLE_PYTHON 51 | value: "1" 52 | - name: BUNDLE_MAKE 53 | value: "1" 54 | - name: CREATE_PACKAGE 55 | value: "1" 56 | - name: TEST_BINARIES_EXECUTE 57 | value: "1" 58 | - name: TEST_ICE40_BLINKY 59 | value: "1" 60 | - name: TEST_ECP5_BLINKY 61 | value: "1" 62 | - name: TEST_NMIGEN 63 | value: "1" 64 | - name: TEST_GHDL_YOSYS 65 | value: "1" 66 | - name: TEST_NEXTPNR_PYTHON 67 | value: "1" 68 | - name: TEST_SBY 69 | value: "1" 70 | 71 | stages: 72 | - stage: build_bba 73 | displayName: Build ECP5 chipdb (*.bba) 74 | condition: eq(variables['COMPILE_NEXTPNR_ECP5'], '1') 75 | jobs: 76 | - job: build_bba 77 | displayName: Build ECP5 chipdb (*.bba) 78 | pool: 79 | vmImage: 'ubuntu-18.04' 80 | steps: 81 | - bash: ./build_bba.sh 82 | displayName: Build ECP5 chipdb (*.bba) 83 | name: build_bba 84 | - publish: _packages/build_linux_x86_64/ecp5-bba-noarch-nightly.tar.gz 85 | artifact: ecp5-bba 86 | 87 | - stage: build_toolchain 88 | displayName: build toolchain 89 | condition: always() 90 | jobs: 91 | - job: build_toolchain 92 | displayName: Build toolchain 93 | timeoutInMinutes: 0 94 | strategy: 95 | matrix: 96 | linux_x86_64: 97 | ARCH: linux_x86_64 98 | vm_image: ubuntu-16.04 99 | container_image: ubuntu:20.04 100 | pool: 101 | vmImage: '$(vm_image)' 102 | 103 | container: 104 | image: $[ variables['container_image'] ] 105 | options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro" 106 | 107 | steps: 108 | - task: DownloadPipelineArtifact@2 109 | condition: eq(variables['COMPILE_NEXTPNR_ECP5'], '1') 110 | inputs: 111 | source: current 112 | artifact: ecp5-bba 113 | path: '$(Build.Repository.LocalPath)/_packages/build_linux_x86_64' 114 | - bash: | 115 | RELEASE_TAG=nightly-$(date +'%Y%m%d') 116 | # create pipeline variable 117 | echo "##vso[task.setvariable variable=RELEASE_TAG]$RELEASE_TAG" 118 | - script: | 119 | /tmp/docker exec -t -u 0 ci-container \ 120 | sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo" 121 | displayName: Set up sudo 122 | - bash: ./build.sh $(ARCH) 123 | displayName: Build toolchain 124 | name: build_toolchain 125 | - publish: _packages/build_$(ARCH)/publish 126 | artifact: fpga-toolchain-$(ARCH)-$(RELEASE_TAG) 127 | - publish: _packages/build_$(ARCH)/publish_symbols 128 | artifact: symbols_fpga-toolchain-$(ARCH)-$(RELEASE_TAG) 129 | 130 | - job: build_toolchain_osx 131 | displayName: Build toolchain OS X 132 | timeoutInMinutes: 0 133 | strategy: 134 | matrix: 135 | osx: 136 | ARCH: darwin 137 | vm_image: macOS-10.15 138 | pool: 139 | vmImage: '$(vm_image)' 140 | 141 | steps: 142 | - task: DownloadPipelineArtifact@2 143 | condition: eq(variables['COMPILE_NEXTPNR_ECP5'], '1') 144 | inputs: 145 | source: current 146 | artifact: ecp5-bba 147 | path: '$(Build.Repository.LocalPath)/_packages/build_linux_x86_64' 148 | - bash: | 149 | RELEASE_TAG=nightly-$(date +'%Y%m%d') 150 | # create pipeline variable 151 | echo "##vso[task.setvariable variable=RELEASE_TAG]$RELEASE_TAG" 152 | - bash: ./build.sh $(ARCH) 153 | displayName: Build toolchain 154 | name: build_toolchain 155 | - publish: _packages/build_$(ARCH)/publish 156 | artifact: fpga-toolchain-$(ARCH)-$(RELEASE_TAG) 157 | - publish: _packages/build_$(ARCH)/publish_symbols 158 | artifact: symbols_fpga-toolchain-$(ARCH)-$(RELEASE_TAG) 159 | 160 | - job: build_toolchain_windows_amd64 161 | displayName: Build toolchain windows_amd64 162 | timeoutInMinutes: 0 163 | pool: 164 | vmImage: vs2017-win2016 165 | variables: 166 | ARCH: windows_amd64 167 | MINGW_ARCH: x86_64 168 | steps: 169 | - powershell: | 170 | Set-MpPreference -DisableArchiveScanning $true 171 | Set-MpPreference -DisableRealtimeMonitoring $true 172 | Set-MpPreference -DisableBehaviorMonitoring $true 173 | - task: DownloadPipelineArtifact@2 174 | condition: eq(variables['COMPILE_NEXTPNR_ECP5'], '1') 175 | inputs: 176 | source: current 177 | artifact: ecp5-bba 178 | path: '$(Build.Repository.LocalPath)/_packages/build_linux_x86_64' 179 | - bash: | 180 | RELEASE_TAG=nightly-$(date +'%Y%m%d') 181 | # create pipeline variable 182 | echo "##vso[task.setvariable variable=RELEASE_TAG]$RELEASE_TAG" 183 | - script: | 184 | set MSYS_ROOT=%CD:~0,2%\msys64 185 | echo ##vso[task.setvariable variable=MSYS_ROOT]%MSYS_ROOT% 186 | choco install msys2 --params "/NoUpdate /InstallDir:%MSYS_ROOT%" 187 | displayName: Install MSYS2 188 | - script: | 189 | set PATH=%MSYS_ROOT%\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem 190 | %MSYS_ROOT%\usr\bin\pacman --noconfirm -Syyuu 191 | displayName: Update MSYS2 192 | - script: | 193 | set PATH=%MSYS_ROOT%\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem 194 | %MSYS_ROOT%\usr\bin\pacman --noconfirm --needed -S git base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake 195 | %MSYS_ROOT%\usr\bin\pacman --noconfirm -Scc 196 | displayName: Install Toolchain 197 | - script: | 198 | set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem 199 | %MSYS_ROOT%\usr\bin\sed -i "s|#CacheDir.*|CacheDir=/c/Users/%USERNAME%/AppData/Local/Temp|g" /etc/pacman.conf 200 | set MSYS=winsymlinks:nativestrict 201 | %MSYS_ROOT%\msys2_shell.cmd -defterm -no-start -mingw64 -full-path -here -c "./build.sh windows_amd64" 202 | displayName: CI-Build 203 | env: 204 | MSYSTEM: MINGW64 205 | CHERE_INVOKING: yes 206 | MINGW_INSTALLS: mingw64 207 | - publish: _packages/build_$(ARCH)/publish 208 | artifact: fpga-toolchain-$(ARCH)-$(RELEASE_TAG) 209 | - publish: _packages/build_$(ARCH)/publish_symbols 210 | artifact: symbols_fpga-toolchain-$(ARCH)-$(RELEASE_TAG) 211 | 212 | - stage: run_tests 213 | displayName: run tests 214 | condition: always() 215 | jobs: 216 | - job: run_tests 217 | displayName: run tests 218 | timeoutInMinutes: 0 219 | strategy: 220 | matrix: 221 | linux_x86_64: 222 | ARCH: linux_x86_64 223 | vm_image: ubuntu-16.04 224 | windows_amd64: 225 | ARCH: windows_amd64 226 | vm_image: vs2017-win2016 227 | darwin: 228 | ARCH: darwin 229 | vm_image: macOS-10.14 230 | pool: 231 | vmImage: '$(vm_image)' 232 | steps: 233 | - bash: | 234 | RELEASE_TAG=nightly-$(date +'%Y%m%d') 235 | # create pipeline variable 236 | echo "##vso[task.setvariable variable=RELEASE_TAG]$RELEASE_TAG" 237 | - task: DownloadPipelineArtifact@2 238 | inputs: 239 | source: current 240 | artifact: fpga-toolchain-$(ARCH)-$(RELEASE_TAG) 241 | path: '$(Build.Repository.LocalPath)' 242 | # source: 'specific' 243 | # project: '4615f283-ee51-4dbc-992b-cdd560f6506b' 244 | # pipeline: '1' 245 | # runVersion: 'specific' 246 | # runId: '349' # this is buildId in the URL 247 | - bash: export VERSION=$(RELEASE_TAG) && ./scripts/test/run_tests.sh $(ARCH) 248 | displayName: Run tests 249 | name: run_tests 250 | 251 | - stage: publish_release 252 | displayName: publish release 253 | # only generate a github release on main (dev branches still have artifacts that can be downloaded) 254 | condition: eq(variables['Build.SourceBranch'], 'refs/heads/main') 255 | jobs: 256 | - job: publish_release 257 | displayName: publish_release 258 | timeoutInMinutes: 0 259 | pool: 260 | vmImage: ubuntu-18.04 261 | variables: 262 | "System.Debug": true 263 | steps: 264 | - bash: | 265 | RELEASE_TAG=nightly-$(date +'%Y%m%d') 266 | # create pipeline variable 267 | echo "##vso[task.setvariable variable=RELEASE_TAG]$RELEASE_TAG" 268 | - download: current 269 | patterns: '**/fpga-toolchain*.*' 270 | - task: GitHubRelease@0 271 | inputs: 272 | gitHubConnection: yosyshq-release 273 | repositoryName: '$(Build.Repository.Name)' 274 | action: 'create' 275 | target: '$(Build.SourceVersion)' 276 | tagSource: 'manual' 277 | tag: '$(RELEASE_TAG)' 278 | addChangeLog: false 279 | releaseNotesSource: 'input' 280 | releaseNotes: '$(RELEASE_TAG)' 281 | assets: | 282 | $(Pipeline.Workspace)/**/fpga-toolchain*.tar.* 283 | $(Pipeline.Workspace)/**/fpga-toolchain*.zip 284 | $(Pipeline.Workspace)/**/fpga-toolchain*.7z 285 | -------------------------------------------------------------------------------- /build-data/darwin/environment.yml: -------------------------------------------------------------------------------- 1 | name: base 2 | channels: 3 | - defaults 4 | dependencies: 5 | - python=3.8.2 6 | -------------------------------------------------------------------------------- /build-data/include/libftdi1/ftdi.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | ftdi.h - description 3 | ------------------- 4 | begin : Fri Apr 4 2003 5 | copyright : (C) 2003-2017 by Intra2net AG and the libftdi developers 6 | email : opensource@intra2net.com 7 | ***************************************************************************/ 8 | 9 | /*************************************************************************** 10 | * * 11 | * This program is free software; you can redistribute it and/or modify * 12 | * it under the terms of the GNU Lesser General Public License * 13 | * version 2.1 as published by the Free Software Foundation; * 14 | * * 15 | ***************************************************************************/ 16 | 17 | #ifndef __libftdi_h__ 18 | #define __libftdi_h__ 19 | 20 | #include 21 | #ifndef _WIN32 22 | #include 23 | #endif 24 | 25 | /* 'interface' might be defined as a macro on Windows, so we need to 26 | * undefine it so as not to break the current libftdi API, because 27 | * struct ftdi_context has an 'interface' member 28 | * As this can be problematic if you include windows.h after ftdi.h 29 | * in your sources, we force windows.h to be included first. */ 30 | #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 31 | #include 32 | #if defined(interface) 33 | #undef interface 34 | #endif 35 | #endif 36 | 37 | /** FTDI chip type */ 38 | enum ftdi_chip_type 39 | { 40 | TYPE_AM=0, 41 | TYPE_BM=1, 42 | TYPE_2232C=2, 43 | TYPE_R=3, 44 | TYPE_2232H=4, 45 | TYPE_4232H=5, 46 | TYPE_232H=6, 47 | TYPE_230X=7, 48 | }; 49 | /** Parity mode for ftdi_set_line_property() */ 50 | enum ftdi_parity_type { NONE=0, ODD=1, EVEN=2, MARK=3, SPACE=4 }; 51 | /** Number of stop bits for ftdi_set_line_property() */ 52 | enum ftdi_stopbits_type { STOP_BIT_1=0, STOP_BIT_15=1, STOP_BIT_2=2 }; 53 | /** Number of bits for ftdi_set_line_property() */ 54 | enum ftdi_bits_type { BITS_7=7, BITS_8=8 }; 55 | /** Break type for ftdi_set_line_property2() */ 56 | enum ftdi_break_type { BREAK_OFF=0, BREAK_ON=1 }; 57 | 58 | /** MPSSE bitbang modes */ 59 | enum ftdi_mpsse_mode 60 | { 61 | BITMODE_RESET = 0x00, /**< switch off bitbang mode, back to regular serial/FIFO */ 62 | BITMODE_BITBANG= 0x01, /**< classical asynchronous bitbang mode, introduced with B-type chips */ 63 | BITMODE_MPSSE = 0x02, /**< MPSSE mode, available on 2232x chips */ 64 | BITMODE_SYNCBB = 0x04, /**< synchronous bitbang mode, available on 2232x and R-type chips */ 65 | BITMODE_MCU = 0x08, /**< MCU Host Bus Emulation mode, available on 2232x chips */ 66 | /* CPU-style fifo mode gets set via EEPROM */ 67 | BITMODE_OPTO = 0x10, /**< Fast Opto-Isolated Serial Interface Mode, available on 2232x chips */ 68 | BITMODE_CBUS = 0x20, /**< Bitbang on CBUS pins of R-type chips, configure in EEPROM before */ 69 | BITMODE_SYNCFF = 0x40, /**< Single Channel Synchronous FIFO mode, available on 2232H chips */ 70 | BITMODE_FT1284 = 0x80, /**< FT1284 mode, available on 232H chips */ 71 | }; 72 | 73 | /** Port interface for chips with multiple interfaces */ 74 | enum ftdi_interface 75 | { 76 | INTERFACE_ANY = 0, 77 | INTERFACE_A = 1, 78 | INTERFACE_B = 2, 79 | INTERFACE_C = 3, 80 | INTERFACE_D = 4 81 | }; 82 | 83 | /** Automatic loading / unloading of kernel modules */ 84 | enum ftdi_module_detach_mode 85 | { 86 | AUTO_DETACH_SIO_MODULE = 0, 87 | DONT_DETACH_SIO_MODULE = 1 88 | }; 89 | 90 | /* Shifting commands IN MPSSE Mode*/ 91 | #define MPSSE_WRITE_NEG 0x01 /* Write TDI/DO on negative TCK/SK edge*/ 92 | #define MPSSE_BITMODE 0x02 /* Write bits, not bytes */ 93 | #define MPSSE_READ_NEG 0x04 /* Sample TDO/DI on negative TCK/SK edge */ 94 | #define MPSSE_LSB 0x08 /* LSB first */ 95 | #define MPSSE_DO_WRITE 0x10 /* Write TDI/DO */ 96 | #define MPSSE_DO_READ 0x20 /* Read TDO/DI */ 97 | #define MPSSE_WRITE_TMS 0x40 /* Write TMS/CS */ 98 | 99 | /* FTDI MPSSE commands */ 100 | #define SET_BITS_LOW 0x80 101 | /*BYTE DATA*/ 102 | /*BYTE Direction*/ 103 | #define SET_BITS_HIGH 0x82 104 | /*BYTE DATA*/ 105 | /*BYTE Direction*/ 106 | #define GET_BITS_LOW 0x81 107 | #define GET_BITS_HIGH 0x83 108 | #define LOOPBACK_START 0x84 109 | #define LOOPBACK_END 0x85 110 | #define TCK_DIVISOR 0x86 111 | /* H Type specific commands */ 112 | #define DIS_DIV_5 0x8a 113 | #define EN_DIV_5 0x8b 114 | #define EN_3_PHASE 0x8c 115 | #define DIS_3_PHASE 0x8d 116 | #define CLK_BITS 0x8e 117 | #define CLK_BYTES 0x8f 118 | #define CLK_WAIT_HIGH 0x94 119 | #define CLK_WAIT_LOW 0x95 120 | #define EN_ADAPTIVE 0x96 121 | #define DIS_ADAPTIVE 0x97 122 | #define CLK_BYTES_OR_HIGH 0x9c 123 | #define CLK_BYTES_OR_LOW 0x9d 124 | /*FT232H specific commands */ 125 | #define DRIVE_OPEN_COLLECTOR 0x9e 126 | /* Value Low */ 127 | /* Value HIGH */ /*rate is 12000000/((1+value)*2) */ 128 | #define DIV_VALUE(rate) (rate > 6000000)?0:((6000000/rate -1) > 0xffff)? 0xffff: (6000000/rate -1) 129 | 130 | /* Commands in MPSSE and Host Emulation Mode */ 131 | #define SEND_IMMEDIATE 0x87 132 | #define WAIT_ON_HIGH 0x88 133 | #define WAIT_ON_LOW 0x89 134 | 135 | /* Commands in Host Emulation Mode */ 136 | #define READ_SHORT 0x90 137 | /* Address_Low */ 138 | #define READ_EXTENDED 0x91 139 | /* Address High */ 140 | /* Address Low */ 141 | #define WRITE_SHORT 0x92 142 | /* Address_Low */ 143 | #define WRITE_EXTENDED 0x93 144 | /* Address High */ 145 | /* Address Low */ 146 | 147 | /* Definitions for flow control */ 148 | #define SIO_RESET 0 /* Reset the port */ 149 | #define SIO_MODEM_CTRL 1 /* Set the modem control register */ 150 | #define SIO_SET_FLOW_CTRL 2 /* Set flow control register */ 151 | #define SIO_SET_BAUD_RATE 3 /* Set baud rate */ 152 | #define SIO_SET_DATA 4 /* Set the data characteristics of the port */ 153 | 154 | #define FTDI_DEVICE_OUT_REQTYPE (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT) 155 | #define FTDI_DEVICE_IN_REQTYPE (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_IN) 156 | 157 | /* Requests */ 158 | #define SIO_RESET_REQUEST SIO_RESET 159 | #define SIO_SET_BAUDRATE_REQUEST SIO_SET_BAUD_RATE 160 | #define SIO_SET_DATA_REQUEST SIO_SET_DATA 161 | #define SIO_SET_FLOW_CTRL_REQUEST SIO_SET_FLOW_CTRL 162 | #define SIO_SET_MODEM_CTRL_REQUEST SIO_MODEM_CTRL 163 | #define SIO_POLL_MODEM_STATUS_REQUEST 0x05 164 | #define SIO_SET_EVENT_CHAR_REQUEST 0x06 165 | #define SIO_SET_ERROR_CHAR_REQUEST 0x07 166 | #define SIO_SET_LATENCY_TIMER_REQUEST 0x09 167 | #define SIO_GET_LATENCY_TIMER_REQUEST 0x0A 168 | #define SIO_SET_BITMODE_REQUEST 0x0B 169 | #define SIO_READ_PINS_REQUEST 0x0C 170 | #define SIO_READ_EEPROM_REQUEST 0x90 171 | #define SIO_WRITE_EEPROM_REQUEST 0x91 172 | #define SIO_ERASE_EEPROM_REQUEST 0x92 173 | 174 | 175 | #define SIO_RESET_SIO 0 176 | #define SIO_RESET_PURGE_RX 1 177 | #define SIO_RESET_PURGE_TX 2 178 | 179 | #define SIO_DISABLE_FLOW_CTRL 0x0 180 | #define SIO_RTS_CTS_HS (0x1 << 8) 181 | #define SIO_DTR_DSR_HS (0x2 << 8) 182 | #define SIO_XON_XOFF_HS (0x4 << 8) 183 | 184 | #define SIO_SET_DTR_MASK 0x1 185 | #define SIO_SET_DTR_HIGH ( 1 | ( SIO_SET_DTR_MASK << 8)) 186 | #define SIO_SET_DTR_LOW ( 0 | ( SIO_SET_DTR_MASK << 8)) 187 | #define SIO_SET_RTS_MASK 0x2 188 | #define SIO_SET_RTS_HIGH ( 2 | ( SIO_SET_RTS_MASK << 8 )) 189 | #define SIO_SET_RTS_LOW ( 0 | ( SIO_SET_RTS_MASK << 8 )) 190 | 191 | #define SIO_RTS_CTS_HS (0x1 << 8) 192 | 193 | /* marker for unused usb urb structures 194 | (taken from libusb) */ 195 | #define FTDI_URB_USERCONTEXT_COOKIE ((void *)0x1) 196 | 197 | #ifdef __GNUC__ 198 | #define DEPRECATED(func) func __attribute__ ((deprecated)) 199 | #elif defined(_MSC_VER) 200 | #define DEPRECATED(func) __declspec(deprecated) func 201 | #else 202 | #pragma message("WARNING: You need to implement DEPRECATED for this compiler") 203 | #define DEPRECATED(func) func 204 | #endif 205 | 206 | struct ftdi_transfer_control 207 | { 208 | int completed; 209 | unsigned char *buf; 210 | int size; 211 | int offset; 212 | struct ftdi_context *ftdi; 213 | struct libusb_transfer *transfer; 214 | }; 215 | 216 | /** 217 | \brief Main context structure for all libftdi functions. 218 | 219 | Do not access directly if possible. 220 | */ 221 | struct ftdi_context 222 | { 223 | /* USB specific */ 224 | /** libusb's context */ 225 | struct libusb_context *usb_ctx; 226 | /** libusb's usb_dev_handle */ 227 | struct libusb_device_handle *usb_dev; 228 | /** usb read timeout */ 229 | int usb_read_timeout; 230 | /** usb write timeout */ 231 | int usb_write_timeout; 232 | 233 | /* FTDI specific */ 234 | /** FTDI chip type */ 235 | enum ftdi_chip_type type; 236 | /** baudrate */ 237 | int baudrate; 238 | /** bitbang mode state */ 239 | unsigned char bitbang_enabled; 240 | /** pointer to read buffer for ftdi_read_data */ 241 | unsigned char *readbuffer; 242 | /** read buffer offset */ 243 | unsigned int readbuffer_offset; 244 | /** number of remaining data in internal read buffer */ 245 | unsigned int readbuffer_remaining; 246 | /** read buffer chunk size */ 247 | unsigned int readbuffer_chunksize; 248 | /** write buffer chunk size */ 249 | unsigned int writebuffer_chunksize; 250 | /** maximum packet size. Needed for filtering modem status bytes every n packets. */ 251 | unsigned int max_packet_size; 252 | 253 | /* FTDI FT2232C requirecments */ 254 | /** FT2232C interface number: 0 or 1 */ 255 | int interface; /* 0 or 1 */ 256 | /** FT2232C index number: 1 or 2 */ 257 | int index; /* 1 or 2 */ 258 | /* Endpoints */ 259 | /** FT2232C end points: 1 or 2 */ 260 | int in_ep; 261 | int out_ep; /* 1 or 2 */ 262 | 263 | /** Bitbang mode. 1: (default) Normal bitbang mode, 2: FT2232C SPI bitbang mode */ 264 | unsigned char bitbang_mode; 265 | 266 | /** Decoded eeprom structure */ 267 | struct ftdi_eeprom *eeprom; 268 | 269 | /** String representation of last error */ 270 | const char *error_str; 271 | 272 | /** Defines behavior in case a kernel module is already attached to the device */ 273 | enum ftdi_module_detach_mode module_detach_mode; 274 | }; 275 | 276 | /** 277 | List all handled EEPROM values. 278 | Append future new values only at the end to provide API/ABI stability*/ 279 | enum ftdi_eeprom_value 280 | { 281 | VENDOR_ID = 0, 282 | PRODUCT_ID = 1, 283 | SELF_POWERED = 2, 284 | REMOTE_WAKEUP = 3, 285 | IS_NOT_PNP = 4, 286 | SUSPEND_DBUS7 = 5, 287 | IN_IS_ISOCHRONOUS = 6, 288 | OUT_IS_ISOCHRONOUS = 7, 289 | SUSPEND_PULL_DOWNS = 8, 290 | USE_SERIAL = 9, 291 | USB_VERSION = 10, 292 | USE_USB_VERSION = 11, 293 | MAX_POWER = 12, 294 | CHANNEL_A_TYPE = 13, 295 | CHANNEL_B_TYPE = 14, 296 | CHANNEL_A_DRIVER = 15, 297 | CHANNEL_B_DRIVER = 16, 298 | CBUS_FUNCTION_0 = 17, 299 | CBUS_FUNCTION_1 = 18, 300 | CBUS_FUNCTION_2 = 19, 301 | CBUS_FUNCTION_3 = 20, 302 | CBUS_FUNCTION_4 = 21, 303 | CBUS_FUNCTION_5 = 22, 304 | CBUS_FUNCTION_6 = 23, 305 | CBUS_FUNCTION_7 = 24, 306 | CBUS_FUNCTION_8 = 25, 307 | CBUS_FUNCTION_9 = 26, 308 | HIGH_CURRENT = 27, 309 | HIGH_CURRENT_A = 28, 310 | HIGH_CURRENT_B = 29, 311 | INVERT = 30, 312 | GROUP0_DRIVE = 31, 313 | GROUP0_SCHMITT = 32, 314 | GROUP0_SLEW = 33, 315 | GROUP1_DRIVE = 34, 316 | GROUP1_SCHMITT = 35, 317 | GROUP1_SLEW = 36, 318 | GROUP2_DRIVE = 37, 319 | GROUP2_SCHMITT = 38, 320 | GROUP2_SLEW = 39, 321 | GROUP3_DRIVE = 40, 322 | GROUP3_SCHMITT = 41, 323 | GROUP3_SLEW = 42, 324 | CHIP_SIZE = 43, 325 | CHIP_TYPE = 44, 326 | POWER_SAVE = 45, 327 | CLOCK_POLARITY = 46, 328 | DATA_ORDER = 47, 329 | FLOW_CONTROL = 48, 330 | CHANNEL_C_DRIVER = 49, 331 | CHANNEL_D_DRIVER = 50, 332 | CHANNEL_A_RS485 = 51, 333 | CHANNEL_B_RS485 = 52, 334 | CHANNEL_C_RS485 = 53, 335 | CHANNEL_D_RS485 = 54, 336 | RELEASE_NUMBER = 55, 337 | EXTERNAL_OSCILLATOR= 56, 338 | USER_DATA_ADDR = 57, 339 | }; 340 | 341 | /** 342 | \brief list of usb devices created by ftdi_usb_find_all() 343 | */ 344 | struct ftdi_device_list 345 | { 346 | /** pointer to next entry */ 347 | struct ftdi_device_list *next; 348 | /** pointer to libusb's usb_device */ 349 | struct libusb_device *dev; 350 | }; 351 | #define FT1284_CLK_IDLE_STATE 0x01 352 | #define FT1284_DATA_LSB 0x02 /* DS_FT232H 1.3 amd ftd2xx.h 1.0.4 disagree here*/ 353 | #define FT1284_FLOW_CONTROL 0x04 354 | #define POWER_SAVE_DISABLE_H 0x80 355 | 356 | #define USE_SERIAL_NUM 0x08 357 | enum ftdi_cbus_func 358 | { 359 | CBUS_TXDEN = 0, CBUS_PWREN = 1, CBUS_RXLED = 2, CBUS_TXLED = 3, CBUS_TXRXLED = 4, 360 | CBUS_SLEEP = 5, CBUS_CLK48 = 6, CBUS_CLK24 = 7, CBUS_CLK12 = 8, CBUS_CLK6 = 9, 361 | CBUS_IOMODE = 0xa, CBUS_BB_WR = 0xb, CBUS_BB_RD = 0xc 362 | }; 363 | 364 | enum ftdi_cbush_func 365 | { 366 | CBUSH_TRISTATE = 0, CBUSH_TXLED = 1, CBUSH_RXLED = 2, CBUSH_TXRXLED = 3, CBUSH_PWREN = 4, 367 | CBUSH_SLEEP = 5, CBUSH_DRIVE_0 = 6, CBUSH_DRIVE1 = 7, CBUSH_IOMODE = 8, CBUSH_TXDEN = 9, 368 | CBUSH_CLK30 = 10, CBUSH_CLK15 = 11, CBUSH_CLK7_5 = 12 369 | }; 370 | 371 | enum ftdi_cbusx_func 372 | { 373 | CBUSX_TRISTATE = 0, CBUSX_TXLED = 1, CBUSX_RXLED = 2, CBUSX_TXRXLED = 3, CBUSX_PWREN = 4, 374 | CBUSX_SLEEP = 5, CBUSX_DRIVE_0 = 6, CBUSX_DRIVE1 = 7, CBUSX_IOMODE = 8, CBUSX_TXDEN = 9, 375 | CBUSX_CLK24 = 10, CBUSX_CLK12 = 11, CBUSX_CLK6 = 12, CBUSX_BAT_DETECT = 13, 376 | CBUSX_BAT_DETECT_NEG = 14, CBUSX_I2C_TXE = 15, CBUSX_I2C_RXF = 16, CBUSX_VBUS_SENSE = 17, 377 | CBUSX_BB_WR = 18, CBUSX_BB_RD = 19, CBUSX_TIME_STAMP = 20, CBUSX_AWAKE = 21 378 | }; 379 | 380 | /** Invert TXD# */ 381 | #define INVERT_TXD 0x01 382 | /** Invert RXD# */ 383 | #define INVERT_RXD 0x02 384 | /** Invert RTS# */ 385 | #define INVERT_RTS 0x04 386 | /** Invert CTS# */ 387 | #define INVERT_CTS 0x08 388 | /** Invert DTR# */ 389 | #define INVERT_DTR 0x10 390 | /** Invert DSR# */ 391 | #define INVERT_DSR 0x20 392 | /** Invert DCD# */ 393 | #define INVERT_DCD 0x40 394 | /** Invert RI# */ 395 | #define INVERT_RI 0x80 396 | 397 | /** Interface Mode. */ 398 | #define CHANNEL_IS_UART 0x0 399 | #define CHANNEL_IS_FIFO 0x1 400 | #define CHANNEL_IS_OPTO 0x2 401 | #define CHANNEL_IS_CPU 0x4 402 | #define CHANNEL_IS_FT1284 0x8 403 | 404 | #define CHANNEL_IS_RS485 0x10 405 | 406 | #define DRIVE_4MA 0 407 | #define DRIVE_8MA 1 408 | #define DRIVE_12MA 2 409 | #define DRIVE_16MA 3 410 | #define SLOW_SLEW 4 411 | #define IS_SCHMITT 8 412 | 413 | /** Driver Type. */ 414 | #define DRIVER_VCP 0x08 415 | #define DRIVER_VCPH 0x10 /* FT232H has moved the VCP bit */ 416 | 417 | #define USE_USB_VERSION_BIT 0x10 418 | 419 | #define SUSPEND_DBUS7_BIT 0x80 420 | 421 | /** High current drive. */ 422 | #define HIGH_CURRENT_DRIVE 0x10 423 | #define HIGH_CURRENT_DRIVE_R 0x04 424 | 425 | /** 426 | \brief Progress Info for streaming read 427 | */ 428 | struct size_and_time 429 | { 430 | uint64_t totalBytes; 431 | struct timeval time; 432 | }; 433 | 434 | typedef struct 435 | { 436 | struct size_and_time first; 437 | struct size_and_time prev; 438 | struct size_and_time current; 439 | double totalTime; 440 | double totalRate; 441 | double currentRate; 442 | } FTDIProgressInfo; 443 | 444 | typedef int (FTDIStreamCallback)(uint8_t *buffer, int length, 445 | FTDIProgressInfo *progress, void *userdata); 446 | 447 | /** 448 | * Provide libftdi version information 449 | * major: Library major version 450 | * minor: Library minor version 451 | * micro: Currently unused, ight get used for hotfixes. 452 | * version_str: Version as (static) string 453 | * snapshot_str: Git snapshot version if known. Otherwise "unknown" or empty string. 454 | */ 455 | struct ftdi_version_info 456 | { 457 | int major; 458 | int minor; 459 | int micro; 460 | const char *version_str; 461 | const char *snapshot_str; 462 | }; 463 | 464 | 465 | #ifdef __cplusplus 466 | extern "C" 467 | { 468 | #endif 469 | 470 | int ftdi_init(struct ftdi_context *ftdi); 471 | struct ftdi_context *ftdi_new(void); 472 | int ftdi_set_interface(struct ftdi_context *ftdi, enum ftdi_interface interface); 473 | 474 | void ftdi_deinit(struct ftdi_context *ftdi); 475 | void ftdi_free(struct ftdi_context *ftdi); 476 | void ftdi_set_usbdev (struct ftdi_context *ftdi, struct libusb_device_handle *usbdev); 477 | 478 | struct ftdi_version_info ftdi_get_library_version(void); 479 | 480 | int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devlist, 481 | int vendor, int product); 482 | void ftdi_list_free(struct ftdi_device_list **devlist); 483 | void ftdi_list_free2(struct ftdi_device_list *devlist); 484 | int ftdi_usb_get_strings(struct ftdi_context *ftdi, struct libusb_device *dev, 485 | char *manufacturer, int mnf_len, 486 | char *description, int desc_len, 487 | char *serial, int serial_len); 488 | int ftdi_usb_get_strings2(struct ftdi_context *ftdi, struct libusb_device *dev, 489 | char *manufacturer, int mnf_len, 490 | char *description, int desc_len, 491 | char *serial, int serial_len); 492 | 493 | int ftdi_eeprom_get_strings(struct ftdi_context *ftdi, 494 | char *manufacturer, int mnf_len, 495 | char *product, int prod_len, 496 | char *serial, int serial_len); 497 | int ftdi_eeprom_set_strings(struct ftdi_context *ftdi, char * manufacturer, 498 | char * product, char * serial); 499 | 500 | int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product); 501 | int ftdi_usb_open_desc(struct ftdi_context *ftdi, int vendor, int product, 502 | const char* description, const char* serial); 503 | int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int vendor, int product, 504 | const char* description, const char* serial, unsigned int index); 505 | int ftdi_usb_open_bus_addr(struct ftdi_context *ftdi, uint8_t bus, uint8_t addr); 506 | int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct libusb_device *dev); 507 | int ftdi_usb_open_string(struct ftdi_context *ftdi, const char* description); 508 | 509 | int ftdi_usb_close(struct ftdi_context *ftdi); 510 | int ftdi_usb_reset(struct ftdi_context *ftdi); 511 | int ftdi_usb_purge_rx_buffer(struct ftdi_context *ftdi); 512 | int ftdi_usb_purge_tx_buffer(struct ftdi_context *ftdi); 513 | int ftdi_usb_purge_buffers(struct ftdi_context *ftdi); 514 | 515 | int ftdi_set_baudrate(struct ftdi_context *ftdi, int baudrate); 516 | int ftdi_set_line_property(struct ftdi_context *ftdi, enum ftdi_bits_type bits, 517 | enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity); 518 | int ftdi_set_line_property2(struct ftdi_context *ftdi, enum ftdi_bits_type bits, 519 | enum ftdi_stopbits_type sbit, enum ftdi_parity_type parity, 520 | enum ftdi_break_type break_type); 521 | 522 | int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size); 523 | int ftdi_read_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize); 524 | int ftdi_read_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize); 525 | 526 | int ftdi_write_data(struct ftdi_context *ftdi, const unsigned char *buf, int size); 527 | int ftdi_write_data_set_chunksize(struct ftdi_context *ftdi, unsigned int chunksize); 528 | int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunksize); 529 | 530 | int ftdi_readstream(struct ftdi_context *ftdi, FTDIStreamCallback *callback, 531 | void *userdata, int packetsPerTransfer, int numTransfers); 532 | struct ftdi_transfer_control *ftdi_write_data_submit(struct ftdi_context *ftdi, unsigned char *buf, int size); 533 | 534 | struct ftdi_transfer_control *ftdi_read_data_submit(struct ftdi_context *ftdi, unsigned char *buf, int size); 535 | int ftdi_transfer_data_done(struct ftdi_transfer_control *tc); 536 | void ftdi_transfer_data_cancel(struct ftdi_transfer_control *tc, struct timeval * to); 537 | 538 | int ftdi_set_bitmode(struct ftdi_context *ftdi, unsigned char bitmask, unsigned char mode); 539 | int ftdi_disable_bitbang(struct ftdi_context *ftdi); 540 | int ftdi_read_pins(struct ftdi_context *ftdi, unsigned char *pins); 541 | 542 | int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency); 543 | int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency); 544 | 545 | int ftdi_poll_modem_status(struct ftdi_context *ftdi, unsigned short *status); 546 | 547 | /* flow control */ 548 | int ftdi_setflowctrl(struct ftdi_context *ftdi, int flowctrl); 549 | int ftdi_setdtr_rts(struct ftdi_context *ftdi, int dtr, int rts); 550 | int ftdi_setdtr(struct ftdi_context *ftdi, int state); 551 | int ftdi_setrts(struct ftdi_context *ftdi, int state); 552 | 553 | int ftdi_set_event_char(struct ftdi_context *ftdi, unsigned char eventch, unsigned char enable); 554 | int ftdi_set_error_char(struct ftdi_context *ftdi, unsigned char errorch, unsigned char enable); 555 | 556 | /* init eeprom for the given FTDI type */ 557 | int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, 558 | char * manufacturer, char *product, 559 | char * serial); 560 | int ftdi_eeprom_build(struct ftdi_context *ftdi); 561 | int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose); 562 | 563 | int ftdi_get_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int* value); 564 | int ftdi_set_eeprom_value(struct ftdi_context *ftdi, enum ftdi_eeprom_value value_name, int value); 565 | 566 | int ftdi_get_eeprom_buf(struct ftdi_context *ftdi, unsigned char * buf, int size); 567 | int ftdi_set_eeprom_buf(struct ftdi_context *ftdi, const unsigned char * buf, int size); 568 | 569 | int ftdi_set_eeprom_user_data(struct ftdi_context *ftdi, const char * buf, int size); 570 | 571 | int ftdi_read_eeprom(struct ftdi_context *ftdi); 572 | int ftdi_read_chipid(struct ftdi_context *ftdi, unsigned int *chipid); 573 | int ftdi_write_eeprom(struct ftdi_context *ftdi); 574 | int ftdi_erase_eeprom(struct ftdi_context *ftdi); 575 | 576 | int ftdi_read_eeprom_location (struct ftdi_context *ftdi, int eeprom_addr, unsigned short *eeprom_val); 577 | int ftdi_write_eeprom_location(struct ftdi_context *ftdi, int eeprom_addr, unsigned short eeprom_val); 578 | 579 | const char *ftdi_get_error_string(struct ftdi_context *ftdi); 580 | 581 | #ifdef __cplusplus 582 | } 583 | #endif 584 | 585 | #endif /* __libftdi_h__ */ 586 | -------------------------------------------------------------------------------- /build-data/lib/linux_aarch64/libftdi1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/linux_aarch64/libftdi1.a -------------------------------------------------------------------------------- /build-data/lib/linux_aarch64/libusb-1.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/linux_aarch64/libusb-1.0.a -------------------------------------------------------------------------------- /build-data/lib/linux_armv7l/libftdi1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/linux_armv7l/libftdi1.a -------------------------------------------------------------------------------- /build-data/lib/linux_armv7l/libusb-1.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/linux_armv7l/libusb-1.0.a -------------------------------------------------------------------------------- /build-data/lib/linux_i686/libftdi1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/linux_i686/libftdi1.a -------------------------------------------------------------------------------- /build-data/lib/linux_i686/libusb-1.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/linux_i686/libusb-1.0.a -------------------------------------------------------------------------------- /build-data/lib/linux_x86_64/libftdi1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/linux_x86_64/libftdi1.a -------------------------------------------------------------------------------- /build-data/lib/linux_x86_64/libusb-1.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/linux_x86_64/libusb-1.0.a -------------------------------------------------------------------------------- /build-data/lib/windows_amd64/libftdi1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/windows_amd64/libftdi1.a -------------------------------------------------------------------------------- /build-data/lib/windows_amd64/libusb-1.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/windows_amd64/libusb-1.0.a -------------------------------------------------------------------------------- /build-data/lib/windows_x86/libftdi1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/windows_x86/libftdi1.a -------------------------------------------------------------------------------- /build-data/lib/windows_x86/libusb-1.0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/lib/windows_x86/libusb-1.0.a -------------------------------------------------------------------------------- /build-data/linux_x86_64/libpython3.8-minimal_3.8.2-1ubuntu1.1_amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/linux_x86_64/libpython3.8-minimal_3.8.2-1ubuntu1.1_amd64.deb -------------------------------------------------------------------------------- /build-data/linux_x86_64/libpython3.8-stdlib_3.8.2-1ubuntu1.1_amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YosysHQ/fpga-toolchain/cd5dc5b5a136dabc7a6c970af1dca3ef50fc4566/build-data/linux_x86_64/libpython3.8-stdlib_3.8.2-1ubuntu1.1_amd64.deb -------------------------------------------------------------------------------- /build-data/test/top.pcf: -------------------------------------------------------------------------------- 1 | set_io clk48 44 2 | set_io usb_d_p 34 3 | set_io usb_d_n 37 4 | set_io usb_pullup 35 5 | set_io usb_pulldown 36 6 | -------------------------------------------------------------------------------- /build-data/test/top_pre_pack.py: -------------------------------------------------------------------------------- 1 | ctx.addClock("clk48", 48.0) 2 | ctx.addClock("clk12_raw", 12.0) 3 | ctx.addClock("usb_12_clk", 12.0) 4 | ctx.addClock("clk48_1", 48.0) 5 | ctx.addClock("usb_48_raw_clk", 48.0) 6 | ctx.addClock("usb_48_clk", 48.0) 7 | ctx.addClock("sys_clk", 12.0) 8 | -------------------------------------------------------------------------------- /build-data/yosys-config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | help() { 4 | { 5 | echo "" 6 | echo "Usage: $0 [--exec] [--prefix pf] args.." 7 | echo "" 8 | echo "Replacement args:" 9 | echo " --bindir fpga-toolchain/bin" 10 | echo " --datdir fpga-toolchain/share/yosys" 11 | echo "" 12 | echo "Note that various options relating to compiling have been disabled for" 13 | echo "the open-tool-forge build and will cause an error." 14 | echo "All other args are passed through as they are." 15 | echo "" 16 | echo "Use --exec to call a command instead of generating output." 17 | echo "" 18 | echo "Use --prefix to change the prefix for the special args from '--' to" 19 | echo "something else. Example:" 20 | echo "" 21 | echo " $0 --prefix @ bindir: @bindir" 22 | echo "" 23 | echo "The args --bindir and --datdir can be directly followed by a slash and" 24 | echo "additional text. Example:" 25 | echo "" 26 | echo " $0 --datdir/simlib.v" 27 | echo "" 28 | } >&2 29 | exit 1 30 | } 31 | 32 | if [ $# -eq 0 ]; then 33 | help 34 | fi 35 | 36 | if [ "$1" == "--build" ]; then 37 | echo Option --build unsupported in open-tool-forge build 38 | exit 1 39 | fi 40 | 41 | prefix="--" 42 | get_prefix=false 43 | exec_mode=false 44 | declare -a tokens=() 45 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )" 46 | 47 | for opt; do 48 | if $get_prefix; then 49 | prefix="$opt" 50 | get_prefix=false 51 | continue 52 | fi 53 | case "$opt" in 54 | "$prefix"cxx) 55 | echo Option --cxx unsupported in open-tool-forge build 56 | exit 1 57 | ;; 58 | "$prefix"cxxflags) 59 | echo Option --cxxflags unsupported in open-tool-forge build 60 | exit 1 61 | ;; 62 | "$prefix"ldflags) 63 | echo Option --ldflags unsupported in open-tool-forge build 64 | exit 1 65 | ;; 66 | "$prefix"ldlibs) 67 | echo Option --ldlibs unsupported in open-tool-forge build 68 | exit 1 69 | ;; 70 | "$prefix"bindir) 71 | tokens=( "${tokens[@]}" "${DIR}"'/bin' ) ;; 72 | "$prefix"datdir) 73 | tokens=( "${tokens[@]}" "${DIR}"'/share/yosys' ) ;; 74 | "$prefix"bindir/*) 75 | tokens=( "${tokens[@]}" "${DIR}"'/bin'"${opt#${prefix}bindir}" ) ;; 76 | "$prefix"datdir/*) 77 | tokens=( "${tokens[@]}" "${DIR}"'/share/yosys'"${opt#${prefix}datdir}" ) ;; 78 | --help|-\?|-h) 79 | if [ ${#tokens[@]} -eq 0 ]; then 80 | help 81 | else 82 | tokens=( "${tokens[@]}" "$opt" ) 83 | fi ;; 84 | --exec) 85 | if [ ${#tokens[@]} -eq 0 ]; then 86 | exec_mode=true 87 | else 88 | tokens=( "${tokens[@]}" "$opt" ) 89 | fi ;; 90 | --prefix) 91 | if [ ${#tokens[@]} -eq 0 ]; then 92 | get_prefix=true 93 | else 94 | tokens=( "${tokens[@]}" "$opt" ) 95 | fi ;; 96 | *) 97 | tokens=( "${tokens[@]}" "$opt" ) 98 | esac 99 | done 100 | 101 | if $exec_mode; then 102 | exec "${tokens[@]}" 103 | fi 104 | echo "${tokens[@]}" 105 | exit 0 106 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################## 3 | # FPGA toolchain builder # 4 | ################################## 5 | 6 | set -e 7 | 8 | # -- Toolchain name 9 | export NAME=fpga-toolchain 10 | 11 | # Use the following variables to enable and disable parts of the build 12 | # If you place a .env file in the root of the repo 13 | # then _common.sh will source it - you can use this to 14 | # locally override these variables without accidentally committing 15 | # changes. 16 | 17 | # Note that these variables are also overridden from their defaults 18 | # in azure-pipelines.yml 19 | 20 | # Enable to install deps automatically (warning, will run the package manager) 21 | INSTALL_DEPS="${INSTALL_DEPS:-1}" 22 | 23 | # Enable to delete intermediate files as we go 24 | # (keeps disk space usage lower in CI runs) 25 | CLEAN_AFTER_BUILD="${CLEAN_AFTER_BUILD:-1}" 26 | 27 | STRIP_SYMBOLS="${STRIP_SYMBOLS:-1}" 28 | 29 | # Enable each individual tool 30 | COMPILE_DFU_UTIL="${COMPILE_DFU_UTIL:-1}" 31 | COMPILE_YOSYS="${COMPILE_YOSYS:-1}" 32 | COMPILE_SBY="${COMPILE_SBY:-1}" 33 | COMPILE_ICESTORM="${COMPILE_ICESTORM:-1}" 34 | COMPILE_NEXTPNR_ICE40="${COMPILE_NEXTPNR_ICE40:-1}" 35 | COMPILE_NEXTPNR_ECP5="${COMPILE_NEXTPNR_ECP5:-0}" 36 | COMPILE_ECPPROG="${COMPILE_ECPPROG:-1}" 37 | COMPILE_OPENFPGALOADER="${COMPILE_OPENFPGALOADER:-1}" 38 | COMPILE_IVERILOG="${COMPILE_IVERILOG:-0}" 39 | COMPILE_GHDL="${COMPILE_GHDL:-1}" 40 | COMPILE_Z3="${COMPILE_Z3:-1}" 41 | COMPILE_BOOLECTOR="${COMPILE_BOOLECTOR:-1}" 42 | COMPILE_AVY="${COMPILE_AVY:-0}" # deliberately disabled - does not yet work 43 | COMPILE_YICES2="${COMPILE_YICES2:-1}" 44 | 45 | # Required for nextpnr's embedded interpreter to work 46 | # also required for symbiyosys on windows. 47 | # May be disabled during dev to speed things up 48 | BUNDLE_PYTHON="${BUNDLE_PYTHON:-1}" 49 | 50 | # Only affects windows builds - a make.exe is 51 | # included for convenience 52 | # (existing Makefiles using unix utils generally need 53 | # to be adjusted to work with this) 54 | BUNDLE_MAKE="${BUNDLE_MAKE:-1}" 55 | 56 | # Enable to compress the resulting build into a package. 57 | # May be disabled during dev to speed things up. 58 | CREATE_PACKAGE="${CREATE_PACKAGE:-1}" 59 | 60 | . scripts/_common.sh $1 61 | 62 | build_setup 63 | 64 | if [ $BUNDLE_PYTHON == "1" ]; then 65 | print ">> Bundle Python" 66 | . $WORK_DIR/scripts/bundle_python.sh 67 | fi 68 | 69 | if [ $BUNDLE_MAKE == "1" ]; then 70 | print ">> Bundle GNU Make" 71 | . $WORK_DIR/scripts/bundle_make.sh 72 | fi 73 | 74 | if [ $COMPILE_NEXTPNR_ECP5 == "1" ]; then 75 | print ">> Compile nextpnr-ecp5" 76 | . $WORK_DIR/scripts/compile_nextpnr_ecp5.sh 77 | fi 78 | 79 | if [ $COMPILE_DFU_UTIL == "1" ]; then 80 | print ">> Compile dfu-utils" 81 | . $WORK_DIR/scripts/compile_dfu_util.sh 82 | fi 83 | 84 | if [ $COMPILE_GHDL == "1" ]; then 85 | print ">> Compile ghdl" 86 | . $WORK_DIR/scripts/compile_ghdl.sh 87 | fi 88 | 89 | if [ $COMPILE_YOSYS == "1" ]; then 90 | print ">> Compile yosys" 91 | . $WORK_DIR/scripts/compile_yosys.sh 92 | fi 93 | 94 | if [ $COMPILE_SBY == "1" ]; then 95 | print ">> Compile SymbiYosys" 96 | . $WORK_DIR/scripts/compile_sby.sh 97 | fi 98 | 99 | if [ $COMPILE_YICES2 == "1" ]; then 100 | print ">> Compile Yices2" 101 | . $WORK_DIR/scripts/compile_yices2.sh 102 | fi 103 | 104 | if [ $COMPILE_Z3 == "1" ]; then 105 | print ">> Compile Z3" 106 | . $WORK_DIR/scripts/compile_z3.sh 107 | fi 108 | 109 | if [ $COMPILE_BOOLECTOR == "1" ]; then 110 | print ">> Compile Boolector" 111 | . $WORK_DIR/scripts/compile_boolector.sh 112 | fi 113 | 114 | if [ $COMPILE_AVY == "1" ]; then 115 | print ">> Compile Avy" 116 | . $WORK_DIR/scripts/compile_avy.sh 117 | fi 118 | 119 | if [ $COMPILE_ICESTORM == "1" ]; then 120 | print ">> Compile icestorm" 121 | . $WORK_DIR/scripts/compile_icestorm.sh 122 | fi 123 | 124 | if [ $COMPILE_NEXTPNR_ICE40 == "1" ]; then 125 | print ">> Compile nextpnr-ice40" 126 | . $WORK_DIR/scripts/compile_nextpnr_ice40.sh 127 | fi 128 | 129 | if [ $COMPILE_ECPPROG == "1" ]; then 130 | print ">> Compile ecpprog" 131 | . $WORK_DIR/scripts/compile_ecpprog.sh 132 | fi 133 | 134 | if [ $COMPILE_OPENFPGALOADER == "1" ]; then 135 | print ">> Compile openFPGALoader" 136 | . $WORK_DIR/scripts/compile_openfpgaloader.sh 137 | fi 138 | 139 | if [ $COMPILE_IVERILOG == "1" ]; then 140 | print ">> Compile iverilog" 141 | . $WORK_DIR/scripts/compile_iverilog.sh 142 | fi 143 | 144 | if [ $CREATE_PACKAGE == "1" ]; then 145 | print ">> Create package" 146 | mkdir -p $PACKAGE_DIR/publish $PACKAGE_DIR/publish_symbols 147 | create_package "$PACKAGE_DIR" "$NAME" "publish/$NAME-$ARCH-$VERSION" 148 | create_package "$PACKAGE_DIR" "${NAME}_symbols" "publish_symbols/symbols_${NAME}-$ARCH-$VERSION" 149 | 150 | if [ ${ARCH:0:7} = "windows" ]; then 151 | create_package "$PACKAGE_DIR" "${NAME}-progtools" "publish/${NAME}-progtools-$ARCH-$VERSION" 152 | fi 153 | fi 154 | -------------------------------------------------------------------------------- /build_bba.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################## 3 | # FPGA toolchain builder # 4 | ################################## 5 | 6 | set -e 7 | 8 | # -- Toolchain name 9 | export NAME=ecp5-bba 10 | 11 | # Enable to install deps automatically (warning, will run the package manager) 12 | INSTALL_DEPS="${INSTALL_DEPS:-1}" 13 | 14 | export VERSION=nightly 15 | . scripts/_common.sh linux_x86_64 16 | 17 | build_setup 18 | 19 | print ">> Compile nextpnr-ecp5-bba" 20 | . $WORK_DIR/scripts/compile_nextpnr_ecp5_bba.sh 21 | 22 | print ">> Create package" 23 | create_package "$PACKAGE_DIR" "$NAME" "$NAME-noarch-$VERSION" 24 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################## 3 | # FPGA toolchain cleaner # 4 | ################################## 5 | 6 | set -e 7 | 8 | . scripts/_common.sh $1 9 | 10 | printf "Are you sure? [y/N]: " 11 | read RESP 12 | case "$RESP" in 13 | [yY][eE][sS]|[yY]) 14 | # -- Remove the package dir 15 | rm -r -f $PACKAGE_DIR 16 | 17 | # -- Remove the build dir 18 | rm -r -f $BUILD_DIR 19 | 20 | rm -r -f $UPSTREAM_DIR 21 | 22 | echo "" 23 | echo ">> CLEAN" 24 | ;; 25 | *) 26 | echo "" 27 | echo ">> ABORT" 28 | ;; 29 | esac 30 | -------------------------------------------------------------------------------- /patches/ghdl/ghdl_largs.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makefile.in b/Makefile.in 2 | index ddae0c82..2ab769d0 100644 3 | --- a/Makefile.in 4 | +++ b/Makefile.in 5 | @@ -200,7 +200,7 @@ GHDL_MCODE_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir 6 | ghdl_mcode$(EXEEXT): GRT_FLAGS+=-DWITH_GNAT_RUN_TIME 7 | ghdl_mcode$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) $(ORTHO_DEPS) \ 8 | memsegs_c.o chkstk.o version.ads force 9 | - $(GNATMAKE) -o $@ -gnat12 $(GHDL_MCODE_INCFLAGS) $(GNATFLAGS) -gnatw.A ghdl_jit.adb $(GNAT_BARGS) -largs memsegs_c.o chkstk.o $(GRT_ADD_OBJS) $(LDFLAGS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB) $(GRT_EXEC_OPTS)) 10 | + $(GNATMAKE) -o $@ -gnat12 $(GHDL_MCODE_INCFLAGS) $(GNATFLAGS) -gnatw.A ghdl_jit.adb $(GNAT_BARGS) -largs memsegs_c.o chkstk.o $(GRT_ADD_OBJS) $(LDFLAGS) $(GNAT_LARGS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB) $(GRT_EXEC_OPTS)) 11 | 12 | memsegs_c.o: $(srcdir)/src/ortho/mcode/memsegs_c.c 13 | $(CC) -c $(COVERAGE_FLAGS) $(CFLAGS) -o $@ $< 14 | @@ -314,7 +314,7 @@ ghdl1-gcc$(EXEEXT): version.ads force 15 | ghdl_gcc$(EXEEXT): version.ads $(GRT_SYNTH_OBJS) force 16 | $(GNATMAKE) $(GHDL_GCC_INCFLAGS) -aI$(srcdir)/src/ghdldrv \ 17 | $(GNATFLAGS) ghdl_gcc $(GNAT_BARGS) \ 18 | - -largs $(LDFLAGS) $(GRT_SYNTH_OBJS) 19 | + -largs $(LDFLAGS) $(GRT_SYNTH_OBJS) $(GNAT_LARGS) 20 | 21 | libs.vhdl.local_gcc: ghdl_gcc$(EXEEXT) ghdl1-gcc$(EXEEXT) 22 | $(MAKE) -f $(srcdir)/libraries/Makefile.inc $(LIBVHDL_FLAGS_TO_PASS) GHDL=$(PWD)/ghdl_gcc$(EXEEXT) GHDL_FLAGS="--GHDL1=$(PWD)/ghdl1-gcc$(EXEEXT) $(LIB_CFLAGS)" vhdl.libs.all libs.vhdl.standard 23 | @@ -342,7 +342,7 @@ ghdl_llvm_jit$(EXEEXT): GRT_FLAGS+=-DWITH_GNAT_RUN_TIME 24 | ghdl_llvm_jit$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) $(ORTHO_DEPS) \ 25 | llvm-cbindings.o version.ads force 26 | $(GNATMAKE) -o $@ $(GHDL_LLVM_INCFLAGS) $(GNATFLAGS) ghdl_jit.adb \ 27 | - $(GNAT_BARGS) -largs llvm-cbindings.o $(GRT_ADD_OBJS) \ 28 | + $(GNAT_BARGS) -largs llvm-cbindings.o $(GNAT_LARGS) $(GRT_ADD_OBJS) \ 29 | $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) --LINK=$(CXX) \ 30 | `$(LLVM_CONFIG) --ldflags --libs --system-libs` $(LDFLAGS) 31 | 32 | @@ -363,7 +363,7 @@ ghdl_llvm$(EXEEXT): version.ads $(GRT_SYNTH_OBJS) force 33 | $(GNATMAKE) $(GHDL_LLVM_INCFLAGS) \ 34 | -aI$(srcdir)/src/ghdldrv $(GNATFLAGS) \ 35 | ghdl_llvm $(GNAT_BARGS) \ 36 | - -largs $(LDFLAGS) $(GRT_SYNTH_OBJS) 37 | + -largs $(LDFLAGS) $(GRT_SYNTH_OBJS) $(GNAT_LARGS) 38 | 39 | ghdl1-llvm$(EXEEXT): version.ads force 40 | $(MAKE) -f $(srcdir)/src/ortho/$(llvm_be)/Makefile \ 41 | @@ -400,7 +400,7 @@ uninstall.llvm: uninstall.llvm.program uninstall.grt 42 | GHDL_SIMUL_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/vhdl/simulate -aI$(srcdir)/src/synth 43 | 44 | ghdl_simul$(EXEEXT): $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) version.ads force 45 | - $(GNATMAKE) $(GHDL_SIMUL_INCFLAGS) $(GNATFLAGS) -gnat12 ghdl_simul $(GNAT_BARGS) -largs $(LDFLAGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) 46 | + $(GNATMAKE) $(GHDL_SIMUL_INCFLAGS) $(GNATFLAGS) -gnat12 ghdl_simul $(GNAT_BARGS) -largs $(LDFLAGS) $(GNAT_LARGS) $(GRT_ADD_OBJS) $(subst @,$(GRTSRCDIR),$(GRT_EXTRA_LIB)) 47 | 48 | libs.vhdl.simul: ghdl_simul$(EXEEXT) 49 | $(MAKE) -f $(srcdir)/libraries/Makefile.inc $(LIBVHDL_FLAGS_TO_PASS) GHDL=$(PWD)/ghdl_simul$(EXEEXT) GHDL_FLAGS="" VHDLLIBS_COPY_OBJS=no vhdl.libs.all 50 | diff --git a/scripts/windows/mcode/Makefile.in b/scripts/windows/mcode/Makefile.in 51 | index 0f7b7422..be1f1151 100644 52 | --- a/scripts/windows/mcode/Makefile.in 53 | +++ b/scripts/windows/mcode/Makefile.in 54 | @@ -14,7 +14,7 @@ GRTSRCDIR=grt 55 | ####grt Makefile.inc 56 | 57 | ghdl_mcode: default_paths.ads $(GRT_ADD_OBJS) mmap_binding.o force 58 | - gnatmake -aIghdldrv -aIghdl -aIortho -aIgrt $(GNATFLAGS) ghdl_mcode $(GNAT_BARGS) -largs mmap_binding.o $(GRT_ADD_OBJS) $(GRT_EXTRA_LIB) -Wl,--version-script=$(GRTSRCDIR)/grt.ver -Wl,--export-dynamic 59 | + gnatmake -aIghdldrv -aIghdl -aIortho -aIgrt $(GNATFLAGS) ghdl_mcode $(GNAT_BARGS) -largs mmap_binding.o $(GNAT_LARGS) $(GRT_ADD_OBJS) $(GRT_EXTRA_LIB) -Wl,--version-script=$(GRTSRCDIR)/grt.ver -Wl,--export-dynamic 60 | 61 | mmap_binding.o: ortho/mmap_binding.c 62 | $(CC) -c -g -o $@ $< 63 | -------------------------------------------------------------------------------- /patches/ghdl/ghdl_version.patch: -------------------------------------------------------------------------------- 1 | --- a/src/version.in 2 | +++ b/src/version.in 3 | @@ -11,6 +11,7 @@ package Version is 4 | 5 | Ghdl_Release : constant String := 6 | "(@DESC@)" & 7 | - " [Dunoon edition]"; 8 | + " [Dunoon edition]" & 9 | + " @BUILDER@"; 10 | 11 | end Version; 12 | -------------------------------------------------------------------------------- /patches/ghdl/libghdl_static.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/grt/grt-zlib.ads b/src/grt/grt-zlib.ads 2 | index 9dfee366..064ce815 100644 3 | --- a/src/grt/grt-zlib.ads 4 | +++ b/src/grt/grt-zlib.ads 5 | @@ -27,7 +27,6 @@ with System; use System; 6 | with Grt.C; use Grt.C; 7 | 8 | package Grt.Zlib is 9 | - pragma Linker_Options ("-lz"); 10 | 11 | type gzFile is new System.Address; 12 | -------------------------------------------------------------------------------- /patches/yosys/yosys_ghdl.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makefile b/Makefile 2 | index 45213c6f..f8393ea4 100644 3 | --- a/Makefile 4 | +++ b/Makefile 5 | @@ -82,7 +83,7 @@ all: top-all 6 | YOSYS_SRC := $(dir $(firstword $(MAKEFILE_LIST))) 7 | VPATH := $(YOSYS_SRC) 8 | 9 | -CXXFLAGS := $(CXXFLAGS) -Wall -Wextra -ggdb -I. -I"$(YOSYS_SRC)" -MD -MP -D_YOSYS_ -fPIC -I$(PREFIX)/include 10 | +CXXFLAGS := $(CXXFLAGS) -w -I. -I"$(YOSYS_SRC)" -MD -MP -D_YOSYS_ -I$(PREFIX)/include 11 | LDLIBS := $(LDLIBS) -lstdc++ -lm 12 | PLUGIN_LDFLAGS := 13 | 14 | @@ -119,7 +120,7 @@ export PATH := $(PORT_PREFIX)/bin:$(PATH) 15 | endif 16 | 17 | else 18 | -LDFLAGS += -rdynamic 19 | +LDFLAGS += 20 | LDLIBS += -lrt 21 | endif 22 | 23 | @@ -184,7 +185,7 @@ endif 24 | ifeq ($(CONFIG),clang) 25 | CXX = clang 26 | LD = clang++ 27 | -CXXFLAGS += -std=c++11 -Os 28 | +CXXFLAGS += -std=c++11 29 | ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H" 30 | 31 | ifneq ($(SANITIZER),) 32 | -------------------------------------------------------------------------------- /scripts/_common.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ################################## 3 | # FPGA toolchain builder # 4 | ################################## 5 | 6 | set -e 7 | 8 | # Set english language for propper pattern matching 9 | export LC_ALL=C 10 | 11 | [ -f .env ] && source .env 12 | 13 | export VERSION="${VERSION:-nightly-$(date +%Y%m%d | tr -d '\n')}" 14 | 15 | # -- Target architectures 16 | export ARCH=$1 17 | # TARGET_ARCHS="linux_x86_64 linux_i686 linux_armv7l linux_aarch64 windows_x86 windows_amd64 darwin" 18 | TARGET_ARCHS="linux_x86_64 windows_amd64 darwin" 19 | 20 | # -- Store current dir 21 | export WORK_DIR=$PWD 22 | # -- Folder for building the source code 23 | export BUILDS_DIR=$WORK_DIR/_builds 24 | # -- Folder for storing the generated packages 25 | export PACKAGES_DIR=$WORK_DIR/_packages 26 | # -- Folder for storing the source code from github 27 | export UPSTREAM_DIR=$WORK_DIR/_upstream 28 | 29 | # -- Directory for compiling the tools 30 | export BUILD_DIR=$BUILDS_DIR/build_$ARCH 31 | 32 | # -- Directory for installation the target files 33 | export PACKAGE_DIR=$PACKAGES_DIR/build_$ARCH 34 | 35 | # -- Test script function 36 | function test_bin { 37 | . $WORK_DIR/scripts/test_bin.sh $1 38 | if [ $? != "0" ]; then 39 | exit 1 40 | fi 41 | } 42 | 43 | # -- Print function 44 | function print { 45 | echo "" 46 | echo $1 47 | echo "" 48 | } 49 | 50 | function git_clone { 51 | local dir_name=$1 52 | local git_url=$2 53 | local git_commit=$3 54 | local update_submodules=$4 55 | 56 | pushd $UPSTREAM_DIR 57 | 58 | # -- Clone the sources from github 59 | test -e $dir_name || git clone $git_url $dir_name 60 | git -C $dir_name pull 61 | git -C $dir_name checkout $git_commit 62 | [[ ! -z "$update_submodules" ]] && git -C $dir_name submodule init 63 | [[ ! -z "$update_submodules" ]] && git -C $dir_name submodule update 64 | git -C $dir_name --no-pager log -1 65 | 66 | # -- Copy the upstream sources into the build directory 67 | rsync -a $dir_name $BUILD_DIR --exclude .git 68 | 69 | popd 70 | } 71 | 72 | function git_clone_direct { 73 | local dir_name=$1 74 | local git_url=$2 75 | local git_commit=$3 76 | local update_submodules=$4 77 | 78 | pushd $BUILD_DIR 79 | 80 | # -- Clone the sources from github 81 | test -e $dir_name || git clone $git_url $dir_name 82 | git -C $dir_name pull 83 | git -C $dir_name checkout $git_commit 84 | [[ ! -z "$update_submodules" ]] && git -C $dir_name submodule init 85 | [[ ! -z "$update_submodules" ]] && git -C $dir_name submodule update 86 | git -C $dir_name log -1 87 | 88 | popd 89 | } 90 | 91 | function clean_build { 92 | local dir_name=$1 93 | 94 | if [ $CLEAN_AFTER_BUILD == "1" ]; then 95 | cd $WORK_DIR 96 | rm -rf $UPSTREAM_DIR/$dir_name 97 | rm -rf $BUILD_DIR/$dir_name 98 | fi 99 | } 100 | 101 | function strip_binaries() { 102 | local binary_paths="$1" 103 | for path in $binary_paths 104 | do 105 | local src_file=$PACKAGE_DIR/$NAME/$path 106 | 107 | if [ ! -f "$src_file" ]; then 108 | echo "Skipping strip of $src_file - does not exist." 109 | fi 110 | 111 | if [ $ARCH = "darwin" ] 112 | then 113 | local dst_file=$PACKAGE_DIR/${NAME}_symbols/$path.dSYM 114 | dsymutil -o $dst_file $src_file 115 | if [ $STRIP_SYMBOLS == "1" ]; then 116 | strip $src_file 117 | fi 118 | else 119 | local dst_file=$PACKAGE_DIR/${NAME}_symbols/$path.debug 120 | objcopy --only-keep-debug "${src_file}" "${dst_file}" 121 | if [ $STRIP_SYMBOLS == "1" ]; then 122 | strip $src_file --strip-debug --strip-unneeded 123 | fi 124 | fi 125 | done 126 | } 127 | 128 | function create_package() { 129 | local base_dir=$1 130 | local compress_dir=$2 131 | local package_name=$3 132 | 133 | pushd $base_dir 134 | echo $VERSION > ./$compress_dir/VERSION 135 | 136 | if [ ${ARCH:0:7} = "windows" ] 137 | then 138 | zip -r $package_name.zip $compress_dir 139 | 7z a $package_name.7z $compress_dir 140 | else 141 | tar -czf $package_name.tar.gz $compress_dir 142 | tar cf - $compress_dir | xz -z - > $package_name.tar.xz 143 | fi 144 | popd 145 | } 146 | 147 | function wget_retry { 148 | local max_retry=3 149 | local counter=0 150 | until wget "$@" 151 | do 152 | sleep 1 153 | [[ counter -eq $max_retry ]] && echo "Failed!" && exit 1 154 | echo "Trying again. Try #$counter" 155 | ((counter++)) 156 | done 157 | } 158 | 159 | # -- Initial setup for the build tree 160 | function build_setup { 161 | # -- Create the build directory 162 | mkdir -p $BUILDS_DIR 163 | # -- Create the packages directory 164 | mkdir -p $PACKAGES_DIR 165 | # -- Create the upstream directory 166 | mkdir -p $UPSTREAM_DIR 167 | 168 | # -- Create the build dir 169 | mkdir -p $BUILD_DIR 170 | 171 | # -- Create the package folders 172 | mkdir -p $PACKAGE_DIR/$NAME/{bin,lib,share} 173 | mkdir -p $PACKAGE_DIR/${NAME}_symbols/{bin,lib} 174 | mkdir -p $PACKAGE_DIR/${NAME}-progtools/bin 175 | 176 | if [ $INSTALL_DEPS == "1" ]; then 177 | print ">> Install dependencies" 178 | . $WORK_DIR/scripts/install_dependencies.sh 179 | fi 180 | 181 | print ">> Set build flags" 182 | . $WORK_DIR/scripts/build_setup.sh 183 | } 184 | 185 | # -- Check ARCH 186 | if [[ $# > 1 ]]; then 187 | echo "" 188 | echo "Error: too many arguments" 189 | exit 1 190 | fi 191 | 192 | if [[ $# < 1 ]]; then 193 | echo "" 194 | echo "Usage: bash build.sh TARGET" 195 | echo "" 196 | echo "Targets: $TARGET_ARCHS" 197 | exit 1 198 | fi 199 | 200 | if [[ $ARCH =~ [[:space:]] || ! $TARGET_ARCHS =~ (^|[[:space:]])$ARCH([[:space:]]|$) ]]; then 201 | echo "" 202 | echo ">>> WRONG ARCHITECTURE \"$ARCH\"" 203 | exit 1 204 | fi 205 | 206 | echo "" 207 | echo ">>> ARCHITECTURE \"$ARCH\"" 208 | -------------------------------------------------------------------------------- /scripts/build_setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Build setup script 3 | 4 | set -e 5 | 6 | export MAKE="make" 7 | 8 | if [ $ARCH == "darwin" ]; then 9 | export J=`sysctl -n hw.ncpu` 10 | else 11 | export J=`nproc` 12 | fi 13 | echo nproc=$J 14 | 15 | export SED=sed 16 | 17 | if [ $ARCH == "linux_x86_64" ]; then 18 | export CC="gcc" 19 | export CXX="g++" 20 | export ABC_ARCHFLAGS="-DLIN64 -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 -DSIZEOF_INT=4" 21 | export EMBEDDED_PY_VER=$(python3 -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))') 22 | fi 23 | 24 | if [ $ARCH == "linux_i686" ]; then 25 | export CC="gcc -m32" 26 | export CXX="g++ -m32" 27 | export ABC_ARCHFLAGS="-DLIN -DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4" 28 | sudo ln -s /usr/include/asm-generic /usr/include/asm 29 | fi 30 | 31 | if [ $ARCH == "linux_armv7l" ]; then 32 | export CC="arm-linux-gnueabihf-gcc" 33 | export CXX="arm-linux-gnueabihf-g++" 34 | export HOST_FLAGS="--host=arm-linux-gnueabihf" 35 | export ABC_ARCHFLAGS="-DLIN -DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4" 36 | fi 37 | 38 | if [ $ARCH == "linux_aarch64" ]; then 39 | export CC="aarch64-linux-gnu-gcc" 40 | export CXX="aarch64-linux-gnu-g++" 41 | export HOST_FLAGS="--host=aarch64-linux-gnu" 42 | export ABC_ARCHFLAGS="-DLIN64 -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 -DSIZEOF_INT=4" 43 | fi 44 | 45 | if [ $ARCH == "windows_x86" ]; then 46 | export PY=".py" 47 | export EXE=".exe" 48 | export CC="i686-w64-mingw32-gcc" 49 | export CXX="i686-w64-mingw32-g++" 50 | export HOST_FLAGS="--host=i686-w64-mingw32" 51 | export ABC_ARCHFLAGS="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -D_POSIX_SOURCE -fpermissive -w" 52 | fi 53 | 54 | if [ $ARCH == "windows_amd64" ]; then 55 | export PY=".py" 56 | export EXE=".exe" 57 | export CC="x86_64-w64-mingw32-gcc" 58 | export CXX="x86_64-w64-mingw32-g++" 59 | export HOST_FLAGS="--host=x86_64-w64-mingw32" 60 | export ABC_ARCHFLAGS="-DSIZEOF_VOID_P=8 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -DHAVE_STRUCT_TIMESPEC -D_POSIX_SOURCE -fpermissive -w" 61 | export MAKE="mingw32-make" 62 | 63 | export EMBEDDED_PY_VER=$(python.exe -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))') 64 | 65 | export J=$(($J*2)) 66 | fi 67 | 68 | if [ $ARCH == "darwin" ]; then 69 | export CC="clang" 70 | export CXX="clang++" 71 | export ABC_ARCHFLAGS="-DLIN64 -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 -DSIZEOF_INT=4" 72 | export J=`sysctl -n hw.ncpu` 73 | export MACOSX_DEPLOYMENT_TARGET="10.10" 74 | 75 | export LIBFTDI_VERSION=$(brew list --versions libftdi | tr ' ' '\n' | tail -1) 76 | export LIBFTDI_ROOT=$(brew --cellar libftdi)/$LIBFTDI_VERSION 77 | export LIBUSB_VERSION=$(brew list --versions libusb | tr ' ' '\n' | tail -1) 78 | export LIBUSB_ROOT=$(brew --cellar libusb)/$LIBUSB_VERSION 79 | export ZLIB_ROOT=$(brew --cellar zlib)/$(brew list --versions zlib | tr ' ' '\n' | tail -1) 80 | export CONDA_ROOT=/tmp/conda 81 | export EMBEDDED_PY_VER=$($CONDA_ROOT/bin/python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))') 82 | 83 | GNAT_VERSION=9.1.0 84 | GNAT_ARCHIVE=gcc-$GNAT_VERSION-x86_64-apple-darwin15-bin 85 | export GNAT_ROOT=/tmp/gnat/$GNAT_ARCHIVE 86 | export SED=gsed 87 | fi 88 | 89 | echo Running with J=$J 90 | -------------------------------------------------------------------------------- /scripts/bundle_make.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | MAKE_VERSION=4.3 6 | MAKE_URL_WIN=https://sourceforge.net/projects/ezwinports/files/make-$MAKE_VERSION-without-guile-w32-bin.zip/download 7 | 8 | mkdir -p $BUILD_DIR/gnu_make 9 | cd $BUILD_DIR/gnu_make 10 | 11 | if [ ${ARCH:0:7} = "windows" ] 12 | then 13 | wget_retry $MAKE_URL_WIN -O gnumake.zip 14 | unzip gnumake.zip 15 | cp bin/make.exe $PACKAGE_DIR/$NAME/bin/ 16 | else 17 | print "Skipping bundling make (this platform should provide its own version of this tool)" 18 | fi 19 | 20 | clean_build gnu_make 21 | -------------------------------------------------------------------------------- /scripts/bundle_python.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e -x 4 | 5 | if [ $ARCH == "linux_x86_64" ]; then 6 | # Install a copy of Python, since Python libraries are not compatible 7 | # across minor versions. 8 | mkdir -p $BUILD_DIR/libpython3 9 | cd $BUILD_DIR/libpython3 10 | for pkg in $(ls -1 ${WORK_DIR}/build-data/$ARCH/*.deb) 11 | do 12 | echo "Extracting $pkg..." 13 | ar p $pkg data.tar.xz | tar xJ 14 | done 15 | mkdir -p $PACKAGE_DIR/$NAME/lib/python$EMBEDDED_PY_VER 16 | mv usr/lib/python$EMBEDDED_PY_VER/* $PACKAGE_DIR/$NAME/lib/python$EMBEDDED_PY_VER 17 | cd .. 18 | 19 | clean_build libpython3 20 | elif [ $ARCH == "windows_amd64" ]; then 21 | mkdir -p $PACKAGE_DIR/$NAME/lib/python$EMBEDDED_PY_VER 22 | cp -L -R /mingw64/lib/python$EMBEDDED_PY_VER $PACKAGE_DIR/$NAME/lib 23 | # this isn't necessary and takes up ~half the size 24 | rm -rf $PACKAGE_DIR/$NAME/lib/python$EMBEDDED_PY_VER/test 25 | cp /mingw64/bin/{libgcc_s_seh-1.dll,libstdc++-6.dll,libwinpthread-1.dll,libpython$EMBEDDED_PY_VER.dll} $PACKAGE_DIR/$NAME/bin 26 | cp /mingw64/bin/python$EMBEDDED_PY_VER.exe $PACKAGE_DIR/$NAME/bin/python3-private.exe 27 | 28 | elif [ $ARCH == "darwin" ]; then 29 | mkdir -p $PACKAGE_DIR/$NAME/lib/python$EMBEDDED_PY_VER 30 | cp -L -R $CONDA_ROOT/lib/python$EMBEDDED_PY_VER $PACKAGE_DIR/$NAME/lib 31 | fi 32 | -------------------------------------------------------------------------------- /scripts/compile_avy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [ $ARCH = "darwin" ] 6 | then 7 | # TODO: might not be too hard to hack a static link: libz.1.dylib and libboost_program_options-mt.dylib 8 | print "Skipping building Avy" 9 | # cmake -DCMAKE_BUILD_TYPE=Release ../ 10 | # $MAKE -j$J 11 | elif [ ${ARCH:0:7} = "windows" ] 12 | then 13 | # steps I took so far to try and get this working on windows: 14 | # 1. replace abc submodule with yosys version (which is maintained by yosys team and supports mingw) 15 | # 2. copy in the abc/cmake dir from the avy version 16 | # 3. replace contents of abc/lib/pthread.h with "#include " to use mingw system winpthreads headers 17 | # 4. patch abc/arch_flags.c for NT64/NT instead of LIN64/LIN 18 | # 5. remove these lines in abc/Makefile: 19 | # ifneq ($(OS), FreeBSD) 20 | # LIBS += -ldl 21 | # endif 22 | # ifneq ($(findstring Darwin, $(shell uname)), Darwin) 23 | # LIBS += -lrt 24 | # endif 25 | # 6. minisat - commented out various lines using setrlimit and SIGXCPU 26 | # 7. glucose - basically the same patches that minisat needed 27 | # 8. (stopped at this point) The newer version of ABC I used has made some minor breaking changes to the API 28 | # e.g.: extavy\avy\src\Pdr.cc:886:60: error: too few arguments to function 'int abc::Pdr_ManCheckCube(abc::Pdr_Man_t*, int, abc::Pdr_Set_t*, abc::Pdr_Set_t**, int, int, int)' 29 | 30 | # cmake -G "MinGW Makefiles" -DABC_CXXFLAGS="-DABC_USE_STDINT_H" -DCMAKE_BUILD_TYPE=Release -DAVY_STATIC_EXE=ON -DABC_SOURCE_DIR=../abc ../ 31 | # $MAKE -j$J 32 | print "Skipping building Avy" 33 | 34 | else 35 | dir_name=avy 36 | commit=master 37 | git_url=https://bitbucket.org/arieg/extavy.git 38 | 39 | git_clone $dir_name $git_url $commit 1 # enable submodule update 40 | 41 | cd $BUILD_DIR/$dir_name 42 | mkdir -p build 43 | cd build 44 | 45 | cmake -DCMAKE_BUILD_TYPE=Release -DAVY_STATIC_EXE=ON ../ 46 | $MAKE -j$J 47 | 48 | test_bin avy/src/avy$EXE 49 | cp avy/src/avy$EXE $PACKAGE_DIR/$NAME/bin 50 | strip_binaries bin/avy$EXE 51 | 52 | clean_build $dir_name 53 | fi 54 | -------------------------------------------------------------------------------- /scripts/compile_boolector.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=boolector 6 | commit=master 7 | git_url=https://github.com/boolector/boolector.git 8 | 9 | git_clone $dir_name $git_url $commit 10 | 11 | cd $BUILD_DIR/$dir_name 12 | 13 | if [ $ARCH = "darwin" ] 14 | then 15 | ./contrib/setup-btor2tools.sh 16 | ./contrib/setup-lingeling.sh 17 | ./configure.sh 18 | 19 | $MAKE -C build -j$J 20 | elif [ ${ARCH:0:7} = "windows" ] 21 | then 22 | $SED -i 's/MINGW32/MINGW/;' ./contrib/setup-utils.sh # fix windows detection on MINGW64 23 | $SED -i 's|\./configure.sh -fPIC|\./configure.sh -fPIC -static|;' ./contrib/setup-btor2tools.sh 24 | # this is easier than working out how to escape an arg with a space in CMAKE_OPTS 25 | $SED -i 's/cmake .. $cmake_opts/cmake -DIS_WINDOWS_BUILD=1 -G "MinGW Makefiles" .. $cmake_opts/;' ./configure.sh 26 | 27 | ./contrib/setup-btor2tools.sh 28 | ./contrib/setup-lingeling.sh 29 | ./configure.sh 30 | 31 | $MAKE -C build -j$J 32 | else 33 | $SED -i 's|\./configure.sh -fPIC|\./configure.sh -fPIC -static|;' ./contrib/setup-btor2tools.sh 34 | 35 | ./contrib/setup-btor2tools.sh 36 | ./contrib/setup-lingeling.sh 37 | ./configure.sh 38 | 39 | $MAKE -C build -j$J 40 | fi 41 | 42 | for i in build/bin/{boolector*,btor*} deps/btor2tools/bin/btorsim* 43 | do 44 | test_bin $i 45 | cp $i $PACKAGE_DIR/$NAME/bin 46 | done 47 | 48 | strip_binaries bin/{boolector,btorimc,btormbt,btormc,btorsim,btoruntrace}$EXE 49 | 50 | clean_build $dir_name 51 | -------------------------------------------------------------------------------- /scripts/compile_dfu_util.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Compile dfu-util script 3 | 4 | set -e 5 | 6 | dir_name=dfu-util 7 | commit=master 8 | git_url=https://git.code.sf.net/p/dfu-util/dfu-util 9 | 10 | git_clone $dir_name $git_url $commit 11 | 12 | cd $BUILD_DIR/$dir_name 13 | 14 | ./autogen.sh 15 | # -- Compile it 16 | if [ $ARCH == "darwin" ]; then 17 | ./configure --libdir=/opt/local/lib \ 18 | --includedir=/opt/local/include \ 19 | USB_CFLAGS="-I$LIBUSB_ROOT/include/libusb-1.0" \ 20 | USB_LIBS="$LIBUSB_ROOT/lib/libusb-1.0.a -Wl,-framework,IOKit -Wl,-framework,CoreFoundation" 21 | $MAKE SUBDIRS=src 22 | elif [ ${ARCH:0:7} = "windows" ] 23 | then 24 | ./configure USB_LIBS="-static -lpthread -lusb-1.0" 25 | $MAKE SUBDIRS=src 26 | else 27 | ./configure USB_CFLAGS="-I$WORK_DIR/build-data/include/libusb-1.0" USB_LIBS="-static $WORK_DIR/build-data/lib/$ARCH/libusb-1.0.a -lpthread" 28 | $MAKE SUBDIRS=src 29 | fi 30 | 31 | TOOLS="dfu-util dfu-prefix dfu-suffix" 32 | 33 | # -- Test the generated executables 34 | for tool in $TOOLS; do 35 | test_bin src/$tool$EXE 36 | done 37 | 38 | # -- Copy the executables to the bin dir 39 | for tool in $TOOLS; do 40 | cp src/$tool$EXE $PACKAGE_DIR/$NAME/bin/$tool$EXE 41 | done 42 | 43 | strip_binaries bin/{dfu-util,dfu-prefix,dfu-suffix}$EXE 44 | 45 | if [ ${ARCH:0:7} = "windows" ]; then 46 | cp $PACKAGE_DIR/$NAME/bin/{dfu-util,dfu-prefix,dfu-suffix}$EXE $PACKAGE_DIR/${NAME}-progtools/bin/ 47 | fi 48 | 49 | clean_build $dir_name 50 | -------------------------------------------------------------------------------- /scripts/compile_ecpprog.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=ecpprog 6 | commit=master 7 | git_url=https://github.com/gregdavill/ecpprog.git 8 | 9 | git_clone $dir_name $git_url $commit 10 | 11 | cd $BUILD_DIR/$dir_name/ecpprog 12 | 13 | # -- Compile it 14 | if [ $ARCH == "darwin" ]; then 15 | sed -i "" "s/-ggdb //;" Makefile 16 | # pkg-config is used to set LDLIBS in this Makefile and doesn't quite do what we want 17 | sed -i "" "s/\$^ \$(LDLIBS)/\$^ \$(LDSTATICLIBS)/g" Makefile 18 | $MAKE -j$J CC="$CC" \ 19 | PKG_CONFIG=":" \ 20 | LDSTATICLIBS="$LIBFTDI_ROOT/lib/libftdi1.a $LIBUSB_ROOT/lib/libusb-1.0.a -Wl,-framework,IOKit -Wl,-framework,CoreFoundation" \ 21 | CFLAGS="-MD -O0 -Wall -std=c99 -I$LIBFTDI_ROOT/include/libftdi1 $CFLAGS" 22 | elif [ ${ARCH:0:7} = "windows" ] 23 | then 24 | sed -i "s/-ggdb //;" Makefile 25 | $MAKE -j$J CC="$CC" \ 26 | LDFLAGS="-static -pthread" 27 | else 28 | sed -i "s/-ggdb //;" Makefile 29 | sed -i "s/\$^ \$(LDLIBS)/\$^ \$(LDLIBS) \$(LDUSBSTATIC)/g" Makefile 30 | $MAKE -j$J CC="$CC" \ 31 | LDFLAGS="-static -pthread -L$WORK_DIR/build-data/lib/$ARCH " \ 32 | LDUSBSTATIC="-lusb-1.0"\ 33 | CFLAGS="-MD -O0 -Wall -std=c99 -I$WORK_DIR/build-data/include/libftdi1 -I$WORK_DIR/build-data/include/libusb-1.0" 34 | fi 35 | 36 | # -- Test the generated executable 37 | test_bin ecpprog$EXE 38 | 39 | # -- Copy the executable to the bin dir 40 | cp ecpprog$EXE $PACKAGE_DIR/$NAME/bin/ecpprog$EXE 41 | 42 | strip_binaries bin/ecpprog$EXE 43 | 44 | if [ ${ARCH:0:7} = "windows" ]; then 45 | cp $PACKAGE_DIR/$NAME/bin/ecpprog$EXE $PACKAGE_DIR/${NAME}-progtools/bin/ecpprog$EXE 46 | fi 47 | 48 | clean_build $dir_name 49 | -------------------------------------------------------------------------------- /scripts/compile_ghdl.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=ghdl 6 | commit=master 7 | git_url=https://github.com/ghdl/ghdl.git 8 | 9 | git_clone $dir_name $git_url $commit 10 | 11 | cd $BUILD_DIR/$dir_name 12 | 13 | # remove unwanted -lz linker flag on Darwin (because it causes a dynamic link) 14 | $SED -i 's/^[ \t]*pragma Linker_Options ("-lz");//;' ./src/grt/grt-zlib.ads 15 | # customise the version string for ghdl 16 | patch -p1 < $WORK_DIR/patches/ghdl/ghdl_version.patch 17 | patch -p1 < $WORK_DIR/patches/ghdl/ghdl_largs.patch 18 | 19 | export GHDL_DESC="$(git -C $UPSTREAM_DIR/$dir_name describe --dirty 2> /dev/null)" 20 | sed -i -e "s/@BUILDER@/open-tool-forge.$VERSION/" src/version.in 21 | 22 | # -- Compile it 23 | if [ $ARCH == "darwin" ]; then 24 | OLD_PATH=$PATH 25 | export PATH="$GNAT_ROOT/bin:$PATH" 26 | 27 | ./configure --prefix=$PACKAGE_DIR/$NAME 28 | 29 | $MAKE -j$J GNAT_LARGS="-static-libgcc $ZLIB_ROOT/lib/libz.a" 30 | $MAKE install 31 | 32 | export PATH="$OLD_PATH" 33 | else 34 | ./configure --prefix=$PACKAGE_DIR/$NAME 35 | $MAKE -j$J GNAT_BARGS="-bargs -E -static" GNAT_LARGS="-static -lz" 36 | $MAKE install 37 | fi 38 | 39 | test_bin $PACKAGE_DIR/$NAME/bin/ghdl$exe 40 | 41 | strip_binaries bin/ghdl$EXE 42 | 43 | clean_build $dir_name 44 | -------------------------------------------------------------------------------- /scripts/compile_icestorm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Compile Icestorm script 3 | 4 | set -e 5 | 6 | dir_name=icestorm 7 | commit=master 8 | git_url=https://github.com/YosysHQ/icestorm 9 | 10 | git_clone $dir_name $git_url $commit 11 | 12 | cd $BUILD_DIR/$dir_name 13 | 14 | # -- Compile it 15 | if [ $ARCH == "darwin" ]; then 16 | sed -i "" "s/-ggdb //;" config.mk 17 | # pkg-config is used to set LDLIBS in this Makefile and doesn't quite do what we want 18 | sed -i "" "s/\$^ \$(LDLIBS)/\$^ \$(LDSTATICLIBS)/g" iceprog/Makefile 19 | make -j$J CC="$CC" \ 20 | SUBDIRS="iceprog" \ 21 | PKG_CONFIG=":" \ 22 | LDSTATICLIBS="-pthread $LIBFTDI_ROOT/lib/libftdi1.a $LIBUSB_ROOT/lib/libusb-1.0.a -Wl,-framework,IOKit -Wl,-framework,CoreFoundation" \ 23 | CFLAGS="-MD -O0 -Wall -std=c99 -I$LIBFTDI_ROOT/include/libftdi1 $CFLAGS" 24 | make -j$J CXX="$CXX" \ 25 | CXXFLAGS="-std=c++11 $CXXFLAGS" \ 26 | SUBDIRS="icebox icepack icemulti icepll icetime icebram" 27 | elif [ ${ARCH:0:7} = "windows" ] 28 | then 29 | sed -i "s/-ggdb //;" Makefile 30 | $MAKE -j$J CC="$CC" STATIC=1 31 | else 32 | sed -i "s/-ggdb //;" config.mk 33 | sed -i "s/\$^ \$(LDLIBS)/\$^ \$(LDLIBS) \$(LDUSBSTATIC)/g" iceprog/Makefile 34 | make -j$J CC="$CC" \ 35 | SUBDIRS="iceprog" \ 36 | LDFLAGS="-static -pthread -L$WORK_DIR/build-data/lib/$ARCH " \ 37 | LDUSBSTATIC="-lusb-1.0"\ 38 | CFLAGS="-MD -O0 -Wall -std=c99 -I$WORK_DIR/build-data/include/libftdi1 -I$WORK_DIR/build-data/include/libusb-1.0" 39 | make -j$J CXX="$CXX" STATIC=1 \ 40 | SUBDIRS="icebox icepack icemulti icepll icetime icebram" 41 | fi 42 | 43 | TOOLS="iceprog icepack icemulti icepll icetime icebram" 44 | 45 | # -- Test the generated executables 46 | for dir in $TOOLS; do 47 | test_bin $dir/$dir$EXE 48 | done 49 | 50 | # -- Copy the executables to the bin dir 51 | for dir in $TOOLS; do 52 | cp $dir/$dir$EXE $PACKAGE_DIR/$NAME/bin/$dir$EXE 53 | done 54 | 55 | # -- Copy the chipdb*.txt data files 56 | mkdir -p $PACKAGE_DIR/$NAME/share/icebox 57 | cp -r icebox/chipdb*.txt $PACKAGE_DIR/$NAME/share/icebox 58 | cp -r icefuzz/timings*.txt $PACKAGE_DIR/$NAME/share/icebox 59 | 60 | strip_binaries bin/{iceprog,icepack,icemulti,icepll,icetime,icebram}$EXE 61 | 62 | if [ ${ARCH:0:7} = "windows" ]; then 63 | cp $PACKAGE_DIR/$NAME/bin/iceprog$EXE $PACKAGE_DIR/${NAME}-progtools/bin/iceprog$EXE 64 | fi 65 | 66 | clean_build $dir_name 67 | -------------------------------------------------------------------------------- /scripts/compile_iverilog.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=iverilog 6 | commit=master 7 | git_url=https://github.com/steveicarus/iverilog.git 8 | 9 | git_clone $dir_name $git_url $commit 10 | 11 | cd $BUILD_DIR/$dir_name 12 | 13 | bash ./autoconf.sh 14 | # -- Compile it 15 | if [ $ARCH == "darwin" ]; then 16 | OLDPATH=$PATH 17 | export PATH="/usr/local/opt/bison/bin:/usr/local/opt/flex/bin:$PATH" 18 | 19 | ./configure --prefix=$PACKAGE_DIR/$NAME \ 20 | --exec-prefix=$PACKAGE_DIR/$NAME \ 21 | 22 | $MAKE LIBS="-lm /usr/local/opt/zlib/lib/libz.a \ 23 | /usr/local/opt/bzip2/lib/libbz2.a \ 24 | /usr/local/opt/ncurses/lib/libncurses.a \ 25 | /usr/local/opt/libedit/lib/libedit.a" 26 | 27 | export PATH=$OLDPATH 28 | elif [ ${ARCH:0:7} = "windows" ] 29 | then 30 | ./configure --prefix=$PACKAGE_DIR/$NAME \ 31 | --exec-prefix=$PACKAGE_DIR/$NAME \ 32 | LDFLAGS="-static -lstdc++ -lm" \ 33 | 34 | $MAKE 35 | else 36 | ./configure --prefix=$PACKAGE_DIR/$NAME \ 37 | --exec-prefix=$PACKAGE_DIR/$NAME \ 38 | 39 | $MAKE SUBDIRS="ivlpp vhdlpp vvp driver" LDFLAGS="-static-libgcc -static -lstdc++ -lm -lc" 40 | fi 41 | 42 | $MAKE install 43 | 44 | TOOLS="bin/iverilog$EXE bin/vvp$EXE lib/ivl/ivl$EXE lib/ivl/ivlpp$EXE lib/ivl/vhdlpp$EXE" 45 | 46 | # -- Test the generated executables 47 | for tool in $TOOLS; do 48 | test_bin $PACKAGE_DIR/$NAME/$tool 49 | done 50 | 51 | strip_binaries $TOOLS 52 | 53 | clean_build $dir_name 54 | -------------------------------------------------------------------------------- /scripts/compile_nextpnr_ecp5.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Compile nextpnr-ecp5 script 3 | 4 | set -e -x 5 | 6 | nextpnr_dir=nextpnr-ecp5 7 | nextpnr_uri=https://github.com/YosysHQ/nextpnr.git 8 | nextpnr_commit=master 9 | nextpnr_commit=$(git ls-remote ${nextpnr_uri} ${nextpnr_commit} | cut -f 1) 10 | 11 | prjtrellis_dir=prjtrellis 12 | prjtrellis_uri=https://github.com/YosysHQ/prjtrellis.git 13 | # Every time you update this, regenerate the chipdb files! 14 | prjtrellis_commit=master 15 | prjtrellis_commit=$(git ls-remote ${prjtrellis_uri} ${prjtrellis_commit} | cut -f 1) 16 | 17 | git_clone $nextpnr_dir $nextpnr_uri $nextpnr_commit 1 # enable submodule update 18 | git_clone $prjtrellis_dir $prjtrellis_uri $prjtrellis_commit 1 # enable submodule update 19 | 20 | # NOTE: We build libtrellis with python DISABLED. 21 | # We do this to speed up build time and to enable static builds. 22 | # We have a precompiled chipdb in this repository, so there is no 23 | # need to have Python functioning. 24 | # Additionally, libtrellis doesn't build correctly when making 25 | # static binaries and having Python enabled. 26 | 27 | cd $BUILD_DIR/ 28 | 29 | if [ -e $nextpnr_dir/CMakeCache.txt -o -e $prjtrellis_dir/CMakeCache.txt ] 30 | then 31 | echo "CMakeCache.txt exists!" 32 | fi 33 | rm -f $nextpnr_dir/CMakeCache.txt $prjtrellis_dir/CMakeCache.txt 34 | 35 | cd $BUILD_DIR 36 | mkdir -p chipdb 37 | cd chipdb 38 | tar -xvf $PACKAGES_DIR/build_linux_x86_64/ecp5-bba-noarch-nightly.tar.gz 39 | 40 | # -- Compile it 41 | if [ $ARCH = "darwin" ] 42 | then 43 | cd $BUILD_DIR/$prjtrellis_dir/libtrellis 44 | cmake \ 45 | -DBUILD_SHARED=OFF \ 46 | -DSTATIC_BUILD=ON \ 47 | -DBUILD_PYTHON=OFF \ 48 | -DCMAKE_INSTALL_PREFIX=$PACKAGE_DIR/$NAME \ 49 | -DCURRENT_GIT_VERSION=$prjtrellis_commit \ 50 | -DBoost_USE_STATIC_LIBS=ON \ 51 | . 52 | make -j$J CXX="$CXX" LIBS="-lm -fno-lto -ldl -lutil" 53 | make install 54 | 55 | cd $BUILD_DIR/$nextpnr_dir 56 | cmake -DARCH=ecp5 \ 57 | -DTRELLIS_ROOT=$BUILD_DIR/$prjtrellis_dir \ 58 | -DPYTRELLIS_LIBDIR=$BUILD_DIR/$prjtrellis_dir/libtrellis \ 59 | -DECP5_CHIPDB=$BUILD_DIR/chipdb/ecp5-bba/bba \ 60 | -DBoost_USE_STATIC_LIBS=ON \ 61 | -DPYTHON_EXECUTABLE=$CONDA_ROOT/bin/python \ 62 | -DPYTHON_LIBRARY=$CONDA_ROOT/lib/libpython$EMBEDDED_PY_VER.a \ 63 | -DBUILD_GUI=OFF \ 64 | -DBUILD_PYTHON=ON \ 65 | -DBUILD_HEAP=ON \ 66 | -DCMAKE_EXE_LINKER_FLAGS='-fno-lto -ldl -lutil' \ 67 | -DSTATIC_BUILD=ON \ 68 | . 69 | make -j$J CXX="$CXX" LIBS="-lm -fno-lto -ldl -lutil" VERBOSE=1 70 | cd .. 71 | elif [ ${ARCH:0:7} = "windows" ] 72 | then 73 | cd $BUILD_DIR/$prjtrellis_dir/libtrellis 74 | cmake \ 75 | -G "MinGW Makefiles" \ 76 | -DBUILD_SHARED=OFF \ 77 | -DSTATIC_BUILD=ON \ 78 | -DBUILD_PYTHON=OFF \ 79 | -DCMAKE_INSTALL_PREFIX=$PACKAGE_DIR/$NAME \ 80 | -DCURRENT_GIT_VERSION=$prjtrellis_commit \ 81 | -DBoost_USE_STATIC_LIBS=ON \ 82 | . 83 | mingw32-make -j$J CXX="$CXX" LIBS="-lm" 84 | mingw32-make install 85 | 86 | cd $BUILD_DIR/$nextpnr_dir 87 | 88 | cmake \ 89 | -G "MinGW Makefiles" \ 90 | -DARCH=ecp5 \ 91 | -DTRELLIS_ROOT=$BUILD_DIR/$prjtrellis_dir \ 92 | -DPYTRELLIS_LIBDIR=$BUILD_DIR/$prjtrellis_dir/libtrellis \ 93 | -DECP5_CHIPDB=$BUILD_DIR/chipdb/ecp5-bba/bba \ 94 | -DBoost_USE_STATIC_LIBS=ON \ 95 | -DBUILD_GUI=OFF \ 96 | -DBUILD_PYTHON=ON \ 97 | -DBUILD_HEAP=ON \ 98 | -DSTATIC_BUILD=ON \ 99 | . 100 | 101 | mingw32-make -j$J CXX="$CXX" LIBS="-static -lstdc++ -lm" VERBOSE=1 102 | cd .. 103 | else 104 | cd $BUILD_DIR/$prjtrellis_dir/libtrellis 105 | 106 | # The second run builds the static libraries we'll use in the final release 107 | cmake \ 108 | -DBUILD_SHARED=OFF \ 109 | -DSTATIC_BUILD=ON \ 110 | -DBUILD_PYTHON=OFF \ 111 | -DBoost_USE_STATIC_LIBS=ON \ 112 | -DCMAKE_INSTALL_PREFIX=$PACKAGE_DIR/$NAME \ 113 | -DCURRENT_GIT_VERSION=$prjtrellis_commit \ 114 | -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \ 115 | . 116 | make -j$J CXX="$CXX" 117 | make install 118 | 119 | cd $BUILD_DIR/$nextpnr_dir 120 | cmake \ 121 | -DARCH=ecp5 \ 122 | -DTRELLIS_ROOT=$BUILD_DIR/$prjtrellis_dir \ 123 | -DPYTRELLIS_LIBDIR=$BUILD_DIR/$prjtrellis_dir/libtrellis \ 124 | -DECP5_CHIPDB=$BUILD_DIR/chipdb/ecp5-bba/bba \ 125 | -DBUILD_HEAP=ON \ 126 | -DBUILD_GUI=OFF \ 127 | -DBUILD_PYTHON=ON \ 128 | -DSTATIC_BUILD=ON \ 129 | -DBoost_USE_STATIC_LIBS=ON \ 130 | . 131 | make -j$J CXX="$CXX" LIBS="-static -lstdc++ -lm" 132 | fi || exit 1 133 | 134 | # -- Copy the executables to the bin dir 135 | mkdir -p $PACKAGE_DIR/$NAME/bin 136 | # test_bin $BUILD_DIR/$nextpnr_dir/nextpnr-ecp5$EXE 137 | cp $BUILD_DIR/$nextpnr_dir/nextpnr-ecp5$EXE $PACKAGE_DIR/$NAME/bin/nextpnr-ecp5$EXE 138 | for i in ecpmulti ecppack ecppll ecpunpack ecpbram 139 | do 140 | test_bin $BUILD_DIR/$prjtrellis_dir/libtrellis/$i$EXE 141 | cp $BUILD_DIR/$prjtrellis_dir/libtrellis/$i$EXE $PACKAGE_DIR/$NAME/bin/$i$EXE 142 | done 143 | 144 | # Do a test run of the new binary 145 | $PACKAGE_DIR/$NAME/bin/nextpnr-ecp5$EXE --help 146 | echo 'print("hello from python!")' > hello.py 147 | $PACKAGE_DIR/$NAME/bin/nextpnr-ecp5$EXE --run hello.py 148 | 149 | strip_binaries bin/{ecpmulti,ecppack,ecppll,ecpunpack,ecpbram,nextpnr-ecp5}$EXE 150 | 151 | clean_build $nextpnr_dir 152 | clean_build $prjtrellis_dir 153 | -------------------------------------------------------------------------------- /scripts/compile_nextpnr_ecp5_bba.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Compile nextpnr-ecp5 script 3 | 4 | set -e -x 5 | 6 | nextpnr_dir=nextpnr-ecp5-bba 7 | nextpnr_uri=https://github.com/YosysHQ/nextpnr.git 8 | nextpnr_commit=master 9 | nextpnr_commit=$(git ls-remote ${nextpnr_uri} ${nextpnr_commit} | cut -f 1) 10 | 11 | prjtrellis_dir=prjtrellis-bba 12 | prjtrellis_uri=https://github.com/YosysHQ/prjtrellis.git 13 | # Every time you update this, regenerate the chipdb files! 14 | prjtrellis_commit=master 15 | prjtrellis_commit=$(git ls-remote ${prjtrellis_uri} ${prjtrellis_commit} | cut -f 1) 16 | 17 | git_clone $nextpnr_dir $nextpnr_uri $nextpnr_commit 1 # enable submodule update 18 | git_clone $prjtrellis_dir $prjtrellis_uri $prjtrellis_commit 1 # enable submodule update 19 | 20 | cd $BUILD_DIR/ 21 | 22 | if [ -e $nextpnr_dir/CMakeCache.txt -o -e $prjtrellis_dir/CMakeCache.txt ] 23 | then 24 | echo "CMakeCache.txt exists!" 25 | fi 26 | rm -f $nextpnr_dir/CMakeCache.txt $prjtrellis_dir/CMakeCache.txt 27 | 28 | # -- Compile it 29 | cd $BUILD_DIR/$prjtrellis_dir/libtrellis 30 | 31 | # build libtrellis with the python module enabled 32 | mkdir -p $BUILD_DIR/$prjtrellis_dir/tmp_prjtrellis_install 33 | cmake \ 34 | -DBUILD_SHARED=ON \ 35 | -DCMAKE_INSTALL_PREFIX=$BUILD_DIR/$prjtrellis_dir/tmp_prjtrellis_install \ 36 | -DSTATIC_BUILD=OFF \ 37 | -DBoost_USE_STATIC_LIBS=OFF \ 38 | -DBUILD_PYTHON=ON \ 39 | -DCURRENT_GIT_VERSION=$prjtrellis_commit \ 40 | . 41 | make -j$J CXX="$CXX" 42 | make install 43 | rm -rf CMakeCache.txt 44 | 45 | # use libtrellis + the python module to generate BBA files 46 | cd $BUILD_DIR/$nextpnr_dir 47 | cmake \ 48 | -DARCH=ecp5 \ 49 | -DTRELLIS_INSTALL_PREFIX=$BUILD_DIR/$prjtrellis_dir/tmp_prjtrellis_install \ 50 | -DBUILD_HEAP=ON \ 51 | -DBUILD_GUI=OFF \ 52 | -DBUILD_PYTHON=ON \ 53 | -DSTATIC_BUILD=OFF \ 54 | -DBoost_USE_STATIC_LIBS=OFF \ 55 | . 56 | 57 | # skip most of the nextpnr build and generate the *.bba chipdb files 58 | make -j$J CXX="$CXX" chipdb-ecp5-bbas 59 | 60 | mkdir -p $PACKAGE_DIR/$NAME/bba 61 | cp $BUILD_DIR/$nextpnr_dir/ecp5/chipdb/*.bba $PACKAGE_DIR/$NAME/bba 62 | 63 | clean_build $nextpnr_dir 64 | clean_build $prjtrellis_dir 65 | -------------------------------------------------------------------------------- /scripts/compile_nextpnr_ice40.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Compile nextpnr-ice40 script 3 | 4 | set -e 5 | 6 | dir_name=nextpnr-ice40 7 | commit=master 8 | git_url=https://github.com/YosysHQ/nextpnr.git 9 | 10 | git_clone $dir_name $git_url $commit 1 # enable submodule update 11 | 12 | cd $BUILD_DIR/$dir_name 13 | 14 | if [ -e CMakeCache.txt ] 15 | then 16 | echo "CMakeCache.txt exists!" 17 | fi 18 | rm -f CMakeCache.txt 19 | 20 | # -- Compile it 21 | if [ $ARCH == "darwin" ]; then 22 | cmake -DARCH=ice40 \ 23 | -DBoost_USE_STATIC_LIBS=ON \ 24 | -DPYTHON_EXECUTABLE=$CONDA_ROOT/bin/python \ 25 | -DPYTHON_LIBRARY=$CONDA_ROOT/lib/libpython$EMBEDDED_PY_VER.a \ 26 | -DBUILD_GUI=OFF \ 27 | -DBUILD_HEAP=ON \ 28 | -DCMAKE_EXE_LINKER_FLAGS='-fno-lto -ldl -lutil' \ 29 | -DICEBOX_ROOT=$PACKAGE_DIR/$NAME/share/icebox \ 30 | -DSTATIC_BUILD=ON \ 31 | . 32 | make -j$J CXX="$CXX" LIBS="-lm -fno-lto -ldl -lutil" 33 | elif [ ${ARCH:0:7} == "windows" ]; then 34 | cmake \ 35 | -G "MinGW Makefiles" \ 36 | -DARCH=ice40 \ 37 | -DBUILD_HEAP=ON \ 38 | -DBUILD_GUI=OFF \ 39 | -DBUILD_PYTHON=ON \ 40 | -DSTATIC_BUILD=ON \ 41 | -DICEBOX_ROOT=$PACKAGE_DIR/$NAME/share/icebox \ 42 | -DBoost_USE_STATIC_LIBS=ON \ 43 | . 44 | 45 | $MAKE -j$J CXX="$CXX" VERBOSE=1 46 | else 47 | cmake \ 48 | -DARCH=ice40 \ 49 | -DBUILD_HEAP=ON \ 50 | -DBUILD_GUI=OFF \ 51 | -DSTATIC_BUILD=ON \ 52 | -DICEBOX_ROOT=$PACKAGE_DIR/$NAME/share/icebox \ 53 | -DBoost_USE_STATIC_LIBS=ON \ 54 | . 55 | make -j$J CXX="$CXX" 56 | fi || exit 1 57 | 58 | # -- Copy the executable to the bin dir 59 | mkdir -p $PACKAGE_DIR/$NAME/bin 60 | cp nextpnr-ice40$EXE $PACKAGE_DIR/$NAME/bin/nextpnr-ice40$EXE 61 | 62 | # Do a test run of the new binary 63 | $PACKAGE_DIR/$NAME/bin/nextpnr-ice40$EXE --up5k --package sg48 --pcf $WORK_DIR/build-data/test/top.pcf --json $WORK_DIR/build-data/test/top.json --asc /tmp/nextpnr/top.txt --pre-pack $WORK_DIR/build-data/test/top_pre_pack.py --seed 0 --placer heap 64 | 65 | strip_binaries bin/nextpnr-ice40$EXE 66 | 67 | clean_build $dir_name 68 | -------------------------------------------------------------------------------- /scripts/compile_openfpgaloader.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=openfpgaloader 6 | commit=master 7 | git_url=https://github.com/trabucayre/openFPGALoader.git 8 | 9 | git_clone $dir_name $git_url $commit 10 | 11 | mkdir -p $BUILD_DIR/$dir_name/build 12 | cd $BUILD_DIR/$dir_name/build 13 | 14 | 15 | # -- Compile it 16 | if [ $ARCH == "darwin" ]; then 17 | cmake -DENABLE_UDEV=OFF ../ 18 | $MAKE -j$J 19 | elif [ ${ARCH:0:7} = "windows" ] 20 | then 21 | cmake -G "MinGW Makefiles" -DENABLE_UDEV=OFF -DBUILD_STATIC=ON ../ 22 | $MAKE -j$J 23 | else 24 | cmake -DLINK_CMAKE_THREADS=ON -DUSE_PKGCONFIG=OFF -DENABLE_UDEV=OFF -DBUILD_STATIC=ON \ 25 | -DLIBUSB_LIBRARIES=$WORK_DIR/build-data/lib/$ARCH/libusb-1.0.a \ 26 | -DLIBFTDI_LIBRARIES=$WORK_DIR/build-data/lib/$ARCH/libftdi1.a \ 27 | -DLIBFTDI_VERSION=1.4 \ 28 | -DCMAKE_CXX_FLAGS="-I$WORK_DIR/build-data/include/libusb-1.0 -I$WORK_DIR/build-data/include/libftdi1" \ 29 | ../ 30 | $MAKE -j$J 31 | fi 32 | 33 | test_bin openFPGALoader$EXE 34 | cp openFPGALoader$EXE $PACKAGE_DIR/$NAME/bin/openFPGALoader$EXE 35 | 36 | strip_binaries bin/openFPGALoader$EXE 37 | 38 | if [ ${ARCH:0:7} = "windows" ]; then 39 | cp $PACKAGE_DIR/$NAME/bin/openFPGALoader$EXE $PACKAGE_DIR/${NAME}-progtools/bin/openFPGALoader$EXE 40 | fi 41 | 42 | clean_build $dir_name 43 | -------------------------------------------------------------------------------- /scripts/compile_sby.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=symbiyosys 6 | commit=master 7 | git_url=https://github.com/YosysHQ/SymbiYosys.git 8 | 9 | git_clone $dir_name $git_url $commit 10 | 11 | cd $BUILD_DIR/$dir_name 12 | 13 | # -- Compile it 14 | if [ ${ARCH:0:7} = "windows" ] 15 | then 16 | # use make rather than mingw32-make here because the sed tool expects unix paths 17 | # PYTHON overrides the shebang telling the sby.exe launcher where to find python 18 | make install PREFIX=$PACKAGE_DIR/$NAME PYTHON="./bin/python3-private.exe" 19 | test_bin $PACKAGE_DIR/$NAME/bin/sby.exe 20 | elif [ $ARCH == "darwin" ]; then 21 | # put GNU sed in path temporarily 22 | OLDPATH=$PATH 23 | export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH" 24 | $MAKE install PREFIX=$PACKAGE_DIR/$NAME 25 | export PATH=$OLDPATH 26 | else 27 | $MAKE install PREFIX=$PACKAGE_DIR/$NAME 28 | fi 29 | 30 | clean_build $dir_name 31 | -------------------------------------------------------------------------------- /scripts/compile_yices2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=yices2 6 | commit=master 7 | git_url=https://github.com/SRI-CSL/yices2.git 8 | 9 | # gperf files don't work with CRLF line endings on windows 10 | # TODO: handle this better so I don't mess with people's dev envs 11 | git config --global core.autocrlf false 12 | git_clone $dir_name $git_url $commit 13 | cd $BUILD_DIR/$dir_name 14 | autoconf 15 | 16 | if [ $ARCH == "darwin" ] 17 | then 18 | ./configure 19 | $MAKE -j$J static-bin 20 | YICES2_BINDIR=./build/x86_64-apple-darwin*-release/static_bin 21 | elif [ ${ARCH:0:7} = "windows" ] 22 | then 23 | ./configure --host=x86_64-pc-mingw64 24 | # this is a hack to make the Makefile behave like we are on cygwin 25 | # (they have not implemented MSYS2 support but it seems to work anyway) 26 | echo 'echo "cygwin"' > autoconf/os 27 | MAKE=/usr/bin/make OPTION=mingw64 /usr/bin/make -j$J static-bin 28 | YICES2_BINDIR=./build/x86_64-pc-mingw64-release/static_bin 29 | else 30 | ./configure 31 | $MAKE -j$J static-bin 32 | YICES2_BINDIR=./build/x86_64-pc-linux-gnu-release/static_bin 33 | fi 34 | 35 | cp $YICES2_BINDIR/yices$EXE $PACKAGE_DIR/$NAME/bin/yices$EXE 36 | cp $YICES2_BINDIR/yices_sat$EXE $PACKAGE_DIR/$NAME/bin/yices-sat$EXE 37 | cp $YICES2_BINDIR/yices_smt$EXE $PACKAGE_DIR/$NAME/bin/yices-smt$EXE 38 | cp $YICES2_BINDIR/yices_smt2$EXE $PACKAGE_DIR/$NAME/bin/yices-smt2$EXE 39 | 40 | TOOLS="yices yices-sat yices-smt yices-smt2" 41 | 42 | for tool in $TOOLS; do 43 | test_bin $PACKAGE_DIR/$NAME/bin/$tool$EXE 44 | strip_binaries bin/$tool$EXE 45 | done 46 | 47 | clean_build $dir_name 48 | -------------------------------------------------------------------------------- /scripts/compile_yosys.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Compile Yosys script 3 | 4 | set -e -x 5 | 6 | dir_name=yosys 7 | commit=master 8 | # commit=5eff0b73ae82ee490be3e732241eb22cb4bff952 9 | git_url=https://github.com/YosysHQ/yosys.git 10 | 11 | dir_name_gyp=ghdl_yosys_plugin 12 | commit_gyp=master 13 | git_url_gyp=https://github.com/ghdl/ghdl-yosys-plugin 14 | 15 | git_clone $dir_name $git_url $commit 16 | GIT_REV=$(git -C $UPSTREAM_DIR/$dir_name rev-parse --short HEAD 2> /dev/null || echo UNKNOWN) 17 | 18 | if [ $COMPILE_GHDL == "1" ] 19 | then 20 | git_clone $dir_name_gyp $git_url_gyp $commit_gyp 21 | fi 22 | 23 | cd $BUILD_DIR/$dir_name 24 | 25 | MAKEFILE_CONF_GHDL= 26 | GHDL_LDLIBS= 27 | if [ $COMPILE_GHDL == "1" ] 28 | then 29 | patch < $WORK_DIR/patches/yosys/yosys_ghdl.patch 30 | 31 | mkdir -p frontends/ghdl 32 | cp -R ../$dir_name_gyp/src/* frontends/ghdl 33 | MAKEFILE_CONF_GHDL=$'ENABLE_GHDL := 1\n' 34 | MAKEFILE_CONF_GHDL+="GHDL_PREFIX := $PACKAGE_DIR/$NAME" 35 | 36 | if [ $ARCH == "darwin" ]; then 37 | GHDL_LDLIBS="$PACKAGE_DIR/$NAME/lib/libghdl.a $(tr -s '\n' ' ' < $PACKAGE_DIR/$NAME/lib/libghdl.link)" 38 | elif [ ${ARCH:0:7} == "windows" ]; then 39 | GHDL_LDLIBS="$(cygpath -m -a $PACKAGE_DIR/$NAME/lib/libghdl.a) $(cat $PACKAGE_DIR/$NAME/lib/libghdl.link | tr -s '\n' ' ' | tr -s '\\' '/' )" 40 | else 41 | GHDL_LDLIBS="$PACKAGE_DIR/$NAME/lib/libghdl.a $(tr -s '\n' ' ' < $PACKAGE_DIR/$NAME/lib/libghdl.link)" 42 | fi 43 | fi 44 | 45 | # -- Compile it 46 | if [ $ARCH == "darwin" ]; then 47 | OLDPATH=$PATH 48 | export PATH="/usr/local/opt/bison/bin:/usr/local/opt/flex/bin:$PATH" 49 | $MAKE config-clang 50 | echo "$MAKEFILE_CONF_GHDL" >> Makefile.conf 51 | gsed -r -i 's/^(YOSYS_VER := [0-9]+\.[0-9]+\+[0-9]+).*$/\1 \(open-tool-forge build\)/;' Makefile 52 | sed -i "" "s/-Wall -Wextra -ggdb/-w/;" Makefile 53 | CXXFLAGS="-std=c++11 $CXXFLAGS" make \ 54 | -j$J GIT_REV="${GIT_REV}" PRETTY=0 \ 55 | LDLIBS="-lm $GHDL_LDLIBS" \ 56 | ENABLE_TCL=0 ENABLE_PLUGINS=0 ENABLE_READLINE=0 ENABLE_COVER=0 ENABLE_ZLIB=0 ENABLE_ABC=1 \ 57 | ABCMKARGS="CC=\"$CC\" CXX=\"$CXX\" OPTFLAGS=\"-O\" \ 58 | ARCHFLAGS=\"$ABC_ARCHFLAGS\" ABC_USE_NO_READLINE=1" 59 | 60 | export PATH=$OLDPATH 61 | elif [ ${ARCH:0:7} == "windows" ]; then 62 | $MAKE config-msys2-64 63 | echo "$MAKEFILE_CONF_GHDL" >> Makefile.conf 64 | sed -r -i 's/^(YOSYS_VER := [0-9]+\.[0-9]+\+[0-9]+).*$/\1 \(open-tool-forge build\)/;' Makefile 65 | $MAKE -j$J GIT_REV="${GIT_REV}" PRETTY=0 \ 66 | LDLIBS="-static -lstdc++ -lm $GHDL_LDLIBS" \ 67 | ABCMKARGS="CC=\"$CC\" CXX=\"$CXX\" LIBS=\"-static -lm\" OPTFLAGS=\"-O\" \ 68 | ARCHFLAGS=\"$ABC_ARCHFLAGS\" \ 69 | ABC_USE_NO_READLINE=1 \ 70 | ABC_USE_NO_PTHREADS=1 \ 71 | ABC_USE_LIBSTDCXX=1 \ 72 | OPTFLAGS=\"-ggdb -O0\" \ 73 | ABC_MAKE_VERBOSE=1" \ 74 | ENABLE_TCL=0 ENABLE_PLUGINS=0 ENABLE_READLINE=0 ENABLE_COVER=0 ENABLE_ZLIB=0 ENABLE_ABC=1 \ 75 | PYTHON="./bin/python3-private.exe" # override the shebang telling the exe launcher where to find python 76 | 77 | test_bin yosys-smtbmc$EXE 78 | else 79 | $MAKE config-gcc 80 | echo "$MAKEFILE_CONF_GHDL" >> Makefile.conf 81 | sed -i "s/-Wall -Wextra -ggdb/-w/;" Makefile 82 | sed -r -i 's/^(YOSYS_VER := [0-9]+\.[0-9]+\+[0-9]+).*$/\1 \(open-tool-forge build\)/;' Makefile 83 | # sed -i "s/LD = gcc$/LD = $CC/;" Makefile 84 | # sed -i "s/CXX = gcc$/CXX = $CC/;" Makefile 85 | # sed -i "s/LDFLAGS += -rdynamic/LDFLAGS +=/;" Makefile 86 | $MAKE -j$J GIT_REV="${GIT_REV}" PRETTY=0 \ 87 | LDLIBS="-static -lstdc++ -lm $GHDL_LDLIBS -ldl" \ 88 | ENABLE_TCL=0 ENABLE_PLUGINS=0 ENABLE_READLINE=0 ENABLE_COVER=0 ENABLE_ZLIB=0 ENABLE_ABC=1 \ 89 | ABCMKARGS="CC=\"$CC\" CXX=\"$CXX\" LIBS=\"-static -lm -ldl -pthread\" \ 90 | OPTFLAGS=\"-O\" \ 91 | ARCHFLAGS=\"$ABC_ARCHFLAGS -Wno-unused-but-set-variable\" \ 92 | ABC_USE_NO_READLINE=1" 93 | fi 94 | 95 | # -- Test the generated executables 96 | test_bin yosys$EXE 97 | test_bin yosys-abc$EXE 98 | test_bin yosys-filterlib$EXE 99 | 100 | # -- Copy the executable files 101 | cp yosys$EXE $PACKAGE_DIR/$NAME/bin/yosys$EXE 102 | cp yosys-abc$EXE $PACKAGE_DIR/$NAME/bin/yosys-abc$EXE 103 | 104 | # this is a custom version of yosys-config (https://github.com/open-tool-forge/fpga-toolchain/issues/26) 105 | cp $WORK_DIR/build-data/yosys-config $PACKAGE_DIR/$NAME/bin/yosys-config 106 | 107 | cp yosys-filterlib$EXE $PACKAGE_DIR/$NAME/bin/yosys-filterlib$EXE 108 | cp yosys-smtbmc$EXE $PACKAGE_DIR/$NAME/bin/yosys-smtbmc$EXE 109 | [[ ! -z "$EXE" ]] && cp yosys-smtbmc-script.py $PACKAGE_DIR/$NAME/bin/yosys-smtbmc-script.py 110 | 111 | # -- Copy the share folder to the package folder 112 | mkdir -p $PACKAGE_DIR/$NAME/share/yosys 113 | cp -r share/* $PACKAGE_DIR/$NAME/share/yosys 114 | 115 | strip_binaries bin/{yosys,yosys-abc,yosys-filterlib}$EXE 116 | 117 | clean_build $dir_name 118 | clean_build $dir_name_gyp 119 | -------------------------------------------------------------------------------- /scripts/compile_z3.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=z3 6 | commit=z3-4.8.8 7 | git_url=https://github.com/Z3Prover/z3.git 8 | 9 | git_clone $dir_name $git_url $commit 10 | 11 | cd $BUILD_DIR/$dir_name 12 | mkdir -p build 13 | cd build 14 | 15 | if [ $ARCH = "darwin" ] 16 | then 17 | cmake ../ 18 | $MAKE -j$J 19 | elif [ ${ARCH:0:7} = "windows" ] 20 | then 21 | LDFLAGS="-static" cmake -G "MinGW Makefiles" -DBUILD_LIBZ3_SHARED=OFF ../ 22 | $MAKE -j$J 23 | else 24 | # edbordin: the extra CXXFLAGS are required to correctly statically link pthreads without 25 | # the program segfaulting on startup (something to do with weak symbols, I won't pretend 26 | # to fully understand) 27 | CXXFLAGS="-Wl,--whole-archive -lpthread -lrt -Wl,--no-whole-archive" LDFLAGS="-static -pthread -lrt" cmake -DZ3_BUILD_LIBZ3_SHARED=OFF ../ 28 | $MAKE -j$J 29 | fi 30 | 31 | test_bin z3$EXE 32 | cp z3$EXE $PACKAGE_DIR/$NAME/bin 33 | strip_binaries bin/z3$EXE 34 | 35 | clean_build $dir_name 36 | -------------------------------------------------------------------------------- /scripts/darwin_patch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | prog_name="$1" 6 | if [ -z $prog_name ] 7 | then 8 | echo "Usage $0 [target_name]" 9 | exit 1 10 | fi 11 | 12 | echo "Removing @rpath from $prog_name" 13 | base_pkg=$(echo ${prog_name} | cut -d/ -f5) 14 | install_name_tool -id $prog_name $prog_name || true 15 | otool -L "$prog_name" | while read i 16 | do 17 | if ! echo $i | grep -q "@rpath" 18 | then 19 | echo " Skipping library [$i]" 20 | continue 21 | fi 22 | base_lib=$(echo "$i" | awk '{print $1}') 23 | new_path=$(echo "$base_lib" | sed 's|@rpath|/tmp/nextpnr/lib|') 24 | echo " $prog_name: Removing rpath '$base_lib' -> '$new_path'" 25 | install_name_tool -change "$base_lib" "$new_path" "$prog_name" 26 | done 27 | otool -L "$prog_name" 28 | echo "" -------------------------------------------------------------------------------- /scripts/install_dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Install dependencies script 4 | 5 | set -e 6 | 7 | base_packages="build-essential bison flex libreadline-dev \ 8 | gawk tcl-dev libffi-dev git rsync wget curl \ 9 | pkg-config python3 cmake autotools-dev automake gperf gnat" 10 | 11 | cross_x64="libboost-dev libboost-filesystem-dev libboost-thread-dev \ 12 | libboost-program-options-dev libboost-python-dev libboost-iostreams-dev \ 13 | libboost-system-dev libboost-chrono-dev libboost-date-time-dev \ 14 | libboost-atomic-dev libboost-regex-dev libpython3-dev libeigen3-dev \ 15 | libgmp-dev" 16 | for b in $cross_x64; do 17 | cross_arm64="$cross_arm64 $b:arm64" 18 | cross_armhf="$cross_armhf $b:armhf" 19 | cross_i386="$cross_i386 $b:i386" 20 | done 21 | 22 | if [ $ARCH == "linux_x86_64" ]; then 23 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $base_packages $cross_x64 24 | gcc --version 25 | g++ --version 26 | fi 27 | 28 | if [ $ARCH == "linux_i686" ]; then 29 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $base_packages $cross_i386 \ 30 | gcc-multilib g++-multilib 31 | sudo ln -s /usr/include/asm-generic /usr/include/asm 32 | gcc --version 33 | g++ --version 34 | fi 35 | 36 | if [ $ARCH == "linux_armv7l" ]; then 37 | # TODO(edbordin): do we need gcc-7 specifically still? 38 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $base_packages $cross_armhf \ 39 | gcc-arm-linux-gnueabihf \ 40 | g++-arm-linux-gnueabihf \ 41 | binfmt-support \ 42 | gcc-7-arm-linux-gnueabihf \ 43 | g++-7-arm-linux-gnueabihf \ 44 | qemu-user-static 45 | arm-linux-gnueabihf-gcc --version 46 | arm-linux-gnueabihf-g++ --version 47 | fi 48 | 49 | if [ $ARCH == "linux_aarch64" ]; then 50 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $base_packages $cross_arm64 \ 51 | gcc-aarch64-linux-gnu \ 52 | g++-aarch64-linux-gnu \ 53 | binfmt-support qemu-user-static 54 | 55 | aarch64-linux-gnu-gcc --version 56 | aarch64-linux-gnu-g++ --version 57 | fi 58 | 59 | if [ $ARCH == "windows_x86" ]; then 60 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y $base_packages \ 61 | mingw-w64 mingw-w64-tools mingw-w64-i686-dev \ 62 | zip 63 | 64 | # this was used to cross-compile nextpnr-ecp5 for Windows but we can't build native python libs 65 | # for Windows with MinGW (CPython on Windows is built with MSVC) and the built python libs are run as part 66 | # of the build process 67 | # 68 | # sudo apt-get install -y build-essential bison flex libreadline-dev \ 69 | # gawk tcl-dev libffi-dev git mercurial graphviz \ 70 | # xdot pkg-config python3.5-dev qt5-default libqt5opengl5-dev $BOOST \ 71 | # gcc-5-mingw-w64 gc++-5-mingw-w64 wine libeigen3-dev qtbase5-dev libpython3.5-dev zip 72 | # #mingw-w64 mingw-w64-tools 73 | # sudo apt-get autoremove -y 74 | # ln -s /usr/include/x86_64-linux-gnu/zconf.h /usr/include 75 | # sudo update-alternatives \ 76 | # --install /usr/bin/i686-w64-mingw32-gcc i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-5 60 \ 77 | # --slave /usr/bin/i686-w64-mingw32-g++ i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-5 78 | 79 | i686-w64-mingw32-gcc --version 80 | i686-w64-mingw32-g++ --version 81 | fi 82 | 83 | if [ $ARCH == "windows_amd64" ]; then 84 | pacman --noconfirm --needed --refresh --sync -S git base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake \ 85 | mingw-w64-x86_64-boost mingw-w64-x86_64-eigen3 rsync unzip zip mingw-w64-x86_64-libftdi bison flex \ 86 | mingw-w64-x86_64-gcc-ada p7zip mingw-w64-x86_64-jsoncpp 87 | 88 | wget https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-binutils-2.36-1-any.pkg.tar.zst 89 | pacman --noconfirm -U mingw-w64-x86_64-binutils-2.36-1-any.pkg.tar.zst 90 | 91 | x86_64-w64-mingw32-gcc --version 92 | x86_64-w64-mingw32-g++ --version 93 | fi 94 | 95 | if [ $ARCH == "darwin" ]; then 96 | sudo xcode-select -s /Applications/Xcode_11.4.1.app/Contents/Developer 97 | # yosys detects some of these tools if a homebrew version is installed 98 | # so we may not need to add all of them to PATH 99 | brew install automake pkg-config bison flex gawk libffi git graphviz xdot bash cmake boost boost-python3 eigen \ 100 | libftdi libusb zlib libedit ncurses bzip2 gnu-sed 101 | 102 | wget_retry --progress=dot https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-MacOSX-x86_64.sh -O miniconda.sh 103 | bash miniconda.sh -b -p /tmp/conda 104 | source /tmp/conda/bin/activate base 105 | conda env update -n base -f $WORK_DIR/build-data/darwin/environment.yml 106 | conda deactivate 107 | 108 | GNAT_VERSION=9.1.0 109 | GNAT_ARCHIVE=gcc-$GNAT_VERSION-x86_64-apple-darwin15-bin 110 | mkdir -p /tmp/gnat 111 | wget_retry https://sourceforge.net/projects/gnuada/files/GNAT_GCC%20Mac%20OS%20X/$GNAT_VERSION/native/$GNAT_ARCHIVE.tar.bz2 112 | tar jxvf $GNAT_ARCHIVE.tar.bz2 -C /tmp/gnat 113 | export GNAT_ROOT=/tmp/gnat/$GNAT_ARCHIVE 114 | else 115 | cp $WORK_DIR/build-data/lib/$ARCH/libftdi1.a $WORK_DIR/build-data/lib/$ARCH/libftdi.a 116 | fi 117 | -------------------------------------------------------------------------------- /scripts/test/install_toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # this script assumes the toolchain artifact has been copied into 6 | # the root of the repo 7 | 8 | cd $WORK_DIR 9 | if [ ${ARCH:0:7} = "windows" ] 10 | then 11 | unzip fpga-toolchain-$ARCH-$VERSION.zip 12 | export PIP=pip 13 | export PYTHON=python 14 | export SED=sed 15 | elif [ $ARCH = "darwin" ] 16 | then 17 | tar -xvf fpga-toolchain-$ARCH-$VERSION.tar.gz 18 | brew install python@3.8 gnu-sed 19 | export PIP=pip3 20 | export PYTHON=python3 21 | export SED=gsed 22 | else 23 | tar -xvf fpga-toolchain-$ARCH-$VERSION.tar.gz 24 | 25 | # install python 3.6 on ubuntu 16.04 for nmigen 26 | # TODO: test on non-debian distros 27 | sudo apt-get update 28 | sudo apt-get install -y --no-install-recommends software-properties-common 29 | sudo add-apt-repository -y -u ppa:deadsnakes/ppa 30 | sudo apt-get install -y --no-install-recommends python3.6 python3-pip 31 | 32 | export PIP="python3.6 -m pip" 33 | export PYTHON=python3.6 34 | export SED=sed 35 | $PIP install --upgrade pip 36 | $PIP install setuptools wheel 37 | fi 38 | 39 | export PATH="$WORK_DIR/fpga-toolchain/bin:$PATH" 40 | export GHDL_PREFIX="$WORK_DIR/fpga-toolchain/lib/ghdl" 41 | 42 | $PIP install git+https://github.com/nmigen/nmigen.git#egg=nmigen 43 | $PIP install git+https://github.com/nmigen/nmigen-boards.git 44 | -------------------------------------------------------------------------------- /scripts/test/run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Test ICE40 design with yosys and nextpnr-ice40 3 | 4 | set -e 5 | 6 | # -- Toolchain name 7 | export NAME=fpga-toolchain-tests 8 | 9 | # -- Debug flags 10 | INSTALL_DEPS=0 # stops _common.sh installing dev deps 11 | TEST_BINARIES_EXECUTE="${TEST_BINARIES_EXECUTE:-1}" 12 | TEST_ICE40_BLINKY="${TEST_ICE40_BLINKY:-1}" 13 | TEST_ECP5_BLINKY="${TEST_ECP5_BLINKY:-1}" 14 | TEST_NMIGEN="${TEST_NMIGEN:-1}" 15 | TEST_GHDL_YOSYS="${TEST_GHDL_YOSYS:-1}" 16 | TEST_NEXTPNR_PYTHON="${TEST_NEXTPNR_PYTHON:-1}" 17 | TEST_SBY="${TEST_SBY:-1}" 18 | 19 | . scripts/_common.sh $1 20 | 21 | build_setup 22 | 23 | . $WORK_DIR/scripts/test/install_toolchain.sh 24 | 25 | if [ $TEST_BINARIES_EXECUTE == "1" ]; then 26 | print ">> Test binaries execute" 27 | . $WORK_DIR/scripts/test/test_binaries_execute.sh 28 | fi 29 | 30 | if [ $TEST_ICE40_BLINKY == "1" ]; then 31 | print ">> Test ICE40 Blinky" 32 | . $WORK_DIR/scripts/test/test_ice40_blinky.sh 33 | fi 34 | 35 | if [ $TEST_ECP5_BLINKY == "1" ]; then 36 | print ">> Test ECP5 Blinky" 37 | . $WORK_DIR/scripts/test/test_ecp5_blinky.sh 38 | fi 39 | 40 | if [ $TEST_ECP5_BLINKY == "1" ]; then 41 | print ">> Test nMigen" 42 | . $WORK_DIR/scripts/test/test_nmigen.sh 43 | fi 44 | 45 | if [ $TEST_GHDL_YOSYS == "1" ]; then 46 | print ">> Test ghdl-yosys-plugin" 47 | . $WORK_DIR/scripts/test/test_ghdl_yosys.sh 48 | fi 49 | 50 | if [ $TEST_NEXTPNR_PYTHON == "1" ]; then 51 | print ">> Test nextpnr embedded python" 52 | . $WORK_DIR/scripts/test/test_nextpnr_python.sh 53 | fi 54 | 55 | if [ $TEST_SBY == "1" ]; then 56 | print ">> Test SymbiYosys" 57 | . $WORK_DIR/scripts/test/test_sby.sh 58 | fi 59 | -------------------------------------------------------------------------------- /scripts/test/test_binaries_execute.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Test binaries execute with --help 3 | 4 | set -e 5 | 6 | tools_to_check=(dfu-prefix dfu-suffix dfu-util ecpbram ecpmulti ecppack ecppll \ 7 | ecpprog ecpunpack ghdl icebram icemulti icepack icepll iceprog icetime \ 8 | nextpnr-ecp5 nextpnr-ice40 yosys yosys-abc yosys-config yosys-filterlib \ 9 | yosys-smtbmc openFPGALoader \ 10 | sby yices yices-sat yices-smt yices-smt2 z3 boolector \ 11 | btorsim btoruntrace btormc btorimc) 12 | 13 | if [ ${ARCH:0:7} = "windows" ] 14 | then 15 | tools_to_check+=(make) 16 | else 17 | tools_to_check+=(btormbt) 18 | fi 19 | 20 | # if [ ${ARCH:0:5} = "linux" ] 21 | # then 22 | # tools_to_check+=(avy) 23 | # fi 24 | 25 | for i in "${tools_to_check[@]}"; 26 | do 27 | if $i --help 2&> /dev/null 28 | then 29 | echo exit code $? OK: $i 30 | else 31 | stored_exit_code=$? 32 | if [ "$stored_exit_code" = "1" ] || [ "$stored_exit_code" = "64" ] 33 | then 34 | echo exit code $stored_exit_code OK: $i 35 | else 36 | echo exit code $stored_exit_code FAIL: $i 37 | exit $stored_exit_code 38 | fi 39 | fi 40 | 41 | done 42 | -------------------------------------------------------------------------------- /scripts/test/test_ecp5_blinky.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Test ECP5 design with yosys and nextpnr-ice40 3 | 4 | set -e 5 | 6 | dir_name=ulx3s-examples 7 | commit=master 8 | git_url=https://github.com/ulx3s/ulx3s-examples.git 9 | 10 | git_clone_direct $dir_name $git_url $commit 11 | cd $BUILD_DIR/$dir_name/blinky/OpenSource 12 | $MAKE ulx3s.bit 13 | -------------------------------------------------------------------------------- /scripts/test/test_ghdl_yosys.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Test VHDL synthesis with ghdl-yosys-plugin 3 | 4 | set -e 5 | 6 | dir_name=ghdl-yosys-plugin 7 | commit=master 8 | git_url=https://github.com/ghdl/ghdl-yosys-plugin.git 9 | 10 | git_clone_direct $dir_name $git_url $commit 11 | 12 | cd $BUILD_DIR/$dir_name/examples/icestick/leds/ 13 | 14 | # Analyse VHDL sources 15 | ghdl -a leds.vhdl 16 | ghdl -a spin1.vhdl 17 | # (it's also possible to get yosys to perform this step for us, but it's better to test the ghdl 18 | # binary works here) 19 | 20 | # Synthesize the design. 21 | yosys -p 'ghdl leds; synth_ice40 -json leds.json' 22 | 23 | # P&R 24 | nextpnr-ice40 --package hx1k --pcf leds.pcf --asc leds.asc --json leds.json 25 | 26 | # Generate bitstream 27 | icepack leds.asc leds.bin 28 | -------------------------------------------------------------------------------- /scripts/test/test_ice40_blinky.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Test ICE40 design with yosys and nextpnr-ice40 3 | 4 | set -e 5 | 6 | dir_name=icebreaker-examples 7 | commit=master 8 | git_url=https://github.com/icebreaker-fpga/icebreaker-examples.git 9 | 10 | git_clone_direct $dir_name $git_url $commit 11 | cd $BUILD_DIR/$dir_name/blink_count_shift 12 | 13 | $MAKE 14 | -------------------------------------------------------------------------------- /scripts/test/test_nextpnr_python.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -- Test embedded python works in nextpnr 3 | 4 | set -e 5 | 6 | cd $BUILD_DIR 7 | mkdir -p test_nextpnr_python 8 | cd test_nextpnr_python 9 | 10 | echo 'print("hello from python!")' > hello.py 11 | nextpnr-ecp5 --run hello.py 12 | nextpnr-ice40 --run hello.py 13 | -------------------------------------------------------------------------------- /scripts/test/test_nmigen.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Try one ICE40 and one ECP5 target to check yosys + nextpnr-ice40 + nextpnr-ecp5 6 | 7 | # $PYTHON -m nmigen_boards.icestick 8 | # (but with do_program=False) 9 | $PYTHON -c "from nmigen_boards.test.blinky import Blinky; \ 10 | from nmigen_boards.icestick import ICEStickPlatform; \ 11 | ICEStickPlatform().build(Blinky(), do_program=False)" 12 | 13 | $PYTHON -c "from nmigen_boards.test.blinky import Blinky; \ 14 | from nmigen_boards.versa_ecp5 import VersaECP5Platform; \ 15 | VersaECP5Platform().build(Blinky(), do_program=False)" 16 | -------------------------------------------------------------------------------- /scripts/test/test_sby.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | dir_name=sby_test 6 | commit=master 7 | git_url=https://github.com/YosysHQ/SymbiYosys.git 8 | 9 | git_clone_direct $dir_name $git_url $commit 10 | cd $BUILD_DIR/$dir_name/docs/examples/quickstart 11 | # smtbmc 12 | echo ==============COVER 13 | sby -f cover.sby || : 14 | echo exitcode: $? 15 | # smtbmc 16 | echo ==============DEMO 17 | sby -f demo.sby || : 18 | echo exitcode: $? 19 | # smtbmc boolector 20 | echo ==============MEMORY 21 | sby -f memory.sby 22 | echo exitcode: $? 23 | # smtbmc 24 | echo ==============PROVE 25 | sby -f prove.sby 26 | echo exitcode: $? 27 | 28 | cd ../puzzles 29 | # yices 30 | echo ==============HASH 31 | sby -f djb2hash.sby 32 | echo exitcode: $? 33 | # z3 34 | echo ==============PRIME 35 | sby -f primegen.sby 36 | echo exitcode: $? 37 | 38 | cd ../demos 39 | # z3 40 | # sby fib.sby 41 | -------------------------------------------------------------------------------- /scripts/test_bin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Test script 4 | 5 | FILE=$1 6 | 7 | echo "" >&2 8 | echo "Testing $FILE file" >&2 9 | echo "------------------------------" >&2 10 | 11 | function test_base { 12 | # Arg $1: Description of test 13 | # Arg $2: expression to eval 14 | if "${@:2}" 15 | then 16 | echo "$1" >&2 17 | else 18 | echo "$1 [FAILED]" >&2 19 | exit 1 20 | fi 21 | } 22 | 23 | function test_exists { 24 | test_base "- 1. File exists" test -e $1 25 | } 26 | 27 | function test_exec { 28 | test_base "- 2. File is executable" test -x $1 29 | } 30 | 31 | function test_static { 32 | msg="- 3. File is static" 33 | # edbordin: darwin and windows always have a few system libs linked dynamically 34 | # so we resort to checking for anything not on this hardcoded "whitelist" 35 | # (I won't be surprised if this breaks outside of the CI environment) 36 | if [ $ARCH == "darwin" ]; then 37 | pat='^\s*(/usr/lib/libSystem.B.dylib|' 38 | pat+='/usr/lib/libc\+\+.1|' 39 | pat+='/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit|' 40 | pat+='/System/Library/Frameworks/CoreFoundation.framework/' 41 | pat+='Versions/A/CoreFoundation).*$' 42 | 43 | output=$(otool -L -X $1 2>&1 | grep -E -v "$pat" || true) 44 | # show the output for debugging if test fails 45 | [[ -n "$output" ]] && otool -L -X $1 46 | test_base "$msg" test -z "$output" 47 | elif [ ${ARCH:0:7} = "windows" ] 48 | then 49 | pat='^\s*(ntdll|KERNEL32|KERNELBASE|msvcrt|' 50 | pat+='ADVAPI32|sechost|RPCRT4|dbghelp|ucrtbase|' 51 | pat+='USER32|win32u|GDI32|gdi32full|WS2_32)\.(dll|DLL).*$' 52 | 53 | output=$(ldd $1 2>&1 | grep -E -v "$pat" || true) 54 | [[ -n "$output" ]] && ldd $1 55 | test_base "$msg" test -z "$output" 56 | else 57 | output=$(ldd $1 2>&1 | grep "not a dynamic executable" || true) 58 | [[ -z "$output" ]] && ldd $1 59 | test_base "$msg" test -n "$output" 60 | fi 61 | } 62 | 63 | file $FILE 64 | 65 | echo "------------------------------" >&2 66 | 67 | test_exists $FILE 68 | test_exec $FILE 69 | test_static $FILE 70 | 71 | echo "------------------------------" >&2 72 | echo "All tests [PASSED]" >&2 73 | echo "" >&2 74 | -------------------------------------------------------------------------------- /scripts/travis_trigger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #echo "> travis login" 4 | #travis login --org 5 | 6 | echo "> travis token" 7 | travis token --org 8 | 9 | echo "> Enter the token: " 10 | read TOKEN 11 | 12 | echo "> Enter the tag: " 13 | read TAG 14 | 15 | body="{ 16 | \"request\": { 17 | \"branch\": \"$TAG\" 18 | } 19 | }" 20 | 21 | echo "> Trigger travis build: " 22 | curl -s -X POST \ 23 | -H "Content-Type: application/json" \ 24 | -H "Accept: application/json" \ 25 | -H "Travis-API-Version: 3" \ 26 | -H "Authorization: token $TOKEN" \ 27 | -d "$body" \ 28 | https://api.travis-ci.org/repo/FPGAwars%2Ftoolchain-icestorm/requests 29 | 30 | echo "> Done!" 31 | --------------------------------------------------------------------------------