diff --git a/.gitignore b/.gitignore index 12023c9..65957d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ +i386* +*.i386* +x86_64* +*.x86_64* +arm64_* +*.arm64_* *~ -Makefile.deps +*.deps diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..60378a6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## [ Unreleased ] + +### Added +### Changed +### Removed diff --git a/LICENSE b/LICENSE index 17cb286..03b0820 100644 --- a/LICENSE +++ b/LICENSE @@ -1,117 +1,312 @@ -GNU GENERAL PUBLIC LICENSE -Version 2, June 1991 +CERN Open Hardware Licence Version 2 - Weakly Reciprocal -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. +CERN has developed this licence to promote collaboration among +hardware designers and to provide a legal tool which supports the +freedom to use, study, modify, share and distribute hardware designs +and products based on those designs. Version 2 of the CERN Open +Hardware Licence comes in three variants: CERN-OHL-P (permissive); and +two reciprocal licences: this licence, CERN-OHL-W (weakly reciprocal) +and CERN-OHL-S (strongly reciprocal). -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. +The CERN-OHL-W is copyright CERN 2020. Anyone is welcome to use it, in +unmodified form only. -To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. +Use of this Licence does not imply any endorsement by CERN of any +Licensor or their designs nor does it imply any involvement by CERN in +their development. -For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. -We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. +1 Definitions -Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + 1.1 'Licence' means this CERN-OHL-W. -Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + 1.2 'Compatible Licence' means -The precise terms and conditions for copying, distribution and modification follow. + a) any earlier version of the CERN Open Hardware licence, or -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + b) any version of the CERN-OHL-S or the CERN-OHL-W, or -0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + c) any licence which permits You to treat the Source to which + it applies as licensed under CERN-OHL-S or CERN-OHL-W + provided that on Conveyance of any such Source, or any + associated Product You treat the Source in question as being + licensed under CERN-OHL-S or CERN-OHL-W as appropriate. -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + 1.3 'Source' means information such as design materials or digital + code which can be applied to Make or test a Product or to + prepare a Product for use, Conveyance or sale, regardless of its + medium or how it is expressed. It may include Notices. -1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + 1.4 'Covered Source' means Source that is explicitly made available + under this Licence. -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + 1.5 'Product' means any device, component, work or physical object, + whether in finished or intermediate form, arising from the use, + application or processing of Covered Source. -2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + 1.6 'Make' means to create or configure something, whether by + manufacture, assembly, compiling, loading or applying Covered + Source or another Product or otherwise. - a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + 1.7 'Available Component' means any part, sub-assembly, library or + code which: - b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + a) is licensed to You as Complete Source under a Compatible + Licence; or - c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + b) is available, at the time a Product or the Source containing + it is first Conveyed, to You and any other prospective + licensees -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + i) with sufficient rights and information (including any + configuration and programming files and information + about its characteristics and interfaces) to enable it + either to be Made itself, or to be sourced and used to + Make the Product; or + ii) as part of the normal distribution of a tool used to + design or Make the Product. -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + 1.8 'External Material' means anything (including Source) which: -In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + a) is only combined with Covered Source in such a way that it + interfaces with the Covered Source using a documented + interface which is described in the Covered Source; and -3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + b) is not a derivative of or contains Covered Source, or, if it + is, it is solely to the extent necessary to facilitate such + interfacing. - a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + 1.9 'Complete Source' means the set of all Source necessary to Make + a Product, in the preferred form for making modifications, + including necessary installation and interfacing information + both for the Product, and for any included Available Components. + If the format is proprietary, it must also be made available in + a format (if the proprietary tool can create it) which is + viewable with a tool available to potential licensees and + licensed under a licence approved by the Free Software + Foundation or the Open Source Initiative. Complete Source need + not include the Source of any Available Component, provided that + You include in the Complete Source sufficient information to + enable a recipient to Make or source and use the Available + Component to Make the Product. - b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + 1.10 'Source Location' means a location where a Licensor has placed + Covered Source, and which that Licensor reasonably believes will + remain easily accessible for at least three years for anyone to + obtain a digital copy. - c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + 1.11 'Notice' means copyright, acknowledgement and trademark notices, + Source Location references, modification notices (subsection + 3.3(b)) and all notices that refer to this Licence and to the + disclaimer of warranties that are included in the Covered + Source. -The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + 1.12 'Licensee' or 'You' means any person exercising rights under + this Licence. -If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + 1.13 'Licensor' means a natural or legal person who creates or + modifies Covered Source. A person may be a Licensee and a + Licensor at the same time. -4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + 1.14 'Convey' means to communicate to the public or distribute. -5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. -6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. +2 Applicability -7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + 2.1 This Licence governs the use, copying, modification, Conveying + of Covered Source and Products, and the Making of Products. By + exercising any right granted under this Licence, You irrevocably + accept these terms and conditions. -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + 2.2 This Licence is granted by the Licensor directly to You, and + shall apply worldwide and without limitation in time. -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + 2.3 You shall not attempt to restrict by contract or otherwise the + rights granted under this Licence to other Licensees. -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + 2.4 This Licence is not intended to restrict fair use, fair dealing, + or any other similar right. -8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. -9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. +3 Copying, Modifying and Conveying Covered Source -Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + 3.1 You may copy and Convey verbatim copies of Covered Source, in + any medium, provided You retain all Notices. -10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + 3.2 You may modify Covered Source, other than Notices, provided that + You irrevocably undertake to make that modified Covered Source + available from a Source Location should You Convey a Product in + circumstances where the recipient does not otherwise receive a + copy of the modified Covered Source. In each case subsection 3.3 + shall apply. -NO WARRANTY + You may only delete Notices if they are no longer applicable to + the corresponding Covered Source as modified by You and You may + add additional Notices applicable to Your modifications. -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + 3.3 You may Convey modified Covered Source (with the effect that You + shall also become a Licensor) provided that You: -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + a) retain Notices as required in subsection 3.2; -END OF TERMS AND CONDITIONS + b) add a Notice to the modified Covered Source stating that You + have modified it, with the date and brief description of how + You have modified it; -How to Apply These Terms to Your New Programs + c) add a Source Location Notice for the modified Covered Source + if You Convey in circumstances where the recipient does not + otherwise receive a copy of the modified Covered Source; and -If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + d) license the modified Covered Source under the terms and + conditions of this Licence (or, as set out in subsection + 8.3, a later version, if permitted by the licence of the + original Covered Source). Such modified Covered Source must + be licensed as a whole, but excluding Available Components + contained in it or External Material to which it is + interfaced, which remain licensed under their own applicable + licences. -To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author +4 Making and Conveying Products - This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + 4.1 You may Make Products, and/or Convey them, provided that You + either provide each recipient with a copy of the Complete Source + or ensure that each recipient is notified of the Source Location + of the Complete Source. That Complete Source includes Covered + Source and You must accordingly satisfy Your obligations set out + in subsection 3.3. If specified in a Notice, the Product must + visibly and securely display the Source Location on it or its + packaging or documentation in the manner specified in that + Notice. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + 4.2 Where You Convey a Product which incorporates External Material, + the Complete Source for that Product which You are required to + provide under subsection 4.1 need not include any Source for the + External Material. - You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. + 4.3 You may license Products under terms of Your choice, provided + that such terms do not restrict or attempt to restrict any + recipients' rights under this Licence to the Covered Source. -If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. +5 Research and Development -The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. +You may Convey Covered Source, modified Covered Source or Products to +a legal entity carrying out development, testing or quality assurance +work on Your behalf provided that the work is performed on terms which +prevent the entity from both using the Source or Products for its own +internal purposes and Conveying the Source or Products or any +modifications to them to any person other than You. Any modifications +made by the entity shall be deemed to be made by You pursuant to +subsection 3.2. -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: - Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. +6 DISCLAIMER AND LIABILITY + + 6.1 DISCLAIMER OF WARRANTY -- The Covered Source and any Products + are provided 'as is' and any express or implied warranties, + including, but not limited to, implied warranties of + merchantability, of satisfactory quality, non-infringement of + third party rights, and fitness for a particular purpose or use + are disclaimed in respect of any Source or Product to the + maximum extent permitted by law. The Licensor makes no + representation that any Source or Product does not or will not + infringe any patent, copyright, trade secret or other + proprietary right. The entire risk as to the use, quality, and + performance of any Source or Product shall be with You and not + the Licensor. This disclaimer of warranty is an essential part + of this Licence and a condition for the grant of any rights + granted under this Licence. + + 6.2 EXCLUSION AND LIMITATION OF LIABILITY -- The Licensor shall, to + the maximum extent permitted by law, have no liability for + direct, indirect, special, incidental, consequential, exemplary, + punitive or other damages of any character including, without + limitation, procurement of substitute goods or services, loss of + use, data or profits, or business interruption, however caused + and on any theory of contract, warranty, tort (including + negligence), product liability or otherwise, arising in any way + in relation to the Covered Source, modified Covered Source + and/or the Making or Conveyance of a Product, even if advised of + the possibility of such damages, and You shall hold the + Licensor(s) free and harmless from any liability, costs, + damages, fees and expenses, including claims by third parties, + in relation to such use. + + +7 Patents + + 7.1 Subject to the terms and conditions of this Licence, each + Licensor hereby grants to You a perpetual, worldwide, + non-exclusive, no-charge, royalty-free, irrevocable (except as + stated in subsections 7.2 and 8.4) patent licence to Make, have + Made, use, offer to sell, sell, import, and otherwise transfer + the Covered Source and Products, where such licence applies only + to those patent claims licensable by such Licensor that are + necessarily infringed by exercising rights under the Covered + Source as Conveyed by that Licensor. + + 7.2 If You institute patent litigation against any entity (including + a cross-claim or counterclaim in a lawsuit) alleging that the + Covered Source or a Product constitutes direct or contributory + patent infringement, or You seek any declaration that a patent + licensed to You under this Licence is invalid or unenforceable + then any rights granted to You under this Licence shall + terminate as of the date such process is initiated. + + +8 General + + 8.1 If any provisions of this Licence are or subsequently become + invalid or unenforceable for any reason, the remaining + provisions shall remain effective. + + 8.2 You shall not use any of the name (including acronyms and + abbreviations), image, or logo by which the Licensor or CERN is + known, except where needed to comply with section 3, or where + the use is otherwise allowed by law. Any such permitted use + shall be factual and shall not be made so as to suggest any kind + of endorsement or implication of involvement by the Licensor or + its personnel. + + 8.3 CERN may publish updated versions and variants of this Licence + which it considers to be in the spirit of this version, but may + differ in detail to address new problems or concerns. New + versions will be published with a unique version number and a + variant identifier specifying the variant. If the Licensor has + specified that a given variant applies to the Covered Source + without specifying a version, You may treat that Covered Source + as being released under any version of the CERN-OHL with that + variant. If no variant is specified, the Covered Source shall be + treated as being released under CERN-OHL-S. The Licensor may + also specify that the Covered Source is subject to a specific + version of the CERN-OHL or any later version in which case You + may apply this or any later version of CERN-OHL with the same + variant identifier published by CERN. + + You may treat Covered Source licensed under CERN-OHL-W as + licensed under CERN-OHL-S if and only if all Available + Components referenced in the Covered Source comply with the + corresponding definition of Available Component for CERN-OHL-S. + + 8.4 This Licence shall terminate with immediate effect if You fail + to comply with any of its terms and conditions. + + 8.5 However, if You cease all breaches of this Licence, then Your + Licence from any Licensor is reinstated unless such Licensor has + terminated this Licence by giving You, while You remain in + breach, a notice specifying the breach and requiring You to cure + it within 30 days, and You have failed to come into compliance + in all material respects by the end of the 30 day period. Should + You repeat the breach after receipt of a cure notice and + subsequent reinstatement, this Licence will terminate + immediately and permanently. Section 6 shall continue to apply + after any termination. + + 8.6 This Licence shall not be enforceable except by a Licensor + acting as such, and third party beneficiary rights are + specifically excluded. -signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice diff --git a/Makefile b/Makefile index 4a7ee1d..d1c8a44 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,29 @@ -#------------------------------------------------------------------------- -# -# Copyright (c) 2021 Rajit Manohar -# Copyright (c) 2021 University of Groningen - Ole Richter -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. -# -#------------------------------------------------------------------------- -TARGETACT= +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2022 University of Groningen - Ole Richter +# +# This source describes Open Hardware and is licensed under the CERN-OHL-W v2 or later +# +# You may redistribute and modify this documentation and make products +# using it under the terms of the CERN-OHL-W v2 (https:/cern.ch/cern-ohl). +# This documentation is distributed WITHOUT ANY EXPRESS OR IMPLIED +# WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY +# AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-W v2 +# for applicable conditions. +# +# Source location: https://git.web.rug.nl/bics/actlib_dataflow_neuro +# +# As per CERN-OHL-W v2 section 4.1, should You produce hardware based on +# these sources, You must maintain the Source Location visible in its +# documentation. +# +# ----------------------------------------------------------------------------- -SUBDIRS= +TARGETACT=LICENSE +# template because its a template based appoach no syntesis so it would be wrong in syn +TARGETACTSUBDIR=template/dataflow_neuro + +SUBDIRS=dataflow_neuro include $(ACT_HOME)/scripts/Makefile.std diff --git a/README.md b/README.md index dd867f6..2494da7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ -# The classical dataflow template library for mixed signal neuromoric processors +# A dataflow template library for mixed signal neuromoric processors +the library will be installed in `$ACT_HOME/act/template/dataflow_neuro`. +This path is part of the default search path for any ACT tool. -the library will be installed in `$ACT_HOME/act`. This path is part of the default search path for any ACT tool. - -this ibrary depends on stdlib - -The comments in the `.act` files have some basic documentation. +this library depends on stdlib (https://github.com/asyncvlsi/stdlib) ## Installation -Set `$ACT_HOME` to the root of your ACT installation, and then run `make install` +Set `$ACT_HOME` to the root of your ACT installation, and then run `make install`. + +## Unit tests + +After installation, you can run `make runtest` to execute the unit tests \ No newline at end of file diff --git a/cern_ohl_w_v2_howto.pdf b/cern_ohl_w_v2_howto.pdf new file mode 100644 index 0000000..1b38b28 Binary files /dev/null and b/cern_ohl_w_v2_howto.pdf differ diff --git a/dataflow_neuro/Makefile b/dataflow_neuro/Makefile new file mode 100644 index 0000000..583860d --- /dev/null +++ b/dataflow_neuro/Makefile @@ -0,0 +1,29 @@ +# ----------------------------------------------------------------------------- +# +# Copyright (c) 2022 University of Groningen - Ole Richter +# +# This source describes Open Hardware and is licensed under the CERN-OHL-W v2 or later +# +# You may redistribute and modify this documentation and make products +# using it under the terms of the CERN-OHL-W v2 (https:/cern.ch/cern-ohl). +# This documentation is distributed WITHOUT ANY EXPRESS OR IMPLIED +# WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY +# AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-W v2 +# for applicable conditions. +# +# Source location: https://git.web.rug.nl/bics/actlib_dataflow_neuro +# +# As per CERN-OHL-W v2 section 4.1, should You produce hardware based on +# these sources, You must maintain the Source Location visible in its +# documentation. +# +# ----------------------------------------------------------------------------- + +TARGETACT=__all__.act stdcells.act acells.act primitives.act +SUBDIRS= +# template because its a template based appoach no syntesis so it would be wrong in syn +TARGETACTSUBDIR=template/dataflow_neuro + +include $(ACT_HOME)/scripts/Makefile.std + +-include Makefile.deps diff --git a/dataflow_neuro/__all__.act b/dataflow_neuro/__all__.act new file mode 100644 index 0000000..60c97bd --- /dev/null +++ b/dataflow_neuro/__all__.act @@ -0,0 +1,27 @@ +/************************************************************************* + * + * This file is part of ACT dataflow neuro library + * + * Copyright (c) 2022 University of Groningen - Ole Richter + * + * This source describes Open Hardware and is licensed under the CERN-OHL-W v2 or later + * + * You may redistribute and modify this documentation and make products + * using it under the terms of the CERN-OHL-W v2 (https:/cern.ch/cern-ohl). + * This documentation is distributed WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY + * AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-W v2 + * for applicable conditions. + * + * Source location: https://git.web.rug.nl/bics/actlib_dataflow_neuro + * + * As per CERN-OHL-W v2 section 4.1, should You produce hardware based on + * these sources, You must maintain the Source Location visible in its + * documentation. + * + ************************************************************************** + */ + +import template::dataflow_neuro::cell_lib_std; +import template::dataflow_neuro::cell_lib_async; +import template::dataflow_neuro::primitives; \ No newline at end of file diff --git a/dataflow_neuro/cell_lib_async.act b/dataflow_neuro/cell_lib_async.act new file mode 100644 index 0000000..9ad79ef --- /dev/null +++ b/dataflow_neuro/cell_lib_async.act @@ -0,0 +1,446 @@ +/************************************************************************* + * + * This file is part of ACT dataflow neuro library + * + * Copyright (c) 2022 University of Groningen - Ole Richter + * Copyright (c) 2022 University of Groningen - Hugh Greatorex + * Copyright (c) 2022 University of Groningen - Michele Mastella + * + * This source describes Open Hardware and is licensed under the CERN-OHL-W v2 or later + * + * You may redistribute and modify this documentation and make products + * using it under the terms of the CERN-OHL-W v2 (https:/cern.ch/cern-ohl). + * This documentation is distributed WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY + * AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-W v2 + * for applicable conditions. + * + * Source location: https://git.web.rug.nl/bics/actlib_dataflow_neuro + * + * As per CERN-OHL-W v2 section 4.1, should You produce hardware based on + * these sources, You must maintain the Source Location visible in its + * documentation. + * + ************************************************************************** + */ + +namespace template { + namespace dataflow_neuro { + + export defcell A_1C1P2N_RB_X1 (bool! y; bool? c1,p1,n1,n2,pr_B, sr_B, vdd, vss) { + bool _y; + prs{ + (~p1 & ~c1)|~pr_B -> _y+ + c1 & n1 & n2 & sr_B -> _y- + _y => y- + + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1} + } + } + + export defcell A_1C1P2N_R_X1 (bool! y; bool? c1,p1,n1,n2,pr_B, sr_B, vdd, vss) { + prs{ + (~p1 & ~c1)|~pr_B -> y- + c1 & n1 & n2 & sr_B -> y+ + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1} + } + } + + + export defcell A_1C1P_1N_X1 (bool! y; bool? c1, p1, n1, vdd, vss) + { + prs{ + ~p1 & ~c1 -> y+ + c1 & n1 -> y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_1C1P_B (bool! y; bool? c1, p1, vdd, vss) + { + bool _y; + prs{ + ~p1 & ~c1 -> _y- + c1 -> _y+ + _y => y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1} } + } + + + export defcell A_1C1P (bool! y; bool? c1, p1, vdd, vss) + { + prs{ + ~p1 & ~c1 -> y+ + c1 -> y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_1C2P1N_X1 (bool! y; bool? c1, p1, p2, n1, vdd, vss) + { + prs{ + ~p1 & ~p2 & ~c1 -> y+ + c1 & n1 -> y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_1C2P_B_X1 (bool! y; bool? c1, p1, p2, vdd, vss) + { + bool _y; + prs{ + ~p1 & ~p2 & ~c1 -> _y- + c1 -> _y+ + _y => y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1} } + } + } + + export defcell A_1C2P (bool! y; bool? c1, p1, p2, vdd, vss) + { + prs{ + ~p1 & ~p2 & ~c1 -> y+ + c1 -> y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_1C3P2P2N_R_X1 (bool! y; bool? c1, p1, p2, p3, p4, p5 n1, n2, pr_B, sr_B, vdd, vss) + { + prs{ + (~p1 & ~p2 & ~p3 & ~c1)|(~p4&~p5&~c1)|~pr_B -> y+ + c1 & n1 & n2 & sr_B -> y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_2C2N2N_RB_X1 (bool ! y; bool? c1, c2, n1, n2, n3, n4, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2) | ~pr_B -> _y+ + c1 & c2 & ((n1 & n2) | (n3 & n4)) & sr_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1}} + } + + export defcell A_2C2N2N_RB_X2 (bool ! y; bool? c1, c2, n1, n2, n3, n4, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2) | ~pr_B -> _y+ + c1 & c2 & ((n1 & n2) | (n3 & n4)) & sr_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-2}; _y{-1}} + } + + + export defcell A_2C2N2N_RB_X4 (bool ! y; bool? c1, c2, n1, n2, n3, n4, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2) | ~pr_B -> _y+ + c1 & c2 & ((n1 & n2) | (n3 & n4)) & sr_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-4}; _y{-1}} + } + + + export defcell A_2C2N2N_R_X1 (bool ! y; bool? c1, c2, n1, n2, n3, n4, pr_B, sr_B; bool? vdd, vss) + { + prs{ + (~c1 & ~c2) | ~pr_B -> y+ + c1 & c2 & ((n1 & n2) | (n3 & n4)) & sr_B -> y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_2C2N_R_B_X1 (bool ! y; bool? c1, c2, n1, n2, rp_B, rs_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2) | ~rp_B -> _y+ + c1 & c2 & n1 & n2 & rs_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1}} + } + + export defcell A_2C2N_R_B_X2 (bool ! y; bool? c1, c2, n1, n2, rp_B, rs_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2) | ~rp_B -> _y+ + c1 & c2 & n1 & n2 & rs_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-2}; _y{-1}} + } + + export defcell A_2C2N_R_B_X4 (bool ! y; bool? c1, c2, n1, n2, rp_B, rs_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2) | ~rp_B -> _y+ + c1 & c2 & n1 & n2 & rs_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-4}; _y{-1}} + } + + + export defcell A_2C2N_R_X1 (bool ! y; bool? c1, c2, n1, n2, rp_B, rs_B; bool? vdd, vss) + { + prs{ + (~c1 & ~c2) | ~rp_B -> y+ + c1 & c2 & n1 & n2 & rs_B -> y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_2C_B_X1 (bool ! y; bool? c1, c2; bool? vdd, vss) + { + bool _y; + prs{ + ~c1 & ~c2 -> _y+ + c1 & c2 -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1}} + } + + export defcell A_2C_RB_X1 (bool ! y; bool? c1, c2, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2) | ~pr_B -> _y+ + c1 & c2 & sr_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1}} + } + + export defcell A_2C_R_X1 (bool ! y; bool? c1, c2, pr_B, sr_B; bool? vdd, vss) + { + prs{ + (~c1 & ~c2) | ~pr_B -> y+ + c1 & c2 & sr_B -> y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_2C_X1 (bool ! y; bool? c1, c2; bool? vdd, vss) + { + prs{ + ~c1 & ~c2 -> y+ + c1 & c2 -> y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_3C_RB_X1 (bool ! y; bool? c1, c2, c3, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2 & ~c3) | ~pr_B -> _y+ + c1 & c2 & c3 & sr_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1}} + } + + export defcell A_3C_RB_X2 (bool ! y; bool? c1, c2, c3, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2 & ~c3) | ~pr_B -> _y+ + c1 & c2 & c3 & sr_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-2}; _y{-1}} + } + + export defcell A_3C_RB_X4 (bool ! y; bool? c1, c2, c3, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2 & ~c3) | ~pr_B -> _y+ + c1 & c2 & c3 & sr_B -> _y- + _y => y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-4}; _y{-1}} + } + + export defcell A_3C_R_X1 (bool ! y; bool? c1, c2, c3, pr_B, sr_B; bool? vdd, vss) + { + prs{ + (~c1 & ~c2 & ~c3) | ~pr_B -> y+ + c1 & c2 & c3 & sr_B -> y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_3C_X1 (bool ! y; bool? c1, c2, c3; bool? vdd, vss) + { + prs{ + ~c1 & ~c2 & ~c3 -> y+ + c1 & c2 & c3 -> y- + } + sizing { + leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export deffcell A_4C_RB_X1 (bool! y; bool? c1, c2, c3, c4, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2 & ~c3 & ~c4) | ~pr_B -> _y+ + c1 & c2 & c3 & c4 & sr_B-> _y- + _y => y- + } + sizing { leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1}} + } + + export deffcell A_4C_RB_X2 (bool! y; bool? c1, c2, c3, c4, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2 & ~c3 & ~c4) | ~pr_B -> _y+ + c1 & c2 & c3 & c4 & sr_B-> _y- + _y => y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-2}; _y{-1}} + } + + export deffcell A_4C_RB_X4 (bool! y; bool? c1, c2, c3, c4, pr_B, sr_B; bool? vdd, vss) + { + bool _y; + prs{ + (~c1 & ~c2 & ~c3 & ~c4) | ~pr_B -> _y+ + c1 & c2 & c3 & c4 & sr_B-> _y- + _y => y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-4}; _y{-1}} + } + + export deffcell A_4C_R_X1 (bool! y; bool? c1, c2, c3, c4, pr_B, sr_B; bool? vdd, vss) + { + prs{ + (~c1 & ~c2 & ~c3 & ~c4) | ~pr_B -> y+ + c1 & c2 & c3 & c4 & sr_B-> y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + + export defcell A_4P1N1N_B_X1 (bool! y; bool? n1, n2, p1, p2, p3, p4; bool? vdd, vss) + { + bool _y; + prs{ + ~p1 & ~p2 & ~p3 & ~p4 -> _y+ + n1 | n2 -> _y- + _y => y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}; _y{-1} } + } + + export defcell A_4P1N1N_X1 (bool! y; bool? n1, n2, p1, p2, p3, p4; bool? vdd, vss) + { + prs{ + ~p1 & ~p2 & ~p3 & ~p4 -> y+ + n1 | n2 -> y- + } + sizing {leak_adjust <- 1; + p_n_mode <- 1; + y {-1}} + } + } + + xp018_cell_lib_async::A_1C1P_B_X1 cell1; + diff --git a/dataflow_neuro/cell_lib_std.act b/dataflow_neuro/cell_lib_std.act new file mode 100644 index 0000000..4b17bad --- /dev/null +++ b/dataflow_neuro/cell_lib_std.act @@ -0,0 +1,280 @@ +/************************************************************************* + * + * This file is part of ACT dataflow neuro library + * + * Copyright (c) 2020-2021 Rajit Manohar + * Copyright (c) 2022 University of Groningen - Ole Richter + * Copyright (c) 2022 University of Groningen - Madison Cotteret + * + * This source describes Open Hardware and is licensed under the CERN-OHL-W v2 or later + * + * You may redistribute and modify this documentation and make products + * using it under the terms of the CERN-OHL-W v2 (https:/cern.ch/cern-ohl). + * This documentation is distributed WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY + * AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-W v2 + * for applicable conditions. + * + * Source location: https://git.web.rug.nl/bics/actlib_dataflow_neuro + * + * As per CERN-OHL-W v2 section 4.1, should You produce hardware based on + * these sources, You must maintain the Source Location visible in its + * documentation. + * + ************************************************************************** + */ + +namespace template { + namespace dataflow_neuro { + + export defproc TIELO_X1(bool! y; bool? vdd, vss) + { + y = vss; + } + + export defproc TIEHI_X1(bool! y; bool? vdd, vss) + { + y = vdd; + } + + /*-- inverters --*/ + + defproc inv (bool! y; bool? a, vdd, vss) + { + prs { + a => y- + } + } + + template + defproc szinv <: inv() + { + [nf = 0 -> sizing { y {-1} } + [] else -> sizing { y {-2*nf,svt,nf} } + ] + } + + export defcell INV_X1<: szinv<0>() { } + export defcell INV_X2<: szinv<1>() { } + export defcell INV_X4<: szinv<2>() { } + export defcell INV_X8<: szinv<4>() { } + + /*-- clock delay buffers --*/ + + template + defproc dbuf (bool! y; bool? a, vdd, vss) + { + {N > 0 : "Delay buffer needs at least one stage!"}; + bool sig[2*N+1]; + sig[0] = a; + sig[2*N] = y; + prs { + (i:2*N: ~sig[i] <80;2> -> sig[i+1]+ + sig[i] <40;2> -> sig[i+1]- + ) + } + } + + export defproc CLKBUF1 <: dbuf<2>() { } + export defproc CLKBUF2 <: dbuf<3>() { } + export defproc CLKBUF3 <: dbuf<4>() { } + + + /*-- signal buffers --*/ + + defproc buf (bool! y; bool? a, vdd, vss) + { + bool _y; + prs { + a => _y- + _y => y- + } + } + + export defcell BUF_X2<: buf() + { + sizing { _y {-1}; y {-2} } + } + + export defcell BUF_X4<: buf() + { + sizing { _y {-1.5}; y {-4,2} } + } + + + /*-- simple gates --*/ + + export defcell NOR2_X1(bool! y; bool? a, b, vdd, vss) + { + prs { + a | b => y- + } + sizing { y {-1} } + } + + export defcell NOR3_X1(bool! y; bool? a, b, c, vdd, vss) + { + prs { + a | b | c => y- + } + sizing { y {-1} } + } + + export defcell OR2_X1(bool! y; bool? a, b, vdd, vss) + { + bool _y; + prs { + a | b => _y- + _y => y- + } + sizing { _y{-1}; y{-1} } + } + + export defcell OR2_X2(bool! y; bool? a, b, vdd, vss) + { + bool _y; + prs { + a | b => _y- + _y => y- + } + sizing { _y{-1}; y{-2} } + } + + export defcell NAND2_X1(bool! y; bool? a, b, vdd, vss) + { + prs { + a & b => y- + } + sizing { y{-1} } + } + + export defcell NAND3_X1(bool! y; bool? a, b, c, vdd, vss) + { + prs { + a & b & c => y- + } + sizing { y{-1} } + } + + export defcell AND2_X1(bool! y; bool? a, b, vdd, vss) + { + bool _y; + prs { + a & b => _y- + _y => y- + } + sizing { _y{-1}; y{-1} } + } + + export defcell AND2_X2(bool! y; bool? a, b, vdd, vss) + { + bool _y; + prs { + a & b => _y- + _y => y- + } + sizing { _y{-1}; y{-2} } + } + + export defcell XOR2_X1(bool! y; bool? a, b, vdd, vss) + { + bool _a, _b; + prs { + a => _a- + b => _b- + + [keeper=0] ~b & ~_a | ~_b & ~a -> y+ + _b & _a | b & a -> y- + } + sizing { _a{-1}; _b{-1}; y{-1} } + } + + export defcell XNOR2_X1(bool! y; bool? a, b, vdd, vss) + { + bool _a, _b; + prs { + a => _a- + b => _b- + + [keeper=0] ~b & ~a | ~_b & ~_a -> y+ + b & _a | _b & a -> y- + } + sizing { _a{-1}; _b{-1}; y{-1} } + } + + export defcell MUX2_X1(bool! y; bool? a, b, S, vdd, vss) + { + // y = !( S ? a : b ) + bool _S; + prs { + S => _S- + + [keeper=0] ~a & ~_S | ~b & ~S -> y+ + a & S | b & _S -> y- + } + sizing { _S{-1}; y{-1} } + } + + export defcell OAI21_X1(bool! y; bool? a, b, c, vdd, vss) + { + prs { + (a | b) & c => y- + } + sizing { y{-1} } + } + + export defcell AOI21_X1(bool! y; bool? a, b, c, vdd, vss) + { + prs { + a & b | c => y- + } + sizing { y{-1} } + } + + export defcell OAI22_X1(bool! y; bool? a, b, c, d, vdd, vss) + { + // y = !((a|b) & (c|d)) + prs { + (a | b) & (c | d) => y- + } + sizing { y{-1} } + } + + export defcell AOI22_X1(bool! y; bool? a, b, c, d, vdd, vss) + { + prs { + a & b | c & d => y- + } + sizing { y{-1} } + } + + + /*--- buffered transmission gates ---*/ + + export defcell TBUF1_X1 (bool! y; bool? a, en, vdd, vss) + { + bool _en; + prs { + en => _en- + + ~a & ~_en -> y+ + a & en -> y- + } + sizing { _en{-1}; y{-1} } + } + + export defcell TBUF_X2 (bool! y; bool? a, en, vdd, vss) + { + bool _en; + prs { + en => _en- + + ~a & ~_en -> y+ + a & en -> y- + } + sizing { _en{-2}; y{-2,2} } + } + } +} + + diff --git a/dataflow_neuro/primitives.act b/dataflow_neuro/primitives.act new file mode 100644 index 0000000..45a2e29 --- /dev/null +++ b/dataflow_neuro/primitives.act @@ -0,0 +1,144 @@ +/************************************************************************* + * + * This file is part of ACT dataflow neuro library + * + * Copyright (c) 2022 University of Groningen - Ole Richter + * + * This source describes Open Hardware and is licensed under the CERN-OHL-W v2 or later + * + * You may redistribute and modify this documentation and make products + * using it under the terms of the CERN-OHL-W v2 (https:/cern.ch/cern-ohl). + * This documentation is distributed WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY + * AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-W v2 + * for applicable conditions. + * + * Source location: https://git.web.rug.nl/bics/actlib_dataflow_neuro + * + * As per CERN-OHL-W v2 section 4.1, should You produce hardware based on + * these sources, You must maintain the Source Location visible in its + * documentation. + * + ************************************************************************** + */ +import template::dataflow_neuro::cell_lib_std; +import template::dataflow_neuro::cell_lib_async; +import std::channel; +open std::channel; + +namespace template { + namespace dataflow_neuro { + + // @ole talk to rajit, we use valid the wrong way arround according to stdlib + template + defchan gen_avMx1of2 <: chan(int) (std::data::Mx1of2?! d; bool!? a; bool!? v) + { + { 0 <= V & std::ceil_log2(V) < M : "Initial token value out of range" }; + + methods { + /*-- initialize channel, sender end --*/ + send_init { + [ reset -> (,i:M: [ ((V >> i) & 1) = 0 -> d.d[i].f+ [] else -> d.d[i].t+ ]);[v] + [] else -> (,i:M: d.d[i].t-,d.d[i].f-);[~v] + ] + } + + /*-- set output data --*/ + set { + (,i:M: [((self >> i) & 1) = 0 -> d.d[i].f+ [] else -> d.d[i].t+ ]);[v] + } + + /*-- finish synchronization --*/ + send_up { + [a] + } + + /*-- reset part of the protocol --*/ + send_rest { + (,i:M: d.d[i].t-,d.d[i].f-);[~v],[~a] + } + + /*-- initialize channel, receiver end --*/ + recv_init { + v-;a- + } + + /*-- get value --*/ + get { + [(&i:M: d.d[i].t | d.d[i].f)]; + self := 0; + (;i:M: [ d.d[i].t -> self := self | (1 << i) + [] else -> skip + ] + ) + } + + /*-- finish synchronization action --*/ + recv_up { + v+,a+ + } + + /*-- reset part of the protocol --*/ + recv_rest { + [(&i:M:~d.d[i].t & ~d.d[i].f)];v-,a- + } + + /*-- probe expression on receiver --*/ + // i think this deadlocks with recv_up + recv_probe = v; + + // no sender probe + } + } + export defchan avMx1of2 <: gen_avMx1of2 () { } + export defchan avrMx1of2 <: gen_avMx1of2 () { } + + + /** + * the buffer template gives you a standart buffer of bitwidth N + * + */ + export template + defproc buffer (avMx1of2 in; avMx1of2 out; rsp reset; power supply) { + //control + bool _en,_en_X,_preset_X,_sreset_X; + A_3C_RB_X4 inack_ctl(c1=en_X,c2=in.v,c3=out.v,y=in.a,pr_B=_preset_X,sr_B=_sreset_X,vdd=supply.vdd,vss=supply.vss); + A_1C1P_X1 en_ctl(c1=in.a,p1=out.v,y=_en,vdd=supply.vdd,vss=supply.vss); + sigbuf en_buf(a=_en, y=_en_X, power=supply); + sigbuf preset_buf(a=reset.p,y=preset_X, power=supply); + sigbuf sreset_buf(a=reset.s,y=sreset_X, power=supply); + + //validity + bool _in_v; + ctree vc(in=in.d,y=_in_v, power=supply); + sigbuf in_v_buf<12>(a=_in_v, y=in.v); + + //function + bool _out_a_BX, _out_a_B; + A_2C1N_RB_X4 f_buf_func[N]; + A_2C1N_RB_X4 t_buf_func[N]; + INV_X1 out_a_inv(a=out.a,y=_out_a_B); + sigbuf out_a_B_buf(a=_out_a_B,y=_out_a_BX); + // check if you can also do single var to array connect a=b[N] + // and remove them from the loop + (i:N: + f_buf_func[i].y=out.d.d[i].f; + t_buf_func[i].y=out.d.d[i].t; + f_buf_func[i].c1=_en_X; + t_buf_func[i].c1=_en_X; + f_buf_func[i].c2=_out_a_BX; + t_buf_func[i].c2=_out_a_BX; + f_buf_func[i].n1=in.d.d[i].f; + t_buf_func[i].n1=in.d.d[i].t; + f_buf_func[i].pr_B=_preset_X; + t_buf_func[i].pr_B=_preset_X; + f_buf_func[i].sr_B=_sreset_X; + t_buf_func[i].sr_B=_sreset_X; + f_buf_func[i].vdd=supply.vdd; + t_buf_func[i].vdd=supply.vdd; + f_buf_func[i].vss=supply.vss; + t_buf_func[i].vss=supply.vss; + ) + } + } +} \ No newline at end of file diff --git a/test/repeat_unit.sh b/test/repeat_unit.sh new file mode 100755 index 0000000..3fc8095 --- /dev/null +++ b/test/repeat_unit.sh @@ -0,0 +1,85 @@ +# repeatedly run prsim on one unit_test's PRs + +bold=$(tput bold) +normal=$(tput sgr0) +und=$(tput smul) +i=${unit} +proc="$i<>" + +echo "" +echo "${bold}******************************************" +echo "* ${i} repetitions , show warnings=${warning}*" +echo "******************************************${normal}" + +cd "unit_tests" +echo "${bold}... checking aflat${normal}" + +# check aflat +if ($ACT_HOME/bin/aflat "$i/test_final.act" > "$i/test.prs"); +then + echo "${bold}... aflat complete, checking in prsim${normal}" + + # run prsim on prs + (($ACT_HOME/bin/prsim "$i/test.prs" < "$i/test.prsim") > "$i/prsim.out"); + if (cat "$i/prsim.out" | grep -e "WRONG ASSERT" -e "FATAL" -e "not found") + then + echo "FAILED in first prsim" + else + + # show warnings setting + if [ "${warning}" = "1" ]; + then + echo "${bold}Exit on prsim warnings turned ON${normal}" + else + echo "${bold}Exit on prsim warnings turned OFF${normal}" + fi + echo "" + + # begin prsim test loop + has_failed=0 + iter=0 + echo "${bold}using random_seed${normal}" + echo "\nusing random_seed" >> "$i/prsim.out" + while [ has_failed=0 ] + do + # write prsim test file with random seed appended to top of file + (echo "random_seed $iter \nrandom" > "$i/test_rand.prsim"); + (cat "$i/test.prsim" >> "$i/test_rand.prsim"); + (echo "\nTEST $iter\n" >> "$i/prsim.out"); + + # validate prsim output + if (($ACT_HOME/bin/prsim "$i/test.prs" < "$i/test_rand.prsim") >> "$i/prsim.out"); + then + if [ "${warning}" = "1" ]; + then + if (cat "$i/prsim.out" | grep -e "WRONG ASSERT" -e "FATAL" -e "not found" -e "WARNING:"); + then + echo "${bold}==> test #${iter} ${und}FAILED in prsim${normal}" + has_failed=1 + exit 0 + else + echo "==> passed test #${iter}" + iter=$(($iter + 1)) + fi + else + if (cat "$i/prsim.out" | grep -e "WRONG ASSERT" -e "FATAL" -e "not found"); + then + echo "${bold}==> test #${iter} ${und}FAILED in prsim${normal}" + has_failed=1 + exit 0 + else + echo "==> passed test #${iter}" + iter=$(($iter + 1)) + fi + fi + else + has_failed=1 + exit 0 + fi + done + (cd ".."; pwd); + exit 1 + fi +else + echo "FAILED in aflat conversion" +fi diff --git a/test/run.sh b/test/run.sh new file mode 100755 index 0000000..e3f4d57 --- /dev/null +++ b/test/run.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +fail=0 +faildirs="" +proc="" +bold=$(tput bold) +normal=$(tput sgr0) +und=$(tput smul) + +faildirs="" +failed=0 + +# +# run_test name [option] +# +run_test () { + echo "Testing ${bold}$1 ${normal}" + # clear run directory + if [ -d $1/run ]; then + rm -rf $1/run + fi + mkdir $1/run + cp init.prs $1/run/test.prs + if aflat -ref=1 $1/test.act >> $1/run/test.prs; then + cat init_qdi.prsim $1/test.prsim | prsim -r $1/run/test.prs > $1/run/prsim.out + if egrep '(WRONG|WARNING|Node)' $1/run/prsim.out >/dev/null; then + echo "${bold}*** simulation failed ***${normal}" + faildirs="${faildirs} ${1}-sim" + failed=1 + echo + fi + else + echo "${bold}*** circuit construction failed ***${normal}" + faildirs="${faildirs} ${1}-ckt" + failed=1 + echo + fi +} + +if [ ! ( command -v aflat && command -v prsim ) ]; +then + echo "${bold}Error:${bold} aflat & prsim necessary for tests." + exit 1 +fi + +if [ ! -d "unit_tests" ]; +then + echo "${bold}Error:${bold} no unit_tests directory." + exit 1 +fi + +cd "unit_tests" + +# run all test except single one is specified +if [ -z $1 ]; then + for i in * + do + if [ -d $i -a -f $i/test.act ]; then + run_test $i + fi + done +else + run_test $1 +fi + +if [ $failed -eq 1 ]; then + echo "" + echo "${bold}*********************************" + echo "* FAILED DIRECTORIES:${normal}$faildirs ${bold}*" + echo "*********************************${normal}" +fi + +exit $failed diff --git a/test/unit_tests/fifo3_8bit/test.act b/test/unit_tests/fifo3_8bit/test.act new file mode 100644 index 0000000..3bd4ead --- /dev/null +++ b/test/unit_tests/fifo3_8bit/test.act @@ -0,0 +1,9 @@ +import template::dataflow_neuro + +defproc fifo3_8bit (avMx1of2<8> A; avMx1of2<8> Y) +{ + avMx1of2<8> _0to1,_1to2; + buffer<8> buf0 (.in=A, .out=_0to1); + buffer<8> buf1 (.in=_0to1, .out=_1to2); + buffer<8> buf2 (.in=_1to2, .out=Y); +} diff --git a/test/unit_tests/fifo3_8bit/test.prsim b/test/unit_tests/fifo3_8bit/test.prsim new file mode 100644 index 0000000..8e80632 --- /dev/null +++ b/test/unit_tests/fifo3_8bit/test.prsim @@ -0,0 +1,40 @@ + +set-channel-neutral "t.A" 8 +set t.Y.a 0 + +cycle +system "echo 'reset completed'" +status X +set Reset 0 +mode run +cycle + +assert t.A.a 0 +assert-channel-neutral "t.Y" 8 + +set-channel-valid "t.A" 8 2 + +system "echo 'sending first set A'" +cycle +assert t.A.a 1 +set-channel-neutral "t.A" 8 +cycle +assert t.A.a 0 + +system "echo 'checking first set'" +assert-channel-valid "t.Y" 8 2 +set t.Y.a 1 + +cycle +assert-channel-neutral "t.Y" 8 +set t.Y.a 0 + +system "echo 'sending second set'" +set-channel-valid "t.A" 8 95 +cycle +assert t.A.a 1 +set-channel-neutral "t.A" 8 +cycle +system "echo 'checking second set'" +assert t.A.a 0 +assert-channel-valid "t.Y" 8 95 diff --git a/test/unit_tests/helper.scm b/test/unit_tests/helper.scm new file mode 100644 index 0000000..82473f2 --- /dev/null +++ b/test/unit_tests/helper.scm @@ -0,0 +1,124 @@ +(define % (lambda (x y) (- x (* y (truncate (/ x y)))))) + +(define dualrail-bit + (lambda (x i) + (let ((tmp + (string-append x + (string-append ".d[" + (string-append (number->string i) "]") + ) + ) + )) + (list (string-append tmp ".f") (string-append tmp ".t")) + ) + ) + ) + +(define assert-var-bit + (lambda (x i v) + (let ((tmp (dualrail-bit x i))) + (begin + (assert (car tmp) (- 1 v)) + (assert (cadr tmp) v) + ) + ) + ) + ) + +(define assert-var-int + (lambda (x width value) + (letrec ((assert-one-bit + (lambda (v i) + (cond + ((=? i width) #t) + (#t (begin + (assert-var-bit x i (% v 2)) + (assert-one-bit (truncate (/ v 2)) (+ i 1)) + ) + ) + ) + ) + )) + (assert-one-bit value 0) + ) + ) + ) + +(define assert-channel-valid + (lambda (ch width value) + (assert-var-int (string-append ch ".d") width value) + ) + ) + +(define assert-channel-neutral + (lambda (ch width) + (letrec ((helper + (lambda (i) + (cond + ((=? i width) #t) + (#t (let ((tmp (dualrail-bit (string-append ch ".d") i))) + (begin + (assert (car tmp) 0) + (assert (cadr tmp) 0) + (helper (+ 1 i)) + ) + ) + ) + ) + ) + ) + ) + (helper 0) + ) + ) + ) + + +(define set-channel-neutral + (lambda (ch width) + (letrec ((ch-name (string-append ch ".d")) + (helper + (lambda (i) + (cond + ((=? i width) #t) + (#t (let ((tmp (dualrail-bit ch-name i))) + (begin + (set (car tmp) 0) + (set (cadr tmp) 0) + (helper (+ 1 i)) + ) + ) + ) + ) + ) + )) + (helper 0) + ) + ) + ) + +(define set-channel-valid + (lambda (ch width val) + (letrec ((ch-name (string-append ch ".d")) + (helper + (lambda (i v) + (cond + ((=? i width) #t) + (#t (let ((tmp (dualrail-bit ch-name i))) + (begin + (set (car tmp) (- 1 (% v 2))) + (set (cadr tmp) (% v 2)) + (helper (+ 1 i) (truncate (/ v 2))) + ) + ) + ) + ) + ) + )) + (helper 0 val) + ) + ) + ) + +(define assert-var-bool (lambda (x v) (assert-var-int x 1 v))) + diff --git a/test/unit_tests/init_qdi.prsim b/test/unit_tests/init_qdi.prsim new file mode 100644 index 0000000..6fb4c18 --- /dev/null +++ b/test/unit_tests/init_qdi.prsim @@ -0,0 +1,11 @@ +initialize +load-scm "helper.scm" +random +set GND 0 +set Vdd 1 + +mode reset +set Reset 1 +cycle +status U +