diff options
Diffstat (limited to 'src')
37 files changed, 875 insertions, 805 deletions
diff --git a/src/LICENSE.txt b/src/LICENSE.txt new file mode 100644 index 00000000..ad3748f7 --- /dev/null +++ b/src/LICENSE.txt @@ -0,0 +1,26 @@ +FIRRTL licence terms + +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. diff --git a/src/main/antlr4/FIRRTL.g4 b/src/main/antlr4/FIRRTL.g4 index e3e662ac..00a4c5de 100644 --- a/src/main/antlr4/FIRRTL.g4 +++ b/src/main/antlr4/FIRRTL.g4 @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ grammar FIRRTL; /*------------------------------------------------------------------ diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index a6bab96e..78360578 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,3 +1,29 @@ +<!-- +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +--> <configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> diff --git a/src/main/scala/firrtl/Compiler.scala b/src/main/scala/firrtl/Compiler.scala index 5c6b76ae..0bb7510f 100644 --- a/src/main/scala/firrtl/Compiler.scala +++ b/src/main/scala/firrtl/Compiler.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl diff --git a/src/main/scala/firrtl/DebugUtils.scala b/src/main/scala/firrtl/DebugUtils.scala index 8151e2a6..3f6d0af1 100644 --- a/src/main/scala/firrtl/DebugUtils.scala +++ b/src/main/scala/firrtl/DebugUtils.scala @@ -1,4 +1,29 @@ -// Private implicit classes and other utility functions for debugging +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl diff --git a/src/main/scala/firrtl/Driver.scala b/src/main/scala/firrtl/Driver.scala index 69eb163c..c2dc0b59 100644 --- a/src/main/scala/firrtl/Driver.scala +++ b/src/main/scala/firrtl/Driver.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl import java.io._ diff --git a/src/main/scala/firrtl/Emitter.scala b/src/main/scala/firrtl/Emitter.scala index a3b42695..c7bf45a2 100644 --- a/src/main/scala/firrtl/Emitter.scala +++ b/src/main/scala/firrtl/Emitter.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl diff --git a/src/main/scala/firrtl/IR.scala b/src/main/scala/firrtl/IR.scala index 39a5b068..5d6a6862 100644 --- a/src/main/scala/firrtl/IR.scala +++ b/src/main/scala/firrtl/IR.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl diff --git a/src/main/scala/firrtl/Parser.scala b/src/main/scala/firrtl/Parser.scala index 41426357..6e93e7e6 100644 --- a/src/main/scala/firrtl/Parser.scala +++ b/src/main/scala/firrtl/Parser.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl import org.antlr.v4.runtime._; diff --git a/src/main/scala/firrtl/Passes.scala b/src/main/scala/firrtl/Passes.scala index babe18d0..ac41cdf1 100644 --- a/src/main/scala/firrtl/Passes.scala +++ b/src/main/scala/firrtl/Passes.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl diff --git a/src/main/scala/firrtl/PrimOps.scala b/src/main/scala/firrtl/PrimOps.scala index c4884ff6..53d87b30 100644 --- a/src/main/scala/firrtl/PrimOps.scala +++ b/src/main/scala/firrtl/PrimOps.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl diff --git a/src/main/scala/firrtl/Translator.scala b/src/main/scala/firrtl/Translator.scala index 7b88e0e0..1ca20346 100644 --- a/src/main/scala/firrtl/Translator.scala +++ b/src/main/scala/firrtl/Translator.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ /* TODO * - Add support for comments (that being said, current Scopers regex should ignore commented lines) diff --git a/src/main/scala/firrtl/Utils.scala b/src/main/scala/firrtl/Utils.scala index afd73bf0..251ae7b2 100644 --- a/src/main/scala/firrtl/Utils.scala +++ b/src/main/scala/firrtl/Utils.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ // Utility functions for FIRRTL IR /* TODO diff --git a/src/main/scala/firrtl/Visitor.scala b/src/main/scala/firrtl/Visitor.scala index 3fe8c176..5204ce8e 100644 --- a/src/main/scala/firrtl/Visitor.scala +++ b/src/main/scala/firrtl/Visitor.scala @@ -1,4 +1,30 @@ /* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ +/* * TODO * - Implement UBits and SBits * - Get correct line number for memory field errors diff --git a/src/main/scala/firrtl/WIR.scala b/src/main/scala/firrtl/WIR.scala index 61657879..9c7b85ee 100644 --- a/src/main/scala/firrtl/WIR.scala +++ b/src/main/scala/firrtl/WIR.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl diff --git a/src/main/scala/firrtl/passes/Checks.scala b/src/main/scala/firrtl/passes/Checks.scala index 4e3f8577..0a07fdcb 100644 --- a/src/main/scala/firrtl/passes/Checks.scala +++ b/src/main/scala/firrtl/passes/Checks.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl.passes diff --git a/src/main/scala/firrtl/passes/Passes.scala b/src/main/scala/firrtl/passes/Passes.scala index 18217445..e8a2106c 100644 --- a/src/main/scala/firrtl/passes/Passes.scala +++ b/src/main/scala/firrtl/passes/Passes.scala @@ -1,3 +1,29 @@ +/* +Copyright (c) 2014 - 2016 The Regents of the University of +California (Regents). All Rights Reserved. Redistribution and use in +source and binary forms, with or without modification, are permitted +provided that the following conditions are met: + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + two paragraphs of disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the Regents nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. +IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. +*/ package firrtl.passes diff --git a/src/main/stanza/bigint.stanza b/src/main/stanza/bigint.stanza deleted file mode 100644 index bc13bdbf..00000000 --- a/src/main/stanza/bigint.stanza +++ /dev/null @@ -1,402 +0,0 @@ -defpackage bigint : - import core - import verse - -val val-n-bytes = 4 -val val-n-bits = val-n-bytes * 8 -val val-all-ones = -1 ;; TODO -val val-n-half-bits = 32 / 2 -defn val-n-words (nbits: Int) -> Int : 1 + (nbits - 1) / 32 -defn val-n-half-words (nbits: Int) -> Int : (1 + (nbits - 1)) / val-n-half-bits -defn val-top-bit (v: Int) -> Int : v >> (32 - 1) -defn val-n-full-words (nbits: Int) -> Int : nbits / 32 -defn val-n-word-bits (nbits: Int) -> Int : nbits % 32 -defn mask-val (n: Int) : -1 >> (32 - n) - -public defclass BigInt <: Gettable & Settable & Lengthable -public defmulti to-bin (b: BigInt) -> String -public defmulti to-hex (b: BigInt) -> String -public defmulti num-words (b: BigInt) -> Int -public defmulti dat (b: BigInt) -> Array<Int> -public defn BigInt (len: Int) : - val d = Array<Int>(val-n-words(len)) - new BigInt : - defmethod get (this, i: Int) -> Int : d[i] - defmethod set (this, i: Int, x: Int) : d[i] = x & -1 - defmethod dat (this) -> Array<Int> : d - defmethod length (this) -> Int : len - defmethod num-words (this) -> Int : length(d) - defmethod to-hex (this) -> String : - defn as-hex (i: Int) -> String : - val str = "0123456789abcdef" - substring(str,i,i + 1) - var str = "h" - ;println(to-bin(this)) - for i in 0 to len by 4 do : - val pos = len - 4 - i - ;println(pos) - val digit = (d[pos / 32] >> (pos % 32)) & 15 - ;println(digit) - val hex = as-hex(digit) - ;println(hex) - if str == "h" and hex == "0" and (i + 4 < len) : false - else : str = string-join([str hex]) - string-join([ "\"" str "\""]) - defmethod to-bin (this) -> String : - string-join $ - generate<Char> : - defn* loop (pos:Int) : - if (pos >= 0) : - yield(if (d[pos / 32] >> (pos % 32))&1 == 1: '1' else: '0') - loop(pos - 1) - loop(len - 1) - ;defmethod to-string (this) : string-join(["BigInt<" len ">(" to-bin(this) ")"]) - defmethod to-string (this) : to-hex(this) - -defmethod print (o:OutputStream, b:BigInt) : - print(o, to-string(b)) - -defn assert (cond:True|False, msg:String) : if not cond: error(msg) - -defn assert (cond:True|False) : assert(cond, "failure") - -;; loop macro with starting values - -;; defn map-range (s:Int, e:Int, f: (Int) -> False) : -;; for i in s to e do : f(i) - -defn map! (f: (Int, Int) -> Int, d: BigInt, s0: BigInt, s1: BigInt) -> BigInt : - ;; assert(length(d) == length(s0) and length(s0) == length(s1), - ;; string-join(["LENS != " num-words(d) " " num-words(s0) " " num-words(s1)])) - for i in 0 to num-words(d) do : - d[i] = f(s0[i], s1[i]) - d - -defn mask! (d: BigInt) -> BigInt : - val n-full-words = val-n-full-words(length(d)) - val n-word-bits = val-n-word-bits(length(d)) - for i in 0 to n-full-words do : - d[i] = -1 - for i in n-full-words to num-words(d) do : - d[i] = 0 - if n-word-bits > 0 : - d[n-full-words] = mask-val(n-word-bits) - d - -defn trim! (d:BigInt) -> BigInt : - val n-full-words = val-n-full-words(length(d)) - val n-word-bits = val-n-word-bits(length(d)) - if n-word-bits > 0 : - d[n-full-words] = d[n-full-words] & mask-val(n-word-bits) - d - -defn extract! (d:BigInt, s0:BigInt, e:Int, s:Int) -> BigInt : trim!(rsh!(d, s0, s)) - -public defn bits (s0:BigInt, e:Int, s:Int) -> BigInt : extract!(BigInt(e - s + 1), s0, e, s) - -public defn bit (s0:BigInt, s:Int) -> Int : - val wi = s / 32 - val bi = s % 32 - s0[wi] >> bi - -defn inject! (d:BigInt, s0:BigInt, f:BigInt, start:Int) -> BigInt : - val bw = length(f) - val msk = mask!(BigInt(bw)) - val msk-lsh = msk << start - val inv-msk-lsh = bit-invert!(msk-lsh, msk-lsh) - val f-lsh = f << start - (s0 & inv-msk-lsh) | f-lsh - -defn map! (f: (Int) -> Int, d: BigInt, s0: BigInt) -> BigInt : - ;; assert(length(d) == length(s0), string-join(["LENS != " num-words(d) " " num-words(s0)])) - for i in 0 to num-words(d) do : - d[i] = f(s0[i]) - d - -defn fill! (f: (Int) -> Int, b: BigInt) : - for i in 0 to num-words(b) do : - b[i] = f(i) - b - -public defmethod equal? (x:BigInt, y:BigInt) -> True|False : - val tf = - if num-words(x) != num-words(y) : - false - else : - var eq? = true - for i in 0 to num-words(x) do : - val e = (x[i] == y[i]) - ;if not e : ;println-all(["NOT-EQUAL " x " AND " y " i=" i " X[i] " x[i] " Y[i] " y[i]]) - eq? = eq? and e - eq? - ;println-all(["EQUAL? " x " AND " y " " tf]) - tf - -public defn less?! (diff:BigInt, x:BigInt, y:BigInt) -> True|False : - sub!(diff, x, y) - val-top-bit(diff[num-words(diff) - 1]) == 1 - -public defn less? (x:BigInt, y:BigInt) -> True|False : op(less?!, x, y) - -public defn less-eq?! (diff:BigInt, x:BigInt, y:BigInt) -> True|False : - sub!(diff, y, x) - val-top-bit(diff[num-words(diff) - 1]) == 0 - -public defn less-eq? (x:BigInt, y:BigInt) -> True|False : op(less-eq?!, x, y) - -public defn greater?! (diff:BigInt, x:BigInt, y:BigInt) -> True|False : not less-eq?!(diff, x, y) - -public defn greater? (x:BigInt, y:BigInt) -> True|False : op(greater?!, x, y) - -public defn greater-eq?! (diff:BigInt, x:BigInt, y:BigInt) -> True|False : not less?!(diff, x, y) - -public defn greater-eq? (x:BigInt, y:BigInt) -> True|False : op(greater-eq?!, x, y) - -defn as-digit (c: Char) -> Int : - index-of("0123456789abcdef", c) as Int - -public defn BigIntLit (f: (Int) -> Int, len: Int) : - fill!(f, BigInt(len)) - -public defn BigIntLit (x: Int, w: Int) : - fill!({_ + x}, BigInt(w)) - -public defn BigIntLit (x: Int) : BigIntLit(x, sizeof(x)) - -public defn BigIntLit (s: String) : BigIntLit(s, -1) - -public defn BigIntLit (s: String, w:Int) : - val base = s[0] - val shamt = if base == 'b': 1 else if base == 'h': 4 else: 2 - val digits = substring(s, 1) - val len = if w == -1: length(digits) * shamt else: w - val lit = BigInt(len) - ;; println-all(["BASE " base " SHAMT " shamt " DIGITS " digits]) - for i in 0 to num-words(lit) do : - lit[i] = 0 - for i in 0 to length(digits) do : - val off = (length(digits) - 1 - i) * shamt - val wi = off / 32 - val bi = off % 32 - lit[wi] = lit[wi] | (as-digit(digits[i]) << bi) - ;; println-all(["OFF " off " wi " wi " bi " bi " lit[wi] " lit[wi] " => " lit]) - ;; println-all(["RES = " lit]) - lit - -public defn sizeof (in: Int) -> Int : - max(1, ceil-log2(in + 1)) - -defn op (f:(BigInt, BigInt, BigInt) -> True|False, x:BigInt, y:BigInt) -> True|False : - f(BigInt(max(length(x), length(y))), x, y) - -defn op (f:(BigInt, BigInt, BigInt) -> BigInt, x:BigInt, y:BigInt) -> BigInt : - f(BigInt(max(length(x), length(y))), x, y) - -defn op (f:(BigInt, BigInt) -> BigInt, x:BigInt) -> BigInt : - f(BigInt(length(x)), x) - -defn int (x: True|False) -> Int : if x : 1 else : 0 - -public defn plus! (d: BigInt, s0: BigInt, s1: BigInt) -> BigInt : - var carry = false - for i in 0 to num-words(d) do : - d[i] = s0[i] + s1[i] + int(carry) - carry = ((s0[i] + s1[i]) < s0[i]) or (d[i] < int(carry)) - d - -public defn plus (x:BigInt, y:BigInt) -> BigInt : op(plus!, x, y) - -public defn cat! (d: BigInt, s0: BigInt, s1: BigInt) -> BigInt : - lsh!(d, s0, length(s1)) - ;; println-all([" LSH! " s0 " " length(s1) " => " d]) - for i in 0 to num-words(s1) do : - d[i] = d[i] | s1[i] - d - -public defn cat (x:BigInt, y:BigInt) -> BigInt : - ;; println-all(["> CAT " x " " y]) - val res = cat!(BigInt(length(x) + length(y)), x, y) - ;; println-all(["< CAT " x " " y " => " res]) - res - -public defn cat (args:Streamable<BigInt>) -> BigInt : - reduce(cat, args) - -public defn sub! (d: BigInt, s0: BigInt, s1: BigInt) -> BigInt : - var borrow = false - for i in 0 to num-words(d) do : - d[i] = s0[i] - s1[i] + int(borrow) - borrow = (s0[i] < (s0[i] - s1[i])) or (s0[i] - s1[i]) < d[i] - d - -public defn sub (x:BigInt, y:BigInt) -> BigInt : op(sub!, x, y) - -public defn neg! (d: BigInt, s0: BigInt) -> BigInt : - var borrow = false - for i in 0 to num-words(d) do : - d[i] = neg(s0[i]) - int(borrow) - borrow = (s0[i] > 0) or (d[i] > 0) - d - -public defn neg (x:BigInt) -> BigInt : op(neg!, x) - -public defn neg? (x:BigInt) -> True|False : - val nw = num-words(x) - val msb = x[nw - 1] >> (length(x) - nw * 32 - 1) - if msb == 0 : false - else : true - -public defn rsha! (d:BigInt, s0:BigInt, amount:Int) -> BigInt : - val w = length(s0) - val nw = num-words(d) - val n-shift-bits = amount % 32 - val n-shift-words = amount / 32 - val n-rev-shift-bits = 32 - n-shift-bits - val is-zero-carry = n-shift-bits == 0 - val msb = s0[nw - 1] >> (w - nw * 32 - 1) - var carry = 0; - - if msb == 0 : - for i in 0 to n-shift-words do : - d[nw - i - 1] = 0 - - defn* loopy (i:Int) : - if i >= n-shift-words : - val x = s0[i] - d[i - n-shift-words] = (x >> n-shift-bits) | carry - carry = if is-zero-carry: 0 else: x << n-rev-shift-bits - loopy(i - 1) - loopy(nw - 1) - - if msb != 0 : - val boundary = (w - amount) - - defn* loop (i:Int) : - if i >= 0 : - val idx = i * 32 - if idx > boundary : - d[i] = -1 - loop(i - 1) - else : - d[i] = d[i] | (-1 << (boundary - idx)) - d[nw - 1] = d[nw - 1] & (-1 >> ((nw - 1) * 32 - w)) - loop(nw - 1) - d - -public defn signed-shift-right (b:BigInt, n:Int) -> BigInt : rsha!(BigInt(length(b)), b, n) - -public defn rsh! (d:BigInt, s0:BigInt, amount:Int) -> BigInt : - val nw = num-words(d) - var carry = 0 - val n-shift-bits = amount % 32 - val n-shift-words = amount / 32 - val n-rev-shift-bits = 32 - n-shift-bits - val is-zero-carry = n-shift-bits == 0 - for i in 0 to n-shift-words do : - d[nw - i - 1] = 0 - defn* loop (i:Int) : - if i >= n-shift-words : - val x = s0[i] - d[i - n-shift-words] = (x >> n-shift-bits) | carry - carry = if is-zero-carry: 0 else: x << n-rev-shift-bits - loop(i - 1) - loop(nw - 1) - d - -public defn shift-right (b:BigInt, n:Int) -> BigInt : rsh!(BigInt(length(b)), b, n) - -public defn lsh! (d:BigInt, s0:BigInt, amount:Int) : - ;; println-all(["LSH " s0 " AMOUNT " amount " INTO BIGINT<" length(d) ">"]) - val n-shift-bits = amount % 32 - val n-shift-words = amount / 32 - val n-rev-shift-bits = 32 - n-shift-bits - val is-zero-carry = n-shift-bits == 0 - for i in 0 to num-words(d) do : - d[i] = 0 - var carry = 0; - ;; println-all(["LSH AMOUNT " amount " VNB " 32 " NSB " n-shift-bits " NSW " n-shift-words " NRSB " n-rev-shift-bits]) - for i in 0 to (num-words(d) - n-shift-words) do : - val x = if i >= num-words(s0) : 0 else: s0[i] - ;; println-all([" SHIFTING " (i + n-shift-words) " VAL " (x << n-shift-bits)]) - d[i + n-shift-words] = (x << n-shift-bits) | carry - carry = if is-zero-carry: 0 else: x >> n-rev-shift-bits - d - -public defn shift-left (b:BigInt, n:Int) -> BigInt : lsh!(BigInt(length(b) + n), b, n) - -;; defn mul! (d: BigInt, s0: BigInt, s1: BigInt, nb0: Int, nb1: Int) -> BigInt : -;; ;; Adapted from Hacker's Delight, from Knuth -;; var nbd = nb0 + nb1 -;; for i in 0 to val-n-words(nbd) do : -;; d[i] = 0 -;; -;; half-val-t* w = reinterpret-cast<half-val-t*>(d); -;; half-val-t* u = reinterpret-cast<half-val-t*>(s0); -;; half-val-t* v = reinterpret-cast<half-val-t*>(s1); -;; val m = val-n-half-words(nb0) -;; val n = val-n-half-words(nb1) -;; val p = val-n-half-words(nbd) -;; -;; for j in 0 to n do : -;; var k = 0 -;; for i in 0 to min(m, p - j) do : -;; val t = u[i] * v[j] + w[i + j] + k -;; w[i + j] = t -;; k = t >> val-n-half-bits() -;; if ((j + m) < p) -;; w[j + m] = k -;; d - -public defn bit-xor! (d: BigInt, s0: BigInt, s1: BigInt) : map!(bit-xor, d, s0, s1) - -public defn bit-xor (b0:BigInt, b1:BigInt) : op(bit-xor!, b0, b1) - -public defn bit-or! (d: BigInt, s0: BigInt, s1: BigInt) : map!(bit-or, d, s0, s1) - -public defn bit-or (b0:BigInt, b1:BigInt) : op(bit-or!, b0, b1) - -public defn bit-and! (d: BigInt, s0: BigInt, s1: BigInt) : map!(bit-and, d, s0, s1) - -public defn bit-and (b0:BigInt, b1:BigInt) : op(bit-and!, b0, b1) - -public defn bit-invert! (d: BigInt, s0: BigInt) : map!(bit-xor, d, s0, mask!(d)) - -public defn bit-invert (b0:BigInt) : op(bit-invert!, b0) - -defn check (msg:String, x:BigInt, e:BigInt) : - println-all([msg " " x " E " e " ? " x == e]) - -defn check (msg:String, x:BigInt) : - println-all([msg " " x]) - -;;; check("Ba ", BigIntLit({ _ }, 1)) -;;; check("Bb ", BigIntLit({ _ }, 16)) -;;; check("Bc ", BigIntLit({ _ }, 32)) -;;; check("Bd ", BigIntLit({ _ }, 48)) -;;; check("Be ", BigIntLit({ _ }, 64)) -;;; check("Bf ", BigIntLit({ _ }, 65)) -;;; check("B1 ", BigIntLit(1, 8)) -;;; check("B2 ", BigIntLit(2, 8)) -;;; check("B+ ", BigIntLit(3, 8) + BigIntLit(5, 8), BigIntLit(3 + 5, 8)) -;;; check("B- ", BigIntLit(5, 8) + BigIntLit(3, 8), BigIntLit(5 + 3, 8)) -;;; check("B| ", BigIntLit(5, 8) | BigIntLit(9, 8), BigIntLit(5 | 9, 8)) -;;; check("B& ", BigIntLit(5, 8) & BigIntLit(9, 8), BigIntLit(5 & 9, 8)) -;;; check("B^ ", BigIntLit(5, 8) ^ BigIntLit(9, 8), BigIntLit(5 ^ 9, 8)) -;;; check("B< ", BigIntLit(5, 8) << 1, BigIntLit(5 << 1, 9)) -;;; check("B< ", BigIntLit(5, 3) << 10, BigIntLit(5 << 1, 13)) -;;; check("B< ", BigIntLit(5, 3) << 32, BigIntLit(5 << 1, 38)) -;;; check("B< ", BigIntLit("b1010") << 1, BigIntLit(10 << 1, 5)) -;check("S1 ", BigIntLit("hfafa") << 16, BigIntLit("hfafa0000", 32)) -;check("S1 ", BigIntLit(1,32) , BigIntLit(1,32)) -;check("S1 ", BigIntLit(0,32) , BigIntLit(0,32)) -;;; check("B< ", BigIntLit(5, 3) << 64, BigIntLit(5 << 1, 67)) -;;; check("BN ", neg(BigIntLit(2, 8)), BigIntLit(-2, 8)) -;check("S2 ", BigIntLit("b11111010") << 8, BigIntLit("b1111101000000000", 16)) -;check("C1 ", cat(BigIntLit("b11111010", 8), BigIntLit("b10111100", 8)), BigIntLit("b1111101010111100", 16)) -;check("C3 ", cat(cat(BigIntLit("b1111"), BigIntLit("b1010")), cat(BigIntLit("b1011"), BigIntLit("b1100"))), BigIntLit("b1111101010111100", 16)) -;check("C4 ", cat([BigIntLit("b1111"), BigIntLit("b1010"), BigIntLit("b1011"), BigIntLit("b1100")]), BigIntLit("b1111101010111100", 16)) -;check("C5 ", BigIntLit("b101111001"), BigIntLit("b101111001")) -;check("C6 ", cat(BigIntLit("b1"), BigIntLit("b01111001")), BigIntLit("b101111001")) -;check("C7 ", cat(BigIntLit("b11101"), BigIntLit("b101111001")), BigIntLit("b11101101111001")) -;check("C8 ", cat([BigIntLit("b11"), BigIntLit("b101"), BigIntLit("b1011"), BigIntLit("b11001")]), BigIntLit("b11101101111001")) -;check("C0 ", bits(BigIntLit("b11101101111001"), 10, 1), BigIntLit("b0110111100")) diff --git a/src/main/stanza/bigint2.stanza b/src/main/stanza/bigint2.stanza index deae1313..e64cd9b6 100644 --- a/src/main/stanza/bigint2.stanza +++ b/src/main/stanza/bigint2.stanza @@ -1,3 +1,28 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. + defpackage bigint2 : import core import verse diff --git a/src/main/stanza/chirrtl.stanza b/src/main/stanza/chirrtl.stanza index 607dbc70..43e6d2d6 100644 --- a/src/main/stanza/chirrtl.stanza +++ b/src/main/stanza/chirrtl.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/chirrtl : import core import verse diff --git a/src/main/stanza/compilers.stanza b/src/main/stanza/compilers.stanza index 1e7e3066..663f28b2 100644 --- a/src/main/stanza/compilers.stanza +++ b/src/main/stanza/compilers.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/compiler : import core import verse diff --git a/src/main/stanza/custom-compiler.stanza b/src/main/stanza/custom-compiler.stanza index 908f70ff..95686189 100644 --- a/src/main/stanza/custom-compiler.stanza +++ b/src/main/stanza/custom-compiler.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. ;defpackage firrtl/custom-compiler : ; import core ; import verse diff --git a/src/main/stanza/custom-passes.stanza b/src/main/stanza/custom-passes.stanza index 65c5fa9b..089b9318 100644 --- a/src/main/stanza/custom-passes.stanza +++ b/src/main/stanza/custom-passes.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. ;defpackage firrtl/custom-passes : ; import core ; import verse diff --git a/src/main/stanza/errors.stanza b/src/main/stanza/errors.stanza index 4cc99049..6d702e9b 100644 --- a/src/main/stanza/errors.stanza +++ b/src/main/stanza/errors.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/errors : import core import verse diff --git a/src/main/stanza/firrtl-ir.stanza b/src/main/stanza/firrtl-ir.stanza index e6c242bf..fdb7659a 100644 --- a/src/main/stanza/firrtl-ir.stanza +++ b/src/main/stanza/firrtl-ir.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/ir2 : import core import verse diff --git a/src/main/stanza/firrtl-lexer.stanza b/src/main/stanza/firrtl-lexer.stanza index 9d50d8ab..1d119d00 100644 --- a/src/main/stanza/firrtl-lexer.stanza +++ b/src/main/stanza/firrtl-lexer.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/lexer : import core import core/stringeater diff --git a/src/main/stanza/firrtl-main.stanza b/src/main/stanza/firrtl-main.stanza index e77c712e..362961af 100644 --- a/src/main/stanza/firrtl-main.stanza +++ b/src/main/stanza/firrtl-main.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. #include<"core/stringeater.stanza"> #include<"core/macro-utils.stanza"> #include<"compiler/stz-algorithms.stanza"> diff --git a/src/main/stanza/firrtl-test-main.stanza b/src/main/stanza/firrtl-test-main.stanza index 39848088..4fcc9dee 100644 --- a/src/main/stanza/firrtl-test-main.stanza +++ b/src/main/stanza/firrtl-test-main.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. #include<"core/stringeater.stanza"> #include<"core/macro-utils.stanza"> #include<"compiler/stz-algorithms.stanza"> diff --git a/src/main/stanza/firrtl.stanza b/src/main/stanza/firrtl.stanza index 2320bc81..f51a13a6 100644 --- a/src/main/stanza/firrtl.stanza +++ b/src/main/stanza/firrtl.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/firrtl : import core import verse diff --git a/src/main/stanza/flo.stanza b/src/main/stanza/flo.stanza index 015da39a..ad04bb23 100644 --- a/src/main/stanza/flo.stanza +++ b/src/main/stanza/flo.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/flo : import core import verse diff --git a/src/main/stanza/ir-parser.stanza b/src/main/stanza/ir-parser.stanza index c0e52e45..6bbfa432 100644 --- a/src/main/stanza/ir-parser.stanza +++ b/src/main/stanza/ir-parser.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/parser : import core import verse diff --git a/src/main/stanza/ir-utils.stanza b/src/main/stanza/ir-utils.stanza index 22ee228b..a96d7503 100644 --- a/src/main/stanza/ir-utils.stanza +++ b/src/main/stanza/ir-utils.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/ir-utils : import core import verse diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index 97302711..d0182532 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/passes : import core import verse diff --git a/src/main/stanza/primop.stanza b/src/main/stanza/primop.stanza index 3d0b06a4..f6aa0de5 100644 --- a/src/main/stanza/primop.stanza +++ b/src/main/stanza/primop.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/primops : import core import verse diff --git a/src/main/stanza/symbolic-value.stanza b/src/main/stanza/symbolic-value.stanza index d8ca2024..3d073f1b 100644 --- a/src/main/stanza/symbolic-value.stanza +++ b/src/main/stanza/symbolic-value.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. defpackage firrtl/symbolic-value : import core import verse diff --git a/src/main/stanza/verilog.stanza b/src/main/stanza/verilog.stanza deleted file mode 100644 index 9040a8bd..00000000 --- a/src/main/stanza/verilog.stanza +++ /dev/null @@ -1,402 +0,0 @@ -defpackage firrtl/verilog : - import core - import verse - import firrtl/ir-utils - import firrtl/ir2 - -defn width! (w:Width) -> Long : - match(w) : - (w:IntWidth) : width(w) - (w) : error("Non-supported width type.") - -defn width! (t:Type) -> Long : - match(t) : - (t:UIntType) : width!(width(t)) - (t:SIntType) : width!(width(t)) - (t) : error("Non-supported type.") - -defn emit (w:Width) -> String : - match(w) : - (w:IntWidth) : - if width(w) >= to-long(1) : string-join $ ["[" width(w) - to-long(1) ":0]"] ;TODO check if need to special case 0 or 1 width wires - else : "" - - (w) : error("Non-supported width type.") - -defn remove-subfield-s (s:Stmt) -> Stmt : - defn remove-subfield-e (e:Expression) -> Expression : - match(map(remove-subfield-e,e)) : - (e:SubField) : - Ref(to-symbol $ string-join $ [emit(exp(e)) bundle-expand-delin name(e)],type(e)) - (e) : e - map{remove-subfield-e,_ } $ map(remove-subfield-s,s) - -defn get-width (t:Type) -> String : - match(t) : - (t:UIntType) : emit(width(t)) - (t:SIntType) : emit(width(t)) - (t:ClockType) : emit(IntWidth(1)) - (t) : error("Non-supported type.") - -defn get-name (e:Expression) -> Symbol : - match(e) : - (e:Ref) : name(e) - (e:SubField) : error("Shouldn't be here") - (e) : error("Shouldn't be here") - -defn escape (s:String) -> String : - val s* = Vector<String>() - add(s*,"\"");" - var percent = false - for c in s do : - if c == '\n' : - add(s*,"\\n") - else : - if c == 'x' and percent : - add(s*,"h") - else : add(s*,to-string(c)) - percent = c == '%' - add(s*,"\"");" - string-join(s*) -;============ Verilog Backend ============= - -defn emit-as-type (e:Expression,t:Type) -> String : - match(t) : - (t:UIntType) : emit(e) - (t:SIntType) : string-join(["$signed(" emit(e) ")"]) - -defn emit-signed-if-any (e:Expression,ls:List<Expression>) -> String : - var signed? = false - for x in ls do : - if type(x) typeof SIntType : signed? = true - if not signed? : emit(e) - else : - match(type(e)) : - (t:SIntType) : string-join(["$signed(" emit(e) ")"]) - (t:UIntType) : string-join(["$signed({1'b0," emit(e) "})"]) - -defn emit (e:Expression) -> String : - match(e) : - (e:Ref) : to-string $ name(e) - (e:UIntValue) : - val str = to-string(value(e)) - val out = substring(str,1,length(str) - 1) - string-join $ [width!(type(e)) "'" out] - (e:SIntValue) : ;string-join $ [width!(type(e)) "'s" value(e)] - val str = to-string(value(e)) - val out = substring(str,1,length(str) - 1) - string-join $ [width!(type(e)) "'s" out] - (e:SubField) : error(string-join(["Non-supported expression: " to-string(e)])) - (e:SubIndex) : error(string-join(["Non-supported expression: " to-string(e)])) - (e:DoPrim) : - ;val sargs = map(emit-as-type{_,type(e)},args(e)) - ;val xargs = map(emit-signed-if-any{_,args(e)},args(e)) - string-join $ switch {_ == op(e)} : - ADD-OP : [emit-signed-if-any(args(e)[0],args(e)) " + " emit-signed-if-any(args(e)[1],args(e))] - SUB-OP : [emit-signed-if-any(args(e)[0],args(e)) " - " emit-signed-if-any(args(e)[1],args(e))] - MUL-OP : [emit-signed-if-any(args(e)[0],args(e)) " * " emit-signed-if-any(args(e)[1],args(e)) ] - DIV-OP : [emit-signed-if-any(args(e)[0],args(e)) " / " emit-signed-if-any(args(e)[1],args(e)) ] - REM-OP : [emit-signed-if-any(args(e)[0],args(e)) " % " emit-signed-if-any(args(e)[1],args(e)) ] - QUO-OP : [emit-signed-if-any(args(e)[0],args(e)) " / " emit-signed-if-any(args(e)[1],args(e)) ] - REM-OP : [emit-signed-if-any(args(e)[0],args(e)) " % " emit-signed-if-any(args(e)[1],args(e)) ] - ADD-WRAP-OP : [emit-signed-if-any(args(e)[0],args(e)), " + " emit-signed-if-any(args(e)[1],args(e))] - SUB-WRAP-OP : [emit-signed-if-any(args(e)[0],args(e)), " - " emit-signed-if-any(args(e)[1],args(e))] - LESS-OP : [emit-signed-if-any(args(e)[0],args(e)) " < " emit-signed-if-any(args(e)[1],args(e))] - LESS-EQ-OP : [emit-signed-if-any(args(e)[0],args(e)) " <= " emit-signed-if-any(args(e)[1],args(e))] - GREATER-OP : [emit-signed-if-any(args(e)[0],args(e)) " > " emit-signed-if-any(args(e)[1],args(e))] - GREATER-EQ-OP : [emit-signed-if-any(args(e)[0],args(e)) " >= " emit-signed-if-any(args(e)[1],args(e))] - NEQUIV-OP : [emit-signed-if-any(args(e)[0],args(e)) " != " emit-signed-if-any(args(e)[1],args(e))] - EQUIV-OP : [emit-signed-if-any(args(e)[0],args(e)) " == " emit-signed-if-any(args(e)[1],args(e))] - NEQUAL-OP : [emit-signed-if-any(args(e)[0],args(e)) " != " emit-signed-if-any(args(e)[1],args(e))] - EQUAL-OP : [emit-signed-if-any(args(e)[0],args(e)) " == " emit-signed-if-any(args(e)[1],args(e))] - MUX-OP : - val en = emit(args(e)[0]) - [en " ? " emit-as-type(args(e)[1],type(e)) " : " emit-as-type(args(e)[2],type(e))] - PAD-OP : - val x = args(e)[0] - val w = width!(type(x)) - val diff = (to-long(consts(e)[0]) - w) - if w == to-long(0) : [ emit(x) ] - else : - if type(e) typeof SIntType : ["{{" diff "{" emit(x) "[" w - to-long(1) "]}}, " emit(x) " }"] - else : ["{{" diff "'d0 }, " emit(x) " }"] - AS-UINT-OP : - ["$unsigned(" emit(args(e)[0]) ")"] - AS-SINT-OP : - ["$signed(" emit(args(e)[0]) ")"] - DYN-SHIFT-LEFT-OP : [emit-as-type(args(e)[0],type(e)) " << " emit(args(e)[1])] - DYN-SHIFT-RIGHT-OP : - if type(e) typeof SIntType : [emit-as-type(args(e)[0],type(e)) " >>> " emit(args(e)[1])] - else : [emit-as-type(args(e)[0],type(e)) " >> " emit(args(e)[1])] - SHIFT-LEFT-OP : [emit-as-type(args(e)[0],type(e)) " << " consts(e)[0]] - SHIFT-RIGHT-OP : [emit(args(e)[0]) "[" width!(type(args(e)[0])) - to-long(1) ":" consts(e)[0] "]"] - ;if type(e) typeof SIntType : [emit-as-type(args(e)[0],type(e)) " >>> " consts(e)[0]] - ;else : [emit-as-type(args(e)[0],type(e)) " >> " consts(e)[0]] - NEG-OP : ["-{" emit-as-type(args(e)[0],type(e)) "}"] - CONVERT-OP : - match(type(args(e)[0])) : - (t:UIntType) : ["{1'b0," emit-as-type(args(e)[0],type(e)) "}"] - (t:SIntType) : [emit-as-type(args(e)[0],type(e))] - BIT-NOT-OP : ["~ " emit-as-type(args(e)[0],type(e))] - BIT-AND-OP : [emit-as-type(args(e)[0],type(e)) " & " emit-as-type(args(e)[1],type(e))] - BIT-OR-OP : [emit-as-type(args(e)[0],type(e)) " | " emit-as-type(args(e)[1],type(e))] - BIT-XOR-OP : [emit-as-type(args(e)[0],type(e)) " ^ " emit-as-type(args(e)[1],type(e))] - CONCAT-OP : ["{" emit-as-type(args(e)[0],type(e)) "," emit-as-type(args(e)[1],type(e)) "}"] - BIT-SELECT-OP : [emit(args(e)[0]) "[" consts(e)[0] "]"] - BITS-SELECT-OP : [emit(args(e)[0]) "[" consts(e)[0] ":" consts(e)[1] "]"] - BIT-AND-REDUCE-OP : - var v = emit-as-type(args(e)[0],type(e)) - for x in tail(args(e)) do : - v = concat(v, [" & " emit(x)]) - v - BIT-OR-REDUCE-OP : - var v = emit-as-type(args(e)[0],type(e)) - for x in tail(args(e)) do : - v = concat(v, [" | " emit(x)]) - v - BIT-XOR-REDUCE-OP : - var v = emit-as-type(args(e)[0],type(e)) - for x in tail(args(e)) do : - v = concat(v, [" ^ " emit(x)]) - v - (e) : - println(["Expression:" e]) - error("Unknown expression") - - -defn emit-module (m:InModule) : - - val body* = remove-subfield-s(body(m)) - - val vdecs = Vector<KeyValue<Symbol,Stmt>>() ; all declarations in order, to preserve ordering - val decs = HashTable<Symbol,Stmt>(symbol-hash) ; all declarations, for fast lookups - val cons = HashTable<Symbol,Expression>(symbol-hash) ; all connections - val ens = HashTable<Symbol,Expression>(symbol-hash) ; all enables - val simuls = HashTable<Symbol,Vector<Streamable>>(symbol-hash) - defn build-table (s:Stmt) -> False : - match(s) : - (s:DefWire|DefPoison|DefRegister|DefMemory|DefNode|DefInstance) : - add(vdecs,name(s) => s) - decs[name(s)] = s - (s:Conditionally) : - match(conseq(s)) : - (c:Connect) : - val n = get-name(loc(c)) - ens[n] = pred(s) - cons[n] = exp(conseq(s) as Connect) - (c:PrintfStmt) : - val my-clk-simuls = get?(simuls,get-name(clk(c)),Vector<Streamable>()) - add(my-clk-simuls,["if(" emit(pred(s)) ") begin"]) - add(my-clk-simuls,[" $fwrite(STDERR," string-join(List(escape(string(c)),map(emit,args(c))), ", ") ");"]) - add(my-clk-simuls,["end"]) - simuls[get-name(clk(c))] = my-clk-simuls - (c:StopStmt) : - val my-clk-simuls = get?(simuls,get-name(clk(c)),Vector<Streamable>()) - add(my-clk-simuls,["if(" emit(pred(s)) ") begin"]) - add(my-clk-simuls,[" $fdisplay(STDERR,\"" ret(c) "\");"]) - add(my-clk-simuls,[" $finish;"]) - add(my-clk-simuls,["end"]) - simuls[get-name(clk(c))] = my-clk-simuls - (s:PrintfStmt) : - val my-clk-simuls = get?(simuls,get-name(clk(s)),Vector<Streamable>()) - add(my-clk-simuls,["$fwrite(STDERR," string-join(List(escape(string(s)),map(emit,args(s))), ", ") ");"]) - simuls[get-name(clk(s))] = my-clk-simuls - (c:StopStmt) : - val my-clk-simuls = get?(simuls,get-name(clk(c)),Vector<Streamable>()) - add(my-clk-simuls,["$fdisplay(STDERR,\"" ret(c) "\");"]) - add(my-clk-simuls,["$finish;"]) - simuls[get-name(clk(c))] = my-clk-simuls - (s:Connect) : - val n = get-name(loc(s)) - cons[n] = exp(s) - (s:Begin) : do(build-table,s) - (s) : false - - build-table(body*) - - val wires = Vector<Streamable>() - val regs = Vector<Streamable>() - val inits = Vector<Streamable>() - val assigns = Vector<Streamable>() - val updates = HashTable<Symbol,Vector<Streamable>>(symbol-hash) - val insts = HashTable<Symbol,Symbol>(symbol-hash) ; inst -> module - val inst-ports = HashTable<Symbol,Vector<Streamable>>(symbol-hash) - - val sh = get-sym-hash(m) - val rand-value = "$random" ;"0" - defn rand-string (w:Long) -> String : string-join(["{" ((w + to-long(31)) / to-long(32)) "{" rand-value "}};"]) - - for x in vdecs do : - val sym = key(x) - match(value(x)) : - (s:DefPoison) : - add(regs,["reg " get-width(type(s)) " " sym ";"]) - add(inits,[sym " = " rand-string(width!(type(s)))]) - (s:DefWire) : - add(wires,["wire " get-width(type(s)) " " sym ";"]) - add(assigns,["assign " sym " = " emit(cons[sym]) ";"]) - (s:DefRegister) : - add(regs,["reg " get-width(type(s)) " " sym ";"]) - val my-clk-update = get?(updates,get-name(clock(s)),Vector<Streamable>()) - if key?(ens,sym) : - add(my-clk-update,["if(" emit(ens[sym]) ") begin"]) - val x = cons[sym] - val y = emit(x) - add(my-clk-update,[" " sym " <= " y ";"]) - add(my-clk-update,["end"]) - else : - add(my-clk-update,[sym " <= " emit(cons[sym]) ";"]) - updates[get-name(clock(s))] = my-clk-update - val w = width!(type(s)) - add(inits,[sym " = " rand-string(w)]) - (s:DefMemory) : - add(regs,["reg " get-width(type(s)) " " sym " [0:" size(s) - 1 "];"]) - add(inits,["for (initvar = 0; initvar < " size(s) "; initvar = initvar+1)"]) - add(inits,[" " sym "[initvar] = " rand-string(width!(type(s))) ]) - (s:DefNode) : - add(wires,["wire " get-width(type(value(s))) " " sym ";"]) - add(assigns,["assign " sym " = " emit(value(s)) ";"]) - (s:DefInstance) : - inst-ports[sym] = Vector<Streamable>() - insts[sym] = name(module(s) as Ref) - for f in fields(type(module(s)) as BundleType) do : - val n* = to-symbol $ string-join $ [sym bundle-expand-delin name(f)] - add(wires,["wire " get-width(type(f)) " " n* ";"]) - add(inst-ports[sym], ["." name(f) "( " n* " )"]) - if flip(f) == REVERSE : - add(assigns,["assign " n* " = " emit(cons[n*]) ";"]) - ;(s:DefAccessor) : - ; val mem-declaration = decs[name(source(s) as Ref)] as DefMemory - ; switch {_ == acc-dir(s)} : - ; READ : - ; if seq?(mem-declaration) : - ; val index* = Ref(firrtl-gensym(name(index(s) as Ref),sh),type(index(s))) - ; add(regs,[ "reg " get-width(type(index*)) " " name(index*) ";"]) ; register index for an additional cycle - - ; val w = width!(type(index*)) - ; add(inits,[name(index*) " = " rand-string(w)]) ; initialize registered index - - ; val my-clk-update = get?(updates,get-name(clock(mem-declaration)),Vector<Streamable>()) - ; add(my-clk-update,[name(index*) " <= " emit(index(s)) ";"]) ; register index - ; updates[get-name(clock(mem-declaration))] = my-clk-update - - ; ; emit read accessor - ; add(wires,["wire " get-width(type(source(s))) " " sym ";"]) - ; add(assigns,["assign " sym " = " emit(source(s)) "[" emit(index*) "];"]) - ; else : - ; ; emit read accessor - ; add(wires,["wire " get-width(type(source(s))) " " sym ";"]) - ; add(assigns,["assign " sym " = " emit(source(s)) "[" emit(index(s)) "];"]) - ; WRITE : - ; val my-clk-update = get?(updates,get-name(clock(mem-declaration)),Vector<Streamable>()) - ; if key?(ens,sym) : - ; add(my-clk-update,["if(" emit(ens[sym]) ") begin"]) - ; add(my-clk-update,[" " emit(source(s)) "[" emit(index(s)) "] <= " emit(cons[sym]) ";"]) - ; add(my-clk-update,["end"]) - ; else : - ; add(my-clk-update,[emit(source(s)) "[" emit(index(s)) "] <= " emit(cons[sym]) ";"]) - ; updates[get-name(clock(mem-declaration))] = my-clk-update - ; RDWR : - ; if seq?(mem-declaration) : - ; ; to make it sequential, register the index for an additional cycle - ; val index* = Ref(firrtl-gensym(name(index(s) as Ref),sh),type(index(s))) - ; add(regs,[ "reg " get-width(type(index*)) " " name(index*) ";"]) - ; val w = width!(type(index*)) - ; add(inits,[name(index*) " = " rand-string(w)]) - ; val my-clk-update = get?(updates,get-name(clock(mem-declaration)),Vector<Streamable>()) - ; add(my-clk-update,[name(index*) " <= " emit(index(s)) ";"]) - ; updates[get-name(clock(mem-declaration))] = my-clk-update - - ; ; emit read accessor - ; add(wires,["wire " get-width(type(source(s))) " " sym ";"]) - ; add(assigns,["assign " sym " = " emit(source(s)) "[" emit(index*) "];"]) - ; else : - ; ; emit read accessor - ; add(wires,["wire " get-width(type(source(s))) " " sym ";"]) - ; add(assigns,["assign " sym " = " emit(source(s)) "[" emit(index(s)) "];"]) - ; val my-clk-update = get?(updates,get-name(clock(mem-declaration)),Vector<Streamable>()) - ; if key?(ens,sym) : - ; add(my-clk-update,["if(" emit(ens[sym]) ") begin"]) - ; add(my-clk-update,[" " emit(source(s)) "[" emit(index(s)) "] <= " emit(cons[sym]) ";"]) - ; add(my-clk-update,["end"]) - ; else : - ; add(my-clk-update,[emit(source(s)) "[" emit(index(s)) "] <= " emit(cons[sym]) ";"]) - ; updates[get-name(clock(mem-declaration))] = my-clk-update - - ;==== Actually printing module ===== - val port-indent = " " - print-all(["module " name(m) "(\n"]) - for (p in ports(m),i in 1 to false) do : - var end = ",\n" - if length(ports(m)) == i : - end = "\n);\n" - switch {_ == direction(p)} : - INPUT : - print-all([port-indent "input " get-width(type(p)) " " name(p) end]) - OUTPUT : - print-all([port-indent "output " get-width(type(p)) " " name(p) end]) - add(assigns,["assign " name(p) " = " emit(cons[name(p)]) ";"]) - if length(ports(m)) == 0 : print(");\n") - - if length(simuls) != 0 : print-all([" integer STDERR = 32'h80000002;\n"]) - - for w in wires do : - print(" ") - println-all(w) - for r in regs do : - print(" ") - println-all(r) - - if length(inits) != 0 : - println("`ifndef SYNTHESIS") - println(" integer initvar;") - println(" initial begin") - println(" #0.002;") - for i in inits do : - print-all(" ") - println-all(i) - println(" end") - println("`endif") - - for a in assigns do : - print(" ") - println-all(a) - - for x in insts do : - println-all([" " value(x) " " key(x) " ("]) - ;print-all([".clk( clk )"]) - for (y in inst-ports[key(x)],i in 1 to false) do : - print(" ") - print-all(y) - if length(inst-ports[key(x)]) != i : - print(",\n") - println("\n );") - - for x in updates do : - if length(value(x)) != 0 : - println-all([" always @(posedge " key(x) ") begin"]) - for u in value(x) do : - print(" ") - println-all(u) - println(" end") - - for x in simuls do : - if length(value(x)) != 0 : - println("`ifndef SYNTHESIS") - println-all([" always @(posedge " key(x) ") begin"]) - for u in value(x) do : - print(" ") - println-all(u) - println(" end") - println("`endif") - - println("endmodule") - - -public defn emit-verilog (with-output:(() -> False) -> False, c:Circuit) : - with-output $ fn () : - for m in modules(c) do : - match(m) : - (m:InModule) : emit-module(m) - (m:ExModule) : false - c diff --git a/src/main/stanza/widthsolver.stanza b/src/main/stanza/widthsolver.stanza index 2b967f44..b3f72f03 100644 --- a/src/main/stanza/widthsolver.stanza +++ b/src/main/stanza/widthsolver.stanza @@ -1,3 +1,27 @@ +;Copyright (c) 2014 - 2016 The Regents of the University of +;California (Regents). All Rights Reserved. Redistribution and use in +;source and binary forms, with or without modification, are permitted +;provided that the following conditions are met: +; * Redistributions of source code must retain the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer. +; * Redistributions in binary form must reproduce the above +; copyright notice, this list of conditions and the following +; two paragraphs of disclaimer in the documentation and/or other materials +; provided with the distribution. +; * Neither the name of the Regents nor the names of its contributors +; may be used to endorse or promote products derived from this +; software without specific prior written permission. +;IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +;SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, +;ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF +;REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +;LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF +;ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION +;TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +;MODIFICATIONS. ;Define the STANDALONE flag to run STANDALONE #if-defined(STANDALONE) : #include<"core/stringeater.stanza"> |
