URL
https://opencores.org/ocsvn/lattice6502/lattice6502/trunk
Subversion Repositories lattice6502
Compare Revisions
- This comparison shows the changes necessary to convert path
/lattice6502
- from Rev 1 to Rev 2
- ↔ Reverse comparison
Rev 1 → Rev 2
/doc/Readme.odt
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
doc/Readme.odt
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: doc/COPYING.LESSER
===================================================================
--- doc/COPYING.LESSER (nonexistent)
+++ doc/COPYING.LESSER (revision 2)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser 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.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
doc/COPYING.LESSER
Property changes :
Added: svn:executable
Index: doc/Readme.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: doc/Readme.pdf
===================================================================
--- doc/Readme.pdf (nonexistent)
+++ doc/Readme.pdf (revision 2)
doc/Readme.pdf
Property changes :
Added: svn:executable
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: doc/COPYING
===================================================================
--- doc/COPYING (nonexistent)
+++ doc/COPYING (revision 2)
@@ -0,0 +1,675 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ 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
+them 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.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. 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.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU 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.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ 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.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+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.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ 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.
+
+ 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
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ 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 3 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, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program 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.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+ .
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
+
doc/COPYING
Property changes :
Added: svn:executable
Index: ispLeaver/65C02.vhd
===================================================================
--- ispLeaver/65C02.vhd (nonexistent)
+++ ispLeaver/65C02.vhd (revision 2)
@@ -0,0 +1,3338 @@
+------------------------------------------------------------------
+-- 6502 principal module.
+--
+-- Copyright Ian Chapman October 28 2010
+--
+-- This file is part of the Lattice 6502 project
+-- It is used to compile with Linux ghdl and ispLeaver.
+--
+--
+-- To do
+-- Detailed test of all instructions.
+--
+-- *************************************************************
+-- Distributed under the GNU Lesser General Public License. *
+-- This can be obtained from “www.gnu.org”. *
+-- *************************************************************
+-- 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 3 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, see
+--
+-- 65C02.vhd
+
+
+--- Purpose to test and exercise my VHLD skills
+---- I've decided not to support 65C02 instructions
+---- nor BCD arithmetic.
+---- I will make it run as fast as I can. Timing not per a real 6502
+---- Lattice EBI has clocked address inputs, so as not to add a cycle
+---- 6502 address outputs are not latched. The data output of the EBI ROM and
+---- RAM is not clocked.
+---- To maintain speed the 6502 address to ROM/RAM is not clocked and the data
+---- returned is not clocked by ROM/RAM. Structures of form address <= address + "1";
+---- cause a race condition. I had to store the address from the mux for
+---- INC type instructions ie read then write.
+----
+---- One boob I've just noticed jsr and pha in the 6502 work opposite to
+---- what I expected ie jsr decrements the stack and I inc it. I guess
+---- that was the way my first computer the SDS sigma 2 did it. I'll keep
+---- like that for now in case a bigger stack is needed. Oh no a sigma 2
+---- did not have a stack only L link register.
+----
+-- I used this to set the hold timing default "-exp parHoldLimit=999"
+-- Also path based placement on
+-- When generating a Lattice ROM/RAM untick latche outputs and use
+-- the *.mem file generated with my asm2rom.pl script.
+------------------------------------------------------------------------------------
+-- TO Do
+-- 1 DONE Update all address modes of cmp, cpx and cpy per #mode
+-- 2 DONE Add rol, ror, asl, lsr, per inc and dec
+-- 3 DONE Correct flags in all modes of item 2
+-- 4 Update the stack instructions, I've it pushing up not down.
+-- 5 Continue testing
+-- 6 DONE Get a kernel up to test each and every instruction
+-- 7 Test all instructions
+-- 7 Add the 65C02 stuff. I think the most needed is phx, phy, plx
+-- and ply are the most useful.
+------------------------------------------------------------------------------------
+
+library IEEE; --Use standard IEEE libs as recommended by Tristan.
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+entity P65C02 is
+
+Port (
+ clock: in std_logic;
+ reset : in std_logic;
+ data_wr: out unsigned(7 downto 0);
+ data_rd: in unsigned(7 downto 0);
+ proc_write: inout std_logic;
+ irq: in std_logic; --Active 0
+ nmi: in std_logic; --Neg transition.
+-- cycle_mark : out std_logic;
+-- add_hold : inout unsigned(15 downto 14);
+ address: inout unsigned(15 downto 0)
+ );
+end P65C02;
+
+architecture P65C02_architecture of P65C02 is
+------------------------------------------------------------------------
+-- Signal Declarations
+------------------------------------------------------------------------
+signal reg_pc : unsigned(15 downto 0);
+signal add_hold : unsigned(15 downto 0);
+signal reg_a : unsigned(8 downto 0);
+signal reg_x, reg_y, reg_s, reg_sp : unsigned(7 downto 0);
+signal Instruction_in, dat_in1, dat_in2, dat_out1, dat_out2 : unsigned(7 downto 0);
+signal n_fg, v_fg, b_fg, d_fg, i_fg, z_fg, v_ff : std_logic;
+signal cycle_ctr, add_fg : unsigned(3 downto 0);
+signal wr_ctr, flags_fg : unsigned(1 downto 0);
+
+
+signal reset_fg, irq_fg, nmi_fg, start_fg, pc_inc_fg, branch_fg: std_logic;
+signal pc_dec_fg, dat2pc_fg : std_logic;
+-- End of signal declarations
+
+begin --architecture
+-- =======================================================
+read_mem:process (clock, reset)
+begin
+if reset = '0' then
+ dat_in1 <= (others => '0');
+ dat_in2 <= (others => '0');
+ instruction_in <= (others => '0');
+
+ elsif rising_edge(clock) then
+ dat_in2 <= dat_in1;
+ dat_in1 <= data_rd;
+
+-- if cycle_ctr = x"0" and start_fg = '0' then
+ if cycle_ctr = x"0" then
+ if irq = '0' or nmi = '0' or (reset = '1' and reset_fg = '0') then
+ Instruction_in <= x"00";
+ else
+ Instruction_in <= data_rd;
+ end if;
+ end if;
+end if;
+end process read_mem;
+
+-- =======================================================
+Prog_ptr:process (clock, reset, pc_dec_fg)
+begin
+if reset = '0' then
+ reg_pc <= x"FFFC";
+ elsif rising_edge(clock) then
+ if dat2pc_fg = '1' then
+ reg_pc(15 downto 8) <= data_rd;
+ reg_pc(7 downto 0) <= dat_in1;
+
+ elsif (cycle_ctr = X"0" and not(irq = '0' or nmi = '0' )) or pc_inc_fg = '1' then
+ reg_pc <= reg_pc + x"0001";
+
+ elsif pc_dec_fg = '1' then
+ reg_pc <= reg_pc - x"0001";
+
+-- elsif cycle_ctr = x"0" and irq = '0' and i_fg = '0' then
+-- reg_pc <= reg_pc - x"0001";
+
+ elsif branch_fg = '1' then
+ reg_pc <= reg_pc + (dat_in1(7) & dat_in1(7) & dat_in1(7) & dat_in1(7) & dat_in1(7) & dat_in1(7) & dat_in1(7) & dat_in1(7) & dat_in1);
+ end if;
+end if;
+end process Prog_ptr;
+
+addressing:process (clock, reset, reg_PC, add_fg)
+begin
+if reset = '0' then
+address <= reg_pc;
+-- elsif rising_edge(clock) then
+ else
+
+ Case add_fg is
+ when x"0" =>
+ address <= reg_pc;
+ when x"1" => --Zero page
+ if proc_write = '0' then
+ address(7 downto 0) <= data_rd;
+ else
+ address(7 downto 0) <= dat_in1;
+ end if;
+ address(15 downto 8) <= x"00";
+ when x"2" => --Zero page, x
+ if proc_write = '0' then
+ address(7 downto 0) <= data_rd + reg_x;
+ else
+ address(7 downto 0) <= dat_in1 + reg_x;
+ end if;
+ address(15 downto 8) <= x"00";
+
+ when x"3" => --Zero page, y
+ if proc_write = '0' then
+ address(7 downto 0) <= data_rd + reg_y;
+ else
+ address(7 downto 0) <= dat_in1 + reg_y;
+ end if;
+ address(15 downto 8) <= x"00";
+ when x"4" => --Absolute Return sub etc
+ if proc_write = '0' then
+ address <= data_rd & dat_in1;
+ else
+ address <= dat_in1 & dat_in2;
+ end if;
+ when x"5" => --Absolute, x
+ if proc_write = '0' then
+ address <= data_rd & dat_in1 + reg_x;
+ else
+ address <= dat_in1 & dat_in2 + reg_x;
+ end if;
+ when x"6" => --Absolute, y
+ address <= (data_rd & dat_in1) + reg_y;
+
+ if proc_write = '0' then
+ address <= data_rd & dat_in1 + reg_y;
+ else
+ address <= dat_in1 & dat_in2 + reg_y;
+ end if;
+
+ when x"7" => --Stack pointer
+ address <= x"01" & reg_sp; --msb should be hex 01
+ when x"8" => --Reset 1st byte
+ address <= x"FFFC";
+ when x"9" => --IRQ and Break 1st byte
+ address <= x"FFFE";
+ when x"A" => --NMI and Break 1st byte
+ address <= x"FFFA";
+ when x"B" => --address + 1
+ address <= add_hold + "1";
+ when x"C" => --(zero),y
+ address(7 downto 0) <= dat_in1 + "1";
+ address(15 downto 8) <= x"00";
+ when x"D" => --(zero,x)
+ address(7 downto 0) <= dat_in1 + reg_x + "1";
+ address(15 downto 8) <= x"00";
+ when x"F" => --Hold address steady for INC etc
+-- address <= address;
+ address <= add_hold;
+ when others =>
+ address <= reg_pc;
+ end case;
+end if;
+end process addressing;
+
+hold_address:process(clock, reset, address)
+begin --hold address bus for inc type instructions.
+if reset = '0' then
+ add_hold <= (others => '0');
+elsif rising_edge(clock) then
+ add_hold <= address;
+end if;
+end process hold_address;
+
+memory_proc_write:process(clock, reset, wr_ctr)
+begin
+if reset = '0' then
+ data_wr <= (others => '0');
+ proc_write <= '0';
+elsif rising_edge(clock) then
+ proc_write <= wr_ctr(0) or wr_ctr(1);
+ if wr_ctr = "01" then
+ data_wr <= dat_out1;
+ elsif wr_ctr = "10" then
+ data_wr <= dat_out2;
+ else
+ data_wr <= x"22";
+ end if;
+end if;
+end process memory_proc_write;
+
+instruction_decode:process (clock, reset, irq, nmi)
+begin
+if reset = '0' then
+ cycle_ctr <= (others => '0');
+-- cycle_mark <= '0';
+ pc_inc_fg <= '0';
+ pc_dec_fg <= '0';
+ dat2pc_fg <= '0';
+ add_fg <= (others => '0');
+ branch_fg <= '0';
+ flags_fg <= (others => '0');
+ wr_ctr <= "00";
+ reg_a <= (others => '0');
+ reg_x <= (others => '0');
+ reg_y <= (others => '0');
+ reg_s <= (others => '0');
+ reg_sp <= (others => '0');
+ n_fg <= '0';
+ v_fg <= '0';
+ b_fg <= '0';
+ d_fg <= '0';
+ i_fg <= '0';
+ z_fg <= '0';
+ reset_fg <= '0';
+ start_fg <= '0';
+ v_ff <= '0';
+ nmi_fg <= '0';
+ irq_fg <= '0';
+ dat_out1 <= (others => '0');
+ dat_out2<= (others => '0');
+
+--elsif rising_edge(clock) and run_fg = '1' then
+elsif rising_edge(clock) then
+-- v_ff <= dat_out2(7); --Used to track the v_fg
+ reset_fg <= reset;
+
+-- This section is to get started
+ if reset = '1' and reset_fg = '0' then
+ start_fg <= '1';
+ wr_ctr <= "00";
+ add_fg <= x"8"; --get start up vectors FFFC FFFD
+ cycle_ctr <= x"5"; --Jump into cycle 5 add_fg <= x'8'
+-- end if;
+ else
+
+
+ case cycle_ctr is --cycle counter case
+ when x"0" =>
+
+-- cycle_mark <= '1';
+ if reset_fg = '1' and reset = '1' then
+
+ if flags_fg /= "00" then
+ n_fg <= dat_out2(7);
+ if dat_out2 = x"00" then
+ z_fg <= '1';
+ else
+ z_fg <= '0';
+ end if;
+ end if;
+ if flags_fg = "10" then
+ start_fg <= '0';
+ v_fg <= reg_a(7) xnor v_ff; --Add V_ff true overflow possible
+-- --Sub V_ff false underflow possible
+ end if;
+ flags_fg <= "00";
+ end if;
+
+ if irq = '0' and i_fg = '0' then
+ irq_fg <= '1';
+ b_fg <= '0';
+ pc_dec_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ elsif nmi = '0' and i_fg = '0' then
+ nmi_fg <= '1';
+ b_fg <= '0';
+ pc_dec_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+
+ case data_rd is
+
+-- ===========================================================================================
+ when x"48" => --PHA 1st part accumulator onto stack
+ wr_ctr <= "01";
+ dat_out1 <= reg_a(7 downto 0);
+ pc_dec_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"08" => --PHP 1st part status onto stack
+ wr_ctr <= "01";
+ dat_out1 <= n_fg & v_fg & '1' & b_fg & d_fg & i_fg & z_fg & reg_a(8);
+ pc_dec_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"68" => --PLA 1st part Pull Accumulator from Stack
+ reg_sp <= reg_sp - "1";
+ pc_dec_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"28" => --PLP 1st part pull old status from stack
+ reg_sp <= reg_sp - "1";
+ pc_dec_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"18" => --CLC clear carry
+ reg_a(8) <= '0';
+-- pc_dec_fg <= '1';
+ cycle_ctr <= x"0";
+
+ when x"38" => --SEC set carry
+ reg_a(8) <= '1';
+ cycle_ctr <= x"0";
+ when x"58" => --CLI Clear interrupt Disable Bit
+ i_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"78" => --SEI Set interrupt Disable Status
+ i_fg <= '1';
+ cycle_ctr <= x"0";
+ when x"88" => --DEY Decrement y reg
+ reg_y <= reg_y - "1";
+ flags_fg <= "01";
+ dat_out2 <= reg_y - "1";
+ cycle_ctr <= x"0";
+ when x"98" => --TYA transfer Y to A
+ reg_a(7 downto 0) <= reg_y;
+ flags_fg <= "01";
+ dat_out2 <= reg_y;
+ cycle_ctr <= x"0";
+ when x"A8" => --TAY transfer A to Y
+ reg_y <= reg_a(7 downto 0);
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0);
+ cycle_ctr <= x"0";
+ when x"B8" => --CLV clear overflow flag
+ v_fg <= '0';
+ pc_dec_fg <= '1';
+ cycle_ctr <= x"0";
+ when x"C8" => --INY increment Y reg
+ reg_y <= reg_y + x"1";
+ flags_fg <= "01";
+ dat_out2 <= reg_y + x"1";
+ cycle_ctr <= x"0";
+ when x"D8" => --CLD Clear decimnal flag
+ d_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"E8" => --INX increment X reg
+ reg_x <= reg_x + x"1";
+ flags_fg <= "01";
+ dat_out2 <= reg_x + x"1";
+ cycle_ctr <= x"0";
+ when x"F8" => --SLD Set decimnal flag
+ d_fg <= '1';
+ cycle_ctr <= x"0";
+ when x"2A" => --ROL A Rotate Left one bit 1st part.
+ reg_a(8 downto 1) <= reg_a(7 downto 0);
+ reg_a(0) <= reg_a(8);
+ dat_out2(7 downto 1) <= reg_a(6 downto 0);
+ dat_out2(0) <= reg_a(8);
+ flags_fg <= "01";
+ cycle_ctr <= x"0";
+ when x"6A" => --ROR A Rotateft right one bit 1st part.
+ reg_a(7 downto 0) <= reg_a(8 downto 1);
+ reg_a(8) <= reg_a(0);
+ dat_out2 <= reg_a(8 downto 1);
+ flags_fg <= "01";
+ cycle_ctr <= x"0";
+ when x"0A" => --ASL A Shift Left one bit 1st part.
+ reg_a <= reg_a(7 downto 0) & '0';
+ dat_out2 <= reg_a(6 downto 0) & '0';
+ flags_fg <= "01";
+ cycle_ctr <= x"0";
+ when x"4A" => --LSR A Logical Shift Right one bit 1st part.
+ reg_a(7 downto 0) <= '0' & reg_a(7 downto 1);
+ reg_a(8) <= reg_a(0);
+ dat_out2 <= '0' & reg_a(7 downto 1);
+ flags_fg <= "01";
+ cycle_ctr <= x"0";
+ when x"9A" => --TXS
+ reg_sp <= reg_x;
+ cycle_ctr <= x"0";
+ when x"AA" => --TAX
+ reg_x <= reg_a(7 downto 0);
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0);
+ cycle_ctr <= x"0";
+ when x"8A" => --TXA
+ reg_a(7 downto 0) <= reg_x;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0);
+ cycle_ctr <= x"0";
+ when x"BA" => --TSX
+ reg_x <= reg_sp;
+ flags_fg <= "01";
+ dat_out2 <= reg_sp;
+ cycle_ctr <= x"0";
+ when x"CA" => --DEX
+ reg_x <= reg_X - X"01";
+ flags_fg <= "01";
+ dat_out2 <= reg_x - X"01";
+ cycle_ctr <= x"0";
+-- =============================================================================================
+ when x"F0" => --BEQ branch true 1st part.
+ cycle_ctr <= cycle_ctr + "1";
+ when x"D0" => --BNE branch true 1st part.
+ cycle_ctr <= cycle_ctr + "1";
+ when x"10" => --BPL plus true 1st part.
+ cycle_ctr <= cycle_ctr + "1";
+ when x"30" => --BM1 negative true 1st part.
+ cycle_ctr <= cycle_ctr + "1";
+ when x"50" => --BVC overflow false 1st part.
+ cycle_ctr <= cycle_ctr + "1";
+ when x"70" => --BVS overflow true 1st part.
+ cycle_ctr <= cycle_ctr + "1";
+ when x"90" => --BCC carry false 1st part.
+ cycle_ctr <= cycle_ctr + "1";
+ when x"B0" => --BCS carry true 1st part.
+ cycle_ctr <= cycle_ctr + "1";
+
+-- =============================================================================================
+ when x"A2" => --LDX #. 1st partProto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"A9" => --LDA #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"09" => --ORA #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"29" => --AND #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"49" => --EOR #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"69" => --ADC #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"A0" => --LDY #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"C0" => --CPY #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"C9" => --CMP #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"E0" => --CPX #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"E9" => --SBC #. 1st part Proto imediate instruction
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+-- =============================================================================================
+ when x"84" => --STY zero 1st part proto
+ dat_out1 <= reg_y;
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"85" => --STA zero 1st part proto
+ dat_out1 <= reg_a(7 downto 0);
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"86" => --STX zero 1st part proto
+ dat_out1 <= reg_x;
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"94" => --STY zero, X 1st part proto
+ dat_out1 <= reg_y;
+ add_fg <= x"2";
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"95" => --STA zero, X 1st part proto
+ dat_out1 <= reg_a(7 downto 0);
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"96" => --STX zero, Y 1st part proto
+ dat_out1 <= reg_x;
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+
+-- ===============================================================================================
+
+ when x"A1" => --LDA (zero,x) 1st part proto
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"B1" => --LDA (zero),y 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"21" => --AND (zero,x) 1st part proto
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"31" => --AND (zero),y 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"41" => --EOR (zero,x) 1st part proto
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"51" => --EOR (zero),y 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"01" => --OR (zero,x) 1st part proto
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"11" => --OR (zero),y 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"61" => --ADC (zero,x) 1st part proto
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"71" => --ADC (zero),y 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"E1" => --SBC (zero,x) 1st part proto
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"F1" => --SBC (zero),y 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"C1" => --CMP (zero,x) 1st part proto
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"D1" => --CMP (zero),y 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"81" => --STA (zero,x) 1st part proto
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"91" => --STA (zero),y 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + "1";
+
+
+-- ==============================================================================================
+ when x"A5" => --LDA zero 1st part proto
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"A4" => --LDY zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"A6" => --LDX zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"B5" => --LDA zero,x 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"B4" => --LDY zero,x 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"B6" => --LDX zero,y 1st part
+ add_fg <= x"3";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"05" => --ORA zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"15" => --ORA zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"24" => --BIT zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"25" => --AND zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"26" => --ROL zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"35" => --AND zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"36" => --ROL zero,X 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"45" => --EOR zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"46" => --LSR zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"55" => --EOR zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+-- =========================================================================================
+ when x"E6" => --INC zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"56" => --LSR zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"65" => --ADC zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"66" => --ROR zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"75" => --ADC zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"76" => --ROR zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"C4" => --CPY zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"C5" => --CMP zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"C6" => --DEC zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"D5" => --CMP zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"D6" => --DEC zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"E4" => --CPX zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"E5" => --SBC zero 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"F5" => --SBC zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"F6" => --INC zero,X 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"06" => --ASL zero, 1st part
+ add_fg <= x"1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"16" => --ASL zero, x 1st part
+ add_fg <= x"2";
+ cycle_ctr <= cycle_ctr + x"1";
+-- ==============================================================================
+ when x"AD" => --LDA abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BD" => --LDA, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"B9" => --LDA, Y abs 1st part
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"2D" => --AND abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"3D" => --AND, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"39" => --AND, Y abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"0D" => --ORA abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"1D" => --ORA, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"19" => --ORA, Y abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"4D" => --EOR abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"5D" => --EOR, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"59" => --EOR, Y abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"6D" => --ADC abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"7D" => --ADC, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"79" => --ADC, Y abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"ED" => --SBC abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"FD" => --SBC, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"F9" => --SBC, Y abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"AE" => --LDX abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BE" => --LDX, y abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"AC" => --LDY abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BC" => --LDY, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"2C" => --BIT abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"CD" => --CMP abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"DD" => --CMP, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"D9" => --CMP, Y abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"EC" => --CPX abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"CC" => --CPY abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+--.........................................................................................
+ when x"8D" => --STA abs 1st part.
+ dat_out1 <= reg_a(7 downto 0);
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"9D" => --STA,x abs 1st part.
+ dat_out1 <= reg_a(7 downto 0);
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"99" => --STA, y abs 1st part.
+ dat_out1 <= reg_a(7 downto 0);
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"8E" => --STX abs 1st part.
+ dat_out1 <= reg_x;
+ cycle_ctr <= cycle_ctr + x"1";--
+ when x"8C" => --STY abs 1st part.
+ dat_out1 <= reg_y;
+ cycle_ctr <= cycle_ctr + x"1";
+--.........................................................................................
+
+ when x"EE" => --INC abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"FE" => --INC, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"CE" => --DEC abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"DE" => --DEC, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"2E" => --ROL abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"3E" => --ROL, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"6E" => --ROR abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"7E" => --ROR, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"4E" => --LSR abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"5E" => --LSR, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"0E" => --ASL abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"1E" => --ASL, x abs 1st part.
+ cycle_ctr <= cycle_ctr + x"1";
+-- ............................................................................
+-- ==============================================================================
+
+
+ when x"4C" => --JMP abs first part
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"6C" => --JMP indirect first part
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"20" => --JSR abs first part
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"60" => --RTS first part
+ reg_sp <= reg_sp - "1";
+ add_fg <= x"7";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"40" => --RTI 1st part pull old status from stack
+ reg_sp <= reg_sp - "1";
+ add_fg <= x"7";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"00" => --Break first part cyc 0
+ if irq_fg = '0' then --Start up, irq and nmi also use
+ b_fg <= '1'; --this set of logic.
+ else
+ b_fg <= '0';
+ end if;
+ pc_dec_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when others =>
+ cycle_ctr <= x"0";
+
+ end case; --Cycle 0
+ end if; --Initiated by nmi irq detection.
+
+
+-- End cycle 0 =========================================================
+
+
+ when x"1" =>
+-- cycle_mark <= '0';
+
+ case Instruction_in is
+-- ================================================================================================
+
+ when x"48" => --PHA 2nd part accumulator onto stack
+ pc_dec_fg <= '0';
+ add_fg <= x"7";
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"08" => --PHP 2nd part Status reg onto stack
+ pc_dec_fg <= '0';
+ add_fg <= x"7";
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"68" => --PLA 2nd part Pull Accumulator from Stack
+ add_fg <= x"7";
+ pc_dec_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"28" => --PLP 2nd part Pull Status from Stack
+ add_fg <= x"7";
+ pc_dec_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"F0" => --BEQ branch true 2nd part.
+ if z_fg = '1' then --Should work like a nop
+ branch_fg <= '1'; --branch true 1st part.
+ else
+ pc_inc_fg <= '1';
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"D0" => --BNE branch true 2nd part.
+ if z_fg = '0' then --Should work like a nop
+ branch_fg <= '1'; --branch true 1st part.
+ else
+ pc_inc_fg <= '1';
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"10" => --BPL plus true 2nd part.
+ if n_fg = '0' then --Should work like a nop
+ branch_fg <= '1'; --branch true 1st part.
+ else
+ pc_inc_fg <= '1';
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"30" => --BM1 negative true 2nd part.
+ if n_fg = '1' then --Should work like a nop
+ branch_fg <= '1'; --branch true 1st part.
+ else
+ pc_inc_fg <= '1';
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"50" => --BVC overflow false 2nd part.
+ if v_fg = '0' then --Should work like a nop
+ branch_fg <= '1'; --branch true 1st part.
+ else
+ pc_inc_fg <= '1';
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"70" => --BVS overflow true 2nd part.
+ if v_fg = '1' then --Should work like a nop
+ branch_fg <= '1'; --branch true 1st part.
+ else
+ pc_inc_fg <= '1';
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"90" => --BCC carry false 2nd part.
+ if reg_a(8) = '0' then --Should work like a nop
+ branch_fg <= '1'; --branch true 1st part.
+ else
+ pc_inc_fg <= '1';
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"B0" => --BCS carry true 2nd part.
+ if reg_a(8) = '1' then --Should work like a nop
+ branch_fg <= '1'; --branch true 1st part.
+ else
+ pc_inc_fg <= '1';
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+-- ================================================================================================
+
+ when x"A2" => --LDX #. 2nd part Proto imediate instruction
+ pc_inc_fg <= '0';
+ reg_x <= data_rd;
+-- flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"A9" => --LDA #. 2nd part Proto imediate instruction
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ flags_fg <= "01";
+ reg_a(7 downto 0) <= data_rd;
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"A0" => --LDY #
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ flags_fg <= "01";
+ reg_y <= data_rd;
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"09" => --ORA #
+ pc_inc_fg <= '0';
+ add_fg <= x"0";
+-- flags_fg <= "01";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ cycle_ctr <= x"0";
+ when x"29" => --AND # 2nd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ flags_fg <= "01";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ cycle_ctr <= x"0";
+ when x"49" => --EOR #
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ flags_fg <= "01";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) xor data_rd;
+ dat_out2 <= reg_a(7 downto 0) xor data_rd;
+ cycle_ctr <= x"0";
+ when x"69" => --ADC #
+ pc_inc_fg <= '0';
+ v_ff <= not reg_a(7) and not data_rd(7); --Pos+Pos=Overflow possible
+ flags_fg <= "10";
+ reg_a <= reg_a + ("0" & data_rd) + ("00000000" & reg_a(8));
+ dat_out2 <= reg_a(7 downto 0) + data_rd + ("0000000" & reg_a(8));
+ cycle_ctr <= x"0";
+ when x"E9" => --SBC # 2nd part
+ pc_inc_fg <= '0';
+ v_ff <= reg_a(7) and data_rd(7); --Neg-Neg=Underflow possible
+ flags_fg <= "10";
+ reg_a <= reg_a - ("0" & data_rd) - ("00000000" & reg_a(8));
+ dat_out2 <= reg_a(7 downto 0) - data_rd - ("0000000" & reg_a(8));
+ cycle_ctr <= x"0";
+
+ when x"C9" => --CMP # 2nd part.
+ pc_inc_fg <= '0';
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd;
+ if reg_a(7 downto 0) > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ cycle_ctr <= x"0";
+ when x"E0" => --CPX #.
+ pc_inc_fg <= '0';
+ flags_fg <= "01";
+ dat_out2 <= reg_x - data_rd;
+ if reg_x > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ cycle_ctr <= x"0";
+ when x"C0" => --CPY #.
+ pc_inc_fg <= '0';
+ flags_fg <= "01";
+ dat_out2 <= reg_y - data_rd;
+ if reg_y > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ cycle_ctr <= x"0";
+
+-- ===================================================================================================
+ when x"84" => --STY zero 2nd part proto
+ add_fg <= x"1";
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"85" => --STA zero 2nd part proto
+ add_fg <= x"1";
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"86" => --STX zero 2nd part proto
+ add_fg <= x"1";
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"94" => --STY zero, X 2nd part proto
+ add_fg <= x"2";
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"95" => --STA zero, X 2nd part proto
+ add_fg <= x"2";
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"96" => --STX zero, Y 2nd part proto
+ add_fg <= x"3";
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + "1";
+
+-- =================================================================================
+ when x"A5" => --LDA zero 2nd part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"A4" => --LDY zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"A6" => --LDX zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"B5" => --LDA zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"B4" => --LDY zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"B6" => --LDX zero,Y 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"05" => --ORA zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"15" => --ORA zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"24" => --BIT zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"25" => --AND zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"35" => --AND zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"45" => --EOR zero,Y 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"55" => --EOR zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"65" => --ADC zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"75" => --ADC zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"C4" => --CPY zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"C5" => --CMP zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"C6" => --DEC zero 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"D5" => --CMP zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"D6" => --DEC zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"E4" => --CPX zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"E5" => --SBC zero 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"F5" => --SBC zero,X 2nd part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+-- ===================================================================================
+ when x"E6" => --INC zero 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"F6" => --INC zero,X 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"46" => --LSR zero 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"56" => --LSR zero,X 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"66" => --ROR zero 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"76" => --ROR zero,X 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"26" => --ROL zero 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"36" => --ROL zero,X 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"06" => --ASL zero 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"16" => --ASL zero,X 2nd part
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+
+
+-- ==============================================================================
+ when x"A1" => --LDA (zero,x) 2nd part proto
+ add_fg <= x"D";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"B1" => --LDA (zero),y 2nd part proto
+ add_fg <= x"C";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"21" => --AND (zero,x) 2nd part proto
+ add_fg <= x"D";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"31" => --AND (zero),y 2nd part proto
+ add_fg <= x"C";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"41" => --EOR (zero,x) 2nd part proto
+ add_fg <= x"D";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"51" => --EOR (zero),y 2nd part proto
+ add_fg <= x"C";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"01" => --OR (zero,x) 2nd part proto
+ add_fg <= x"D";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"11" => --OR (zero),y 2nd part proto
+ add_fg <= x"C";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"61" => --ADC (zero,x) 2nd part proto
+ add_fg <= x"D";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"71" => --ADC (zero),y 2nd part proto
+ add_fg <= x"C";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"E1" => --SBC (zero,x) 2nd part proto
+ add_fg <= x"D";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"F1" => --SBC (zero),y 2nd part proto
+ add_fg <= x"C";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"C1" => --CMP (zero,x) 2nd part proto
+ add_fg <= x"D";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"D1" => --CMP (zero),y 2nd part proto
+ add_fg <= x"C";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"81" => --STA (zero,x) 2nd part proto
+ add_fg <= x"D";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"91" => --STA (zero),y 2nd part proto
+ add_fg <= x"C";
+ cycle_ctr <= cycle_ctr + "1";
+-- ==============================================================================
+ when x"AD" => --LDA abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BD" => --LDA, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"B9" => --LDA, Y abs 2nd part.
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"2D" => --AND abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"3D" => --AND, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"39" => --AND, Y abs 2nd part.
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"0D" => --ORA abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"1D" => --ORA, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"19" => --ORA, Y abs 2nd part.
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"4D" => --EOR abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"5D" => --EOR, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"59" => --EOR, Y abs 2nd part.
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"6D" => --ADC abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"7D" => --ADC, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"79" => --ADC, Y abs 2nd part.
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"ED" => --SBC abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"FD" => --SBC, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"F9" => --SBC, Y abs 2nd part.
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"AE" => --LDX abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BE" => --LDX, y abs 2nd part.
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"AC" => --LDY abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BC" => --LDY, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"2C" => --BIT abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"CD" => --CMP abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"DD" => --CMP, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"D9" => --CMP, Y abs 2nd part.
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"EC" => --CPX abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"CC" => --CPY abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+-- ...............................................................................
+ when x"8D" => --STA abs 2nd part.
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"9D" => --STA,x abs 2nd part.
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"99" => --STA, y abs 2nd part.
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"8E" => --STX abs 2nd part.
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"8C" => --STY abs 2nd part.
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+-- ........................................................................
+
+ when x"EE" => --INC abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"FE" => --INC, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"CE" => --DEC abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"DE" => --DEC, x abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"2E" => --ROL abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"3E" => --ROL, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"6E" => --ROR abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"7E" => --ROR, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"4E" => --LSR abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"5E" => --LSR, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"0E" => --ASL abs 2nd part.
+ add_fg <= x"4";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"1E" => --ASL, x abs 2nd part.
+ add_fg <= x"5";
+ cycle_ctr <= cycle_ctr + x"1";
+-- ............................................................................
+-- ==============================================================================
+ when x"4C" => --JMP abs 2nd part
+ pc_inc_fg <= '0';
+ dat2pc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"6C" => --JMP indirect 2nd part
+ add_fg <= x"4";
+ pc_inc_fg <= '0';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"20" => --JSR abs 2nd part
+ dat2pc_fg <= '1';
+ pc_inc_fg <= '0';
+ wr_ctr <= "10";
+-- add_fg <= x"7";
+ dat_out1 <= reg_pc(7 downto 0);
+ dat_out2 <= reg_pc(15 downto 8);
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"60" => --RTS second part
+ reg_sp <= reg_sp - "1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"40" => --RTI second part pull old status from stack
+ reg_sp <= reg_sp - "1";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"00" => --Break second part cyc 1
+ wr_ctr <= "01"; --put dat_out2 onto stack
+ dat_out1 <= reg_pc(15 downto 8);
+ add_fg <= x"7";
+ dat2pc_fg <= '0';
+ pc_dec_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when others =>
+ cycle_ctr <= cycle_ctr + x"1";
+ end case; --Cycle 1
+
+
+-- End cycle 1 =========================================================
+
+ when x"2" =>
+
+ case instruction_in(7 downto 0) is
+-- ====================================================================================
+
+ when x"48" => --PHA 3rd part accumulator onto stack
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ reg_sp <= reg_sp + "1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"08" => --PHP 3rd part Status reg onto stack
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ reg_sp <= reg_sp + "1";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"68" => --PLA 3rd part Pull Accumulator from Stack
+ pc_dec_fg <= '0';
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"28" => --PLP 3rd part Pull Status from Stack
+ pc_dec_fg <= '0';
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"F0" => --BEQ branch true 3rd part.
+ if branch_fg = '1' then
+ branch_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ end if;
+ when x"D0" => --BNE branch true 3rd part.
+ if branch_fg = '1' then
+ branch_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ end if;
+ when x"10" => --BPL plus true 3rd part.
+ if branch_fg = '1' then
+ branch_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ end if;
+ when x"30" => --BM1 negative true 3rd part.
+ if branch_fg = '1' then
+ branch_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ end if;
+ when x"50" => --BVC overflow false 3rd part.
+ if branch_fg = '1' then
+ branch_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ end if;
+ when x"70" => --BVS overflow true 3rd part.
+ if branch_fg = '1' then
+ branch_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ end if;
+ when x"90" => --BCC carry false 3rd part.
+ if branch_fg = '1' then
+ branch_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ end if;
+ when x"B0" => --BCS carry true 3rd part.
+ if branch_fg = '1' then
+ branch_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ else
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ end if;
+-- ====================================================================================
+ when x"84" => --STY zero 3rd part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"85" => --STA zero 3rd part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"86" => --STX zero 3rd part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"94" => --STY zero, X 3rd part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"95" => --STA zero, X 3rd part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"96" => --STX zero, Y 3rd part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+
+-- ========================================================================================
+ when x"A5" => --LDA zero 3rd part proto
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"A4" => --LDY zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_y <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"A6" => --LDX zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_x <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"B5" => --LDA zero,X 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"B4" => --LDY zero,X 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_y <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"B6" => --LDX zero,Y 3rd part
+ wr_ctr <= "00";
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_x <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"05" => --ORA zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) or data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) or data_rd;
+ cycle_ctr <= x"0";
+ when x"15" => --ORA zero,X 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) or data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) or data_rd;
+ cycle_ctr <= x"0";
+ when x"24" => --BIT zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ n_fg <= data_rd(7);
+ v_fg <= data_rd(6);
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ flags_fg <= "01";
+ cycle_ctr <= x"0";
+ when x"25" => --AND zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ cycle_ctr <= x"0";
+
+ when x"35" => --AND zero,X 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ cycle_ctr <= x"0";
+
+ when x"45" => --EOR zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) xor data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) xor data_rd;
+ cycle_ctr <= x"0";
+
+ when x"55" => --EOR zero,X 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= reg_a(7 downto 0) xor data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) xor data_rd;
+ cycle_ctr <= x"0";
+
+ when x"65" => --ADC zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a <= reg_a + ("0" & data_rd) + ("00000000" & reg_a(8));
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) + data_rd + ("0000000" & reg_a(8));
+ cycle_ctr <= x"0";
+
+ when x"75" => --ADC zero,X 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a <= reg_a + ("0" & data_rd) + ("00000000" & reg_a(8));
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) + data_rd + ("0000000" & reg_a(8));
+ cycle_ctr <= x"0";
+
+ when x"C4" => --CPY zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"C5" => --CMP zero 3rd part
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd;
+ if reg_a(7 downto 0) > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"C6" => --DEC zero 3rd part
+ dat_out1 <= data_rd - x"01";
+ dat_out2 <= data_rd - x"01";
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"D5" => --CMP zero,X 3rd part
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd;
+ if reg_a(7 downto 0) > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"D6" => --DEC zero,X 3rd part
+ pc_inc_fg <= '0';
+ add_fg <= x"0";
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= cycle_ctr + "1";
+ when x"E4" => --CPX zero 3rd part
+ pc_inc_fg <= '0';
+ add_fg <= x"0";
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= x"0";
+ when x"E5" => --SBC zero 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a <= reg_a - ("0" & data_rd) - ("00000000" & reg_a(8));
+ dat_out2 <= reg_a(7 downto 0) - data_rd - ("0000000" & reg_a(8));
+ flags_fg <= "01";
+ cycle_ctr <= x"0";
+
+
+ when x"F5" => --SBC zero,X 3rd part
+ pc_inc_fg <= '0';
+-- add_fg <= x"0";
+ reg_a <= reg_a - ('0' & data_rd) - ("00000000" & reg_a(8));
+ dat_out2 <= reg_a(7 downto 0) - data_rd - ("0000000" & reg_a(8));
+ flags_fg <= "01";
+ cycle_ctr <= x"0";
+
+ when x"E6" => --INC zero 3rd part
+ dat_out1 <= data_rd + x"01";
+ dat_out2 <= data_rd + x"01";
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"F6" => --INC zero,X 3rd part
+ dat_out1 <= data_rd + x"01";
+ dat_out2 <= data_rd + x"01";
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"66" => --ROR zero 3rd part
+ reg_a(8) <= data_rd(0);
+ dat_out1 <= reg_a(8) & data_rd(7 downto 1);
+ dat_out2 <= reg_a(8) & data_rd(7 downto 1);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"76" => --ROR zero,X 3rd part
+ reg_a(8) <= data_rd(0);
+ dat_out1 <= reg_a(8) & data_rd(7 downto 1);
+ dat_out2 <= reg_a(8) & data_rd(7 downto 1);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"26" => --ROL zero 3rd part
+ dat_out1(7 downto 1) <= data_rd(6 downto 0);
+ dat_out1(0) <= reg_a(8);
+ dat_out2(7 downto 1) <= data_rd(6 downto 0);
+ dat_out2(0) <= reg_a(8);
+ flags_fg <= "01";
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"36" => --ROL zero,X 3rd part
+ dat_out1(7 downto 1) <= data_rd(6 downto 0);
+ dat_out1(0) <= reg_a(8);
+ dat_out2(7 downto 1) <= data_rd(6 downto 0);
+ dat_out2(0) <= reg_a(8);
+ flags_fg <= "01";
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"46" => --LSR zero 3rd part
+ dat_out1 <= '0' & reg_a(7 downto 1);
+ dat_out2 <= '0' & reg_a(7 downto 1);
+ reg_a(8) <= data_rd(0);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"56" => --LSR zero,X 3rd part
+ dat_out1 <= '0' & reg_a(7 downto 1);
+ dat_out2 <= '0' & reg_a(7 downto 1);
+ reg_a(8) <= data_rd(0);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"06" => --ASL zero 3rd part
+ reg_a(8) <= data_rd(7);
+ dat_out1 <= data_rd(6 downto 0) & '0';
+ dat_out2 <= data_rd(6 downto 0) & '0';
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"16" => --ASL zero,X 3rd part
+ reg_a(8) <= data_rd(7);
+ dat_out1 <= data_rd(6 downto 0) & data_rd(0);
+ dat_out2 <= data_rd(6 downto 0) & data_rd(0);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+
+-- =============================================================================================
+ when x"A1" => --LDA (zero,x) 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"B1" => --LDA (zero),y 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"21" => --AMD (zero,x) 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"31" => --AND (zero),y 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"41" => --EOR (zero,x) 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"51" => --EOR (zero),y 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"01" => --OR (zero,x) 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"11" => --OR (zero),y 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"61" => --ADC (zero,x) 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"71" => --ADC (zero),y 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"E1" => --SBC (zero,x) 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"F1" => --SBC (zero),y 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"C1" => --CMP (zero,x) 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"D1" => --CMP (zero),y 3rd part proto
+ add_fg <= x"6";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"81" => --STA (zero,x) 3rd part proto
+ add_fg <= x"4";
+ wr_ctr <= "01";
+ dat_out1 <= reg_a(7 downto 0);
+ cycle_ctr <= cycle_ctr + "1";
+ when x"91" => --STA (zero),y 3rd part proto
+ add_fg <= x"6";
+ wr_ctr <= "01";
+ dat_out1 <= reg_a(7 downto 0);
+ cycle_ctr <= cycle_ctr + "1";
+-- ==============================================================================
+ when x"AD" => --LDA abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"BD" => --LDA, x abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"B9" => --LDA, Y abs 3rd part
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+
+ when x"2D" => --AND abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"3D" => --AND, x abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"39" => --AND, Y abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"0D" => --ORA abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"1D" => --ORA, x abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"19" => --ORA, Y abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"4D" => --EOR abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"5D" => --EOR, x abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"59" => --EOR, Y abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"6D" => --ADC abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"7D" => --ADC, x abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"79" => --ADC, Y abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"ED" => --SBC abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"FD" => --SBC, x abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"F9" => --SBC, Y abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"AE" => --LDX abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"BE" => --LDX, y abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"AC" => --LDY abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"BC" => --LDY, x abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"2C" => --BIT abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"CD" => --CMP abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"DD" => --CMP, x abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"D9" => --CMP, Y abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"EC" => --CPX abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"CC" => --CPY abs 3rd part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+-- ................................................................................
+ when x"8D" => --STA abs 3rd part.
+ wr_ctr <= "00";
+ add_fg <= x"4";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"9D" => --STA,x abs 3rd part.
+ wr_ctr <= "00";
+ add_fg <= x"5";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"99" => --STA, y abs 3rd part.
+ wr_ctr <= "00";
+ add_fg <= x"6";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"8E" => --STX abs 3rd part.
+ wr_ctr <= "00";
+ add_fg <= x"4";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+ when x"8C" => --STY abs 3rd part.
+ wr_ctr <= "00";
+ add_fg <= x"4";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+-- ................................................................................
+
+ when x"EE" => --INC abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"FE" => --INC, x abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"CE" => --DEC abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"DE" => --DEC, x abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"2E" => --ROL abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"3E" => --ROL, x abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"6E" => --ROR abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"7E" => --ROR, x abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"4E" => --LSR abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"5E" => --LSR, x abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"0E" => --ASL abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"1E" => --ASL, x abs 3rd part.
+ add_fg <= x"f";
+ cycle_ctr <= cycle_ctr + "1";
+-- ............................................................................
+-- ==============================================================================
+ when x"4C" => --JMP abs 3rd part
+ dat2pc_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"6C" => --JMP indirect 3rd part
+ add_fg <= x"B";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"20" => --JSR abs 3rd part
+ dat2pc_fg <= '0';
+ add_fg <= x"7";
+ wr_ctr <= "01";
+-- reg_sp <= reg_sp + "1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"60" => --RTS third part
+ dat2pc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"40" => --RTI 3rd part pull old status from stack
+ pc_dec_fg <= '0'; --Get 1st PC byte
+ n_fg <= data_rd(7); --cyc 6
+ v_fg <= data_rd(6);
+ b_fg <= data_rd(4);
+ d_fg <= data_rd(3);
+ i_fg <= data_rd(2);
+ z_fg <= data_rd(1);
+ reg_a(8) <= data_rd(0);
+ reg_sp <= reg_sp - "1";
+ dat2pc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"00" => --Break third part cyc 2
+ dat_out1 <= reg_pc(7 downto 0); --put dat_out1 onto stack set up dat_out2
+ reg_sp <= reg_sp + "1";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when others =>
+ cycle_ctr <= cycle_ctr + x"1";
+ end case; --Cycle 2
+
+------------------------------------------------------------------------
+-- Cycle 3 is for single byte instructions ie TAY
+ when x"3" =>
+
+
+
+ if instruction_in(7 downto 0) /= x"A2" and
+ (
+ instruction_in(3 downto 0) = x"3" or
+ instruction_in(3 downto 0) = x"7" or
+ instruction_in(3 downto 0) = x"B" or
+ instruction_in(3 downto 0) = x"F"
+ ) then --NOPs
+ cycle_ctr <= x"0";
+ pc_dec_fg <= '1';
+ else
+
+ case instruction_in(7 downto 0) is
+-- ======================================================================================
+ when x"84" => --STY zero 4th part proto
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"85" => --STA zero 4th part proto
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"86" => --STX zero 4th part proto
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"94" => --STY zero, X 4th part proto
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"95" => --STA zero, X 4th part proto
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"96" => --STX zero, Y 4th part proto
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+-- =======================================================================================
+
+
+ when x"08" => --PHP 4th part accumulator onto stack
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"48" => --PHA 4th part accumulator onto stack
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+
+ when x"68" => --PLA 4th part Pull Accumulator from Stack
+ reg_a(7 downto 0) <= data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"28" => --PLP 4th part Pull Status from Stack
+ n_fg <= data_rd(7);
+ v_fg <= data_rd(6);
+-- b_fg <= data_rd(4);
+ d_fg <= data_rd(3);
+ i_fg <= data_rd(2);
+ z_fg <= data_rd(1);
+ reg_a(8) <= data_rd(0);
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"F0" => --BEQ branch true 4th part.
+ branch_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"D0" => --BNE branch true 4th part.
+ branch_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"10" => --BPL plus true 4th part.
+ branch_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"30" => --BM1 negative true 4th part.
+ branch_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"50" => --BVC overflow false 4th part.
+ branch_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"70" => --BVS overflow true 4th part.
+ branch_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"90" => --BCC carry false 4th part.
+ branch_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"B0" => --BCS carry true 4th part.
+ branch_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+-- ======================================================================================
+
+ when x"E6" => --INC zero fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"F6" => --INC zero,X fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= x"0";
+ when x"C6" => --DEC zero fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"D6" => --DEC zero,X fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= x"0";
+
+ when x"26" => --ROL zero fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"36" => --ROL zero,X fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"66" => --ROR zero fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"76" => --ROR zero,X fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"06" => --ASL zero fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"16" => --ASL zero,X fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"46" => --LSR zero fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"56" => --LSR zero,X fourth part
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+--
+-- ==============================================================================
+ when x"AD" => --LDA abs 4th part.
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BD" => --LDA, x abs 4th part.
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"B9" => --LDA, Y abs 4th part
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+
+ when x"2D" => --AND abs 4th part.
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"3D" => --AND, x abs 4th part.
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"39" => --AND, Y abs 4th part.
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"0D" => --ORA abs 4th part.
+ reg_a(7 downto 0) <= reg_a(7 downto 0) or data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) or data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"1D" => --ORA, x abs 4th part.
+ reg_a(7 downto 0) <= reg_a(7 downto 0) or data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) or data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"19" => --ORA, Y abs 4th part.
+ reg_a(7 downto 0) <= reg_a(7 downto 0) or data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) or data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"4D" => --EOR abs 4th part.
+ reg_a(7 downto 0) <= reg_a(7 downto 0) xor data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) xor data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"5D" => --EOR, x abs 4th part.
+ reg_a(7 downto 0) <= reg_a(7 downto 0) xor data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) xor data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"59" => --EOR, Y abs 4th part.
+
+ reg_a(7 downto 0) <= reg_a(7 downto 0) xor data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) xor data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"6D" => --ADC abs 4th part.
+ reg_a <= reg_a + ("0" & data_rd) + ("00000000" & reg_a(8));
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) + data_rd + ("0000000" & reg_a(8));
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"7D" => --ADC, x abs 4th part.
+ reg_a <= reg_a + ("0" & data_rd) + ("00000000" & reg_a(8));
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) + data_rd + ("0000000" & reg_a(8));
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"79" => --ADC, Y abs 4th part.
+ reg_a <= reg_a + ("0" & data_rd) + ("00000000" & reg_a(8));
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) + data_rd + ("0000000" & reg_a(8));
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"ED" => --SBC abs 4th part.
+ reg_a <= reg_a - ("0" & data_rd) - ("00000000" & reg_a(8));
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd - ("0000000" & reg_a(8));
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"FD" => --SBC, x abs 4th part.
+ reg_a <= reg_a - ("0" & data_rd) - ("00000000" & reg_a(8));
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd - ("0000000" & reg_a(8));
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"F9" => --SBC, Y abs 4th part.
+ reg_a <= reg_a - ("0" & data_rd) - ("00000000" & reg_a(8));
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd - ("0000000" & reg_a(8));
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"AE" => --LDX abs 4th part.
+ reg_x <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+-- pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BE" => --LDX, y abs 4th part.
+ reg_x <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+-- pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"AC" => --LDY abs 4th part.
+ reg_y <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"BC" => --LDY, x abs 4th part.
+ reg_y <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+-- pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"2C" => --BIT abs 4th part.
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"CD" => --CMP abs 4th part.
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd;
+ if reg_a(7 downto 0) > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"DD" => --CMP, x abs 4th part.
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd;
+ if reg_a(7 downto 0) > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"D9" => --CMP, Y abs 4th part.
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd;
+ if reg_a(7 downto 0) > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"EC" => --CPX abs 4th part.
+ if reg_x = data_rd then
+ z_fg <= '1';
+ else
+ z_fg <= '0';
+ end if;
+ if reg_x >= data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ if reg_x < data_rd then
+ n_fg <= '1';
+ else
+ n_fg <= '0';
+ end if;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"CC" => --CPY abs 4th part.
+ if reg_y = data_rd then
+ z_fg <= '1';
+ else
+ z_fg <= '0';
+ end if;
+ if reg_y >= data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ if reg_y < data_rd then
+ n_fg <= '1';
+ else
+ n_fg <= '0';
+ end if;
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+-- .................................................................................
+ when x"8D" => --STA abs 4th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"9D" => --STA,x abs 4th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"99" => --STA, y abs 4th part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"8E" => --STX abs 4th part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"8C" => --STY abs 4th part.
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+-- ........................................................................
+
+ when x"EE" => --INC abs 4th part.
+ dat_out1 <= data_rd + x"01";
+ dat_out2 <= data_rd + x"01";
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"FE" => --INC, x abs 4th part.
+ dat_out1 <= data_rd + x"01";
+ dat_out2 <= data_rd + x"01";
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"CE" => --DEC abs 4th part.
+ dat_out1 <= data_rd - x"01";
+ dat_out2 <= data_rd - x"01";
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"DE" => --DEC, x abs 4th part.
+ dat_out1 <= data_rd - x"01";
+ dat_out2 <= data_rd - x"01";
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"2E" => --ROL abs 4th part.
+ dat_out1(7 downto 1) <= data_rd(6 downto 0);
+ dat_out1(0) <= reg_a(8);
+ dat_out2(7 downto 1) <= data_rd(6 downto 0);
+ dat_out2(0) <= reg_a(8);
+ flags_fg <= "01";
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"3E" => --ROL, x abs 4th part.
+ dat_out1(7 downto 1) <= data_rd(6 downto 0);
+ dat_out1(0) <= reg_a(8);
+ dat_out2(7 downto 1) <= data_rd(6 downto 0);
+ dat_out2(0) <= reg_a(8);
+ flags_fg <= "01";
+ wr_ctr <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"6E" => --ROR abs 4th part.
+ reg_a(8) <= data_rd(0);
+ dat_out1 <= reg_a(8) & data_rd(7 downto 1);
+ dat_out2 <= reg_a(8) & data_rd(7 downto 1);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"7E" => --ROR, x abs 4th part.
+ reg_a(8) <= data_rd(0);
+ dat_out1 <= reg_a(8) & data_rd(7 downto 1);
+ dat_out2 <= reg_a(8) & data_rd(7 downto 1);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"4E" => --LSR abs 4th part.
+ dat_out1 <= '0' & reg_a(7 downto 1);
+ dat_out2 <= '0' & reg_a(7 downto 1);
+ reg_a(8) <= data_rd(0);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"5E" => --LSR, x abs 4th part.
+ dat_out1 <= '0' & reg_a(7 downto 1);
+ dat_out2 <= '0' & reg_a(7 downto 1);
+ reg_a(8) <= data_rd(0);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"0E" => --ASL abs 4th part.
+ reg_a(8) <= data_rd(7);
+ dat_out1 <= data_rd(6 downto 0) & data_rd(0);
+ dat_out2 <= data_rd(6 downto 0) & data_rd(0);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"1E" => --ASL, x abs 4th part.
+ reg_a(8) <= data_rd(7);
+ dat_out1 <= data_rd(6 downto 0) & data_rd(0);
+ dat_out2 <= data_rd(6 downto 0) & data_rd(0);
+ wr_ctr <= "01";
+ flags_fg <= "01";
+ cycle_ctr <= cycle_ctr + x"1";
+-- ............................................................................
+-- ==============================================================================
+ when x"A1" => --LDA (zero,x) 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"B1" => --LDA (zero),y 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"21" => --AND (zero,x) 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"31" => --AND (zero),y 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"41" => --EOR (zero,x) 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"51" => --EOR (zero),y 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"01" => --OR (zero,x) 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"11" => --OR (zero),y 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+
+ when x"61" => --ADC (zero,x) 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"71" => --ADC (zero),y 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"E1" => --SBC (zero,x) 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"F1" => --SBC (zero),y 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"C1" => --CMP (zero,x) 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when x"D1" => --CMP (zero),y 4th part proto
+ add_fg <= x"0";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + "1";
+
+
+ when x"81" => --STA (zero,x) 4th part proto
+-- add_fg <= x"0";
+-- pc_inc_fg <= '1';
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + "1";
+ when x"91" => --STA (zero),y 4th part proto
+-- add_fg <= x"0";
+-- pc_inc_fg <= '1';
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + "1";
+-- ==================================================================================
+
+ when x"4C" => --JMP abs 4th part
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"6C" => --JMP abs 4th part
+ add_fg <= x"0";
+ dat2pc_fg <= '1';
+ pc_inc_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"20" => --JSR indirect 4th part
+-- add_fg <= x"0";
+ wr_ctr <= "00";
+ reg_sp <= reg_sp + "1";
+-- pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"60" => --RTS fourth part
+ dat2pc_fg <= '0';
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"40" => --RTI forth part
+-- reg_sp <= reg_sp - "1";
+ add_fg <= x"7"; --Get 2nd PC byte
+ dat2pc_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"00" => --Break forth extra part cyc 3
+ dat_out1 <= n_fg & v_fg & '1' & b_fg & d_fg & i_fg & z_fg & reg_a(8);
+ reg_sp <= reg_sp + "1";
+ cycle_ctr <= cycle_ctr + x"1";
+
+--------------------------------------------------------------------------------------
+ when others =>
+ cycle_ctr <= cycle_ctr + x"1";
+
+ end case; --Cycle 3
+ end if; --End single byte stuff
+
+-- End of cycle 3
+-- Cycle 4 is for 2 byte/cycle instructions ie LDA #
+--
+ when x"4" =>
+ case Instruction_in is
+-- ======================================================================================
+ when x"F0" => --BEQ branch true 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"D0" => --BNE branch true 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"10" => --BPL plus true 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"30" => --BM1 negative true 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"50" => --BVC overflow false 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"70" => --BVS overflow true 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"90" => --BCC carry false 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"B0" => --BCS carry true 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+-- ======================================================================================
+
+ when x"E6" => --INC zero 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"F6" => --INC zero,X 5th part
+ wr_ctr <= "00";
+ pc_inc_fg <= '0';
+ add_fg <= x"0";
+ cycle_ctr <= x"0";
+ when x"c6" => --DEC zero 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"46" => --LSR zero 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"56" => --LSR zero,X 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"66" => --ROR zero 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"76" => --ROR zero,X 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"26" => --ROL zero 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"36" => --ROL zero,X 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"06" => --ASL zero 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"16" => --ASL zero,X 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+
+
+--
+-- ======================================================================================
+ when x"AD" => --LDA 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"BD" => --LDA, x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"B9" => --LDA, Y 5th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"2D" => --AND 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"3D" => --AND, x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"39" => --AND, Y 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"0D" => --ORA 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"1D" => --ORA, x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"19" => --ORA, Y 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"4D" => --EOR 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"5D" => --EOR, x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"59" => --EOR, Y 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"6D" => --ADC 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"7D" => --ADC, x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"79" => --ADC, Y 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"ED" => --SBC 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"FD" => --SBC, x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"F9" => --SBC, Y 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"AE" => --LDX 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"BE" => --LDX, y 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"AC" => --LDY 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"BC" => --LDY, x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"2C" => --BIT 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"CD" => --CMP 5th part.
+ wr_ctr <= "10"; pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"DD" => --CMP, x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"D9" => --CMP, Y 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"EC" => --CPX 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"CC" => --CPY 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+-- ............................................................................
+ when x"8D" => --STA 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"9D" => --STA,x 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"99" => --STA, y 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"8E" => --STX 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"8C" => --STY 5th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+-- ............................................................................
+
+ when x"EE" => --INC abs 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"FE" => --INC, x 5th part.
+ wr_ctr <= "00";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"CE" => --DEC 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"DE" => --DEC, x 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"2E" => --ROL 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"3E" => --ROL, x 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"6E" => --ROR 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"7E" => --ROR, x 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"4E" => --LSR 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"5E" => --LSR, x 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"0E" => --ASL 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"1E" => --ASL, x 5th part.
+ wr_ctr <= "00";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+-- ............................................................................
+-- ==============================================================================
+ when x"A1" => --LDA (zero,x) 5th part proto
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"B1" => --LDA (zero),y 5th part proto
+ reg_a(7 downto 0) <= data_rd;
+ flags_fg <= "01";
+ dat_out2 <= data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"21" => --AND (zero,x) 5th part proto
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"31" => --AND (zero),y 5th part proto
+ reg_a(7 downto 0) <= reg_a(7 downto 0) and data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) and data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"42" => --EOR (zero,x) 5th part proto
+ reg_a(7 downto 0) <= reg_a(7 downto 0) xor data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) xor data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"51" => --EOR (zero),y 5th part proto
+ reg_a(7 downto 0) <= reg_a(7 downto 0) xor data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) xor data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"01" => --OR (zero,x) 5th part proto
+ reg_a(7 downto 0) <= reg_a(7 downto 0) or data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) or data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"11" => --OR (zero),y 5th part proto
+ reg_a(7 downto 0) <= reg_a(7 downto 0) or data_rd;
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) or data_rd;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"61" => --ADC (zero,x) 5th part proto
+ flags_fg <= "01";
+ reg_a <= reg_a + ("0" & data_rd) + ("00000000" & reg_a(8));
+ dat_out2 <= reg_a(7 downto 0) + data_rd + ("0000000" & reg_a(8));
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"71" => --ADC (zero),y 5th part proto
+ flags_fg <= "01";
+ reg_a <= reg_a + ("0" & data_rd) + ("00000000" & reg_a(8));
+ dat_out2 <= reg_a(7 downto 0) + data_rd + ("0000000" & reg_a(8));
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"E1" => --SBC (zero,x) 5th part proto
+ flags_fg <= "01";
+ reg_a <= reg_a - ("0" & data_rd) - ("00000000" & reg_a(8));
+ dat_out2 <= reg_a(7 downto 0) - data_rd - ("0000000" & reg_a(8));
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"F1" => --SBC (zero),y 5th part proto
+ flags_fg <= "01";
+ reg_a <= reg_a - ("0" & data_rd) - ("00000000" & reg_a(8));
+ dat_out2 <= reg_a(7 downto 0) - data_rd - ("0000000" & reg_a(8));
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"C1" => --CMP (zero,x) 5th part proto
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd;
+ if reg_a(7 downto 0) > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"D1" => --CMP (zero),y 5th part proto
+ flags_fg <= "01";
+ dat_out2 <= reg_a(7 downto 0) - data_rd;
+ if reg_a(7 downto 0) > data_rd then
+ reg_a(8) <= '1';
+ else
+ reg_a(8) <= '0';
+ end if;
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"81" => --STA (zero,x) 5th part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"91" => --STA (zero),y 5th part proto
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+-- ==============================================================================
+ when x"4C" => --JMP abs 5th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"6C" => --JMP indirect 5th part
+ pc_inc_fg <= '1';
+ dat2pc_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"20" => --JSR 5th part
+ pc_inc_fg <= '1';
+ add_fg <= x"0";
+ reg_sp <= reg_sp + "1";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"60" => --RTS fifth part
+ dat2pc_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"40" => --RTI fifth part
+-- reg_sp <= reg_sp + "1";
+ add_fg <= x"0";
+-- dat2pc_fg <= '0';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"00" => --Break fifth part cyc 4
+ wr_ctr <= "00";
+ reg_sp <= reg_sp + "1";
+ if nmi_fg = '0' then
+ add_fg <= x"9"; --Complete stacking start getting vector
+ else
+ add_fg <= x"A";
+ end if;
+ cycle_ctr <= cycle_ctr + x"1";
+
+
+ when others =>
+ cycle_ctr <= cycle_ctr + x"1";
+
+ end case; --Cycle 4
+-- end if;
+------------------------------------------------------------------------
+-- End of cycle 4
+-- Cycle 5 is for 3 byte instructions ie LDA abs
+
+ when x"5" =>
+ case Instruction_in is
+-- =========================================================================
+ when x"81" => --STA (zero,x) 6th part proto
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"91" => --STA (zero),y 6th part proto
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+
+-- ........................................................................................
+ when x"E6" => --INC zero 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"c6" => --dec zero 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"26" => --ROL zero 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"F6" => --INC zero,X 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"46" => --LSR zero 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"56" => --LSR zero,X 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"66" => --ROR zero 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"76" => --ROR zero,X 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"36" => --ROL zero,X 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"06" => --ASL zero 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"16" => --ASL zero,X 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+
+--==================================================
+
+
+ when x"EE" => --INC abs 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"FE" => --INC, x 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= x"0";
+ when x"CE" => --DEC 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"DE" => --DEC, x 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"2E" => --ROL 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"3E" => --ROL, x 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"6E" => --ROR 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"7E" => --ROR, x 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"4E" => --LSR 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"5E" => --LSR, x 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"0E" => --ASL 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+ when x"1E" => --ASL, x 6th part.
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+-- ........................................................................................
+ when x"6C" => --JMP indirect 6th part
+ pc_inc_fg <= '0';
+-- dat2pc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"60" => --RTS 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"40" => --RTI sixth part
+ cycle_ctr <= cycle_ctr + x"1";
+ pc_inc_fg <= '1';
+ cycle_ctr <= cycle_ctr + x"1";
+
+ when x"20" => --JSR 6th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"00" => --Break 6th part cyc 5
+ add_fg <= x"B";
+ irq_fg <= '0';
+ nmi_fg <= '0';
+ cycle_ctr <= cycle_ctr + "1";
+
+ when others =>
+-- cycle_ctr <= x"0";
+ cycle_ctr <= cycle_ctr + x"1";
+-- --get_inst_fg <= '0';
+ end case; --Cycle 5
+
+------------------------------------------------------------------------
+-- End of cycle 5
+-- Cycle 6 is for 3 byte instructions ie LDA abs
+
+ when x"6" =>
+ case Instruction_in is
+
+ when x"EE" => --INC abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"cE" => --DEC abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"2E" => --ROL abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"3E" => --ROL, x abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"6E" => --ROR abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"7E" => --ROR, x abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"4E" => --LSR abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"5E" => --LSR, x abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"0E" => --ASL abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+ when x"1E" => --ASL, x abs 7th part.
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+--=============================================================================
+
+ when x"40" => --RTI 7th part
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when x"00" => --Break 7th part cyc 6
+ dat2pc_fg <= '1';
+ add_fg <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+ when others =>
+ cycle_ctr <= x"0";
+ --get_inst_fg <= '0';
+
+
+ end case; --Cycle 6
+-- End of cycle 6
+
+
+-- Cycle 8 is for 3 byte instructions ie LDA abs
+
+ when x"7" =>
+ case Instruction_in is
+
+ when x"40" => --RTI 8th cyc
+ cycle_ctr <= x"0";
+
+ when x"00" => --Break 8th part cyc 7
+ if start_fg = '0' then --When starting don't mess with this
+ i_fg <= '1'; --Break irq and start use this logic.
+ end if;
+ pc_inc_fg <= '1';
+ start_fg <= '0';
+ dat2pc_fg <= '0';
+-- cycle_ctr <= x"0";
+ cycle_ctr <= cycle_ctr + "1";
+
+
+ when others =>
+ cycle_ctr <= x"0";
+ --get_inst_fg <= '0';
+
+ end case; --Cycle 7
+-- Cycle 7
+ when x"8" =>
+ case Instruction_in is
+
+ when x"00" => --Break 10th part cyc 8
+ pc_inc_fg <= '0';
+ cycle_ctr <= x"0";
+
+ when others =>
+ cycle_ctr <= cycle_ctr + "1";
+ pc_inc_fg <= '0';
+
+ end case; --Cycle 8
+-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+-- Cycle 9
+ when x"9" =>
+ case Instruction_in is
+
+ when others =>
+ cycle_ctr <= cycle_ctr + "1";
+ pc_inc_fg <= '0';
+
+ end case; --Cycle 9
+-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+-- Cycle A
+
+ when x"A" =>
+ case Instruction_in is
+
+
+ when others =>
+ cycle_ctr <= cycle_ctr + "1";
+ pc_inc_fg <= '0';
+
+ end case; --Cycle A
+-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+-- Cycle B
+
+ when x"B" =>
+ case Instruction_in is
+
+ when others =>
+ cycle_ctr <= cycle_ctr + "1";
+ pc_inc_fg <= '0';
+
+ end case; --Cycle B
+-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+-- Cycle C
+
+ when x"C" =>
+ case Instruction_in is
+
+
+ when others =>
+ cycle_ctr <= x"0";
+
+ end case; --Cycle C
+
+-- ==========================================================================
+
+
+ when others =>
+ cycle_ctr<= x"0";
+ end case; --cycle_ctr
+end if; --Reset stuff
+
+end if; --rising edge
+
+end process instruction_decode;
+
+end P65C02_architecture;
+
ispLeaver/65C02.vhd
Property changes :
Added: svn:executable
Index: ispLeaver/Processor.vhd
===================================================================
--- ispLeaver/Processor.vhd (nonexistent)
+++ ispLeaver/Processor.vhd (revision 2)
@@ -0,0 +1,289 @@
+------------------------------------------------------------------
+-- 6502 Top module.
+--
+-- Copyright Ian Chapman October 28 2010
+--
+-- This file is part of the Lattice 6502 project
+-- It is used to compile with ispLeaver not Linux ghdl.
+-- It is the address mapping and connecting the other modules.
+-- It is replaced by Processor.vhd when running ispLeaver.
+--
+-- To do
+-- This will be work in process or replaced whatever
+-- project file is needed to control other modules.
+--
+-- *************************************************************
+-- Distributed under the GNU Lesser General Public License. *
+-- This can be obtained from “www.gnu.org”. *
+-- *************************************************************
+-- 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 3 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, see
+--
+-- Processor.vhd
+------------------------------------------------------------------
+library IEEE; --Use standard IEEE libs as recommended by Tristan.
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+entity Processor is
+
+Port (
+-- data_wr : inout unsigned(7 downto 0);
+ clk_pin : in std_logic;
+-- clk_out : out std_logic;
+-- u802 : out std_logic;
+-- u702 : out std_logic;
+-- u602 : out std_logic;
+-- u1101 : out std_logic;
+-- u801 : out std_logic;
+-- u701 : out std_logic;
+ u601 : out std_logic;
+ rst_pin : in std_logic;
+ irq_pin : in std_logic;
+ nmi_pin : in std_logic;
+ RX_pin : in std_logic;
+-- PG_pin : in std_logic;
+ TX_pin : out std_logic;
+ Pwr_on_pin : out std_logic
+ );
+end Processor;
+
+architecture structure of Processor is
+
+-- COMPONENT DECLARATIONS
+
+component P65C02
+port(
+ data_rd: in unsigned(7 downto 0);
+ data_wr: out unsigned(7 downto 0);
+-- cycle_mark : out std_logic; --Used to signal the cycle usually cycle 0.
+ address: inout unsigned(15 downto 0);
+ proc_write : inout std_logic;
+ reset, clock : in std_logic;
+ irq : in std_logic;
+ nmi : in std_logic);
+end component;
+
+component UART_RX is
+port(
+ PG, OSC_10MHz,RX, csr_usart :in std_logic;
+ RX_rdy : out std_logic;
+ rx_reg : out unsigned(7 downto 0)
+ );
+end component;
+
+component UART_TX is
+port(
+ OSC_10MHz, PG, csw_usart :in std_logic;
+ tx_dat : in unsigned(7 downto 0);
+ TX ,tx_rdy : out std_logic
+ );
+end component;
+
+component Lattice_rom
+port (
+ OutClock: in std_logic;
+ OutClockEn: in std_logic;
+ Reset: in std_logic;
+ Address: in std_logic_vector(9 downto 0);
+ Q: out std_logic_vector(7 downto 0));
+end component;
+
+component Lattice_ram
+port (
+ Clock: in std_logic;
+ ClockEn: in std_logic;
+ Reset: in std_logic;
+ WE: in std_logic;
+ Address: in std_logic_vector(9 downto 0);
+ Data: in std_logic_vector(7 downto 0);
+ Q: out std_logic_vector(7 downto 0));
+end component;
+
+--component ghdl_rom
+--port (
+-- rom_dat: out unsigned(7 downto 0);
+-- wr, clk, rst: in std_logic;
+-- address: in unsigned(15 downto 0)
+-- );
+--end component;
+
+--component ghdl_ram
+--port (
+-- ram_dat: out unsigned(7 downto 0);
+-- data_wr : in unsigned(7 downto 0);
+-- clk, wr, rst: in std_logic;
+-- address: in unsigned(15 downto 0)
+-- );
+--end component;
+
+
+------------------------------------------------------------------------
+-- Signal Declarations
+------------------------------------------------------------------------
+signal address : unsigned(15 downto 0);
+signal add : unsigned(15 downto 0);
+signal proc_rd_dat, rom_dat, ram_dat, data_wr : unsigned(7 downto 0);
+signal rx_dat : unsigned(7 downto 0);
+signal proc_write : std_logic;
+signal one, RX_rdy, csw_usart, csr_usart, tx_rdy : std_logic;
+signal rst_bar : std_logic;
+
+signal clk : std_logic;
+--signal clk_pin : std_logic;
+signal counter : unsigned(3 downto 0);
+signal ram_write : std_logic;
+
+-- I/O ports
+constant led_port : unsigned (15 downto 0) := x"4007";
+constant rs232_dat : unsigned (15 downto 0) := x"4000"; --input and output
+constant uart_stat : unsigned (15 downto 0) := x"4001"; --RX and TX state found here
+constant uart: unsigned (15 downto 0) := x"4000"; --starts the uart transmitting
+
+begin
+
+U1 : P65C02 port map(
+ reset => rst_pin,
+ Clock => clk_pin,
+ data_rd => proc_rd_dat,
+ data_wr => data_wr,
+ address => address,
+ proc_write => proc_write,
+ irq => irq_pin,
+-- cycle_mark => cycle_mark);
+ nmi => nmi_pin);
+
+
+U2 : UART_RX port map (
+ PG => rst_pin,
+ OSC_10MHz => clk_pin,
+ RX => RX_pin,
+ rx_reg => rx_dat,
+ csr_usart => csr_usart,
+ RX_rdy => RX_rdy);
+
+U3 : UART_TX port map (
+ PG => rst_pin,
+ TX => TX_pin,
+ tx_rdy => tx_rdy,
+ OSC_10MHz => clk_pin,
+ tx_dat => data_wr,
+ csw_usart => csw_usart);
+
+--R1 : ghdl_rom port map(
+-- rom_dat=>rom_dat,
+-- address=>address,
+-- wr=>proc_write,
+-- clk=>clk_pin,
+-- rst=>rst_pin);
+
+--R2 : ghdl_ram port map(
+-- clk=>clk_pin,
+-- rst=>rst_pin,
+-- ram_dat=>ram_dat,
+-- data_wr=>data_wr,
+-- address=>address,
+-- wr=>ram_write);
+
+R3 : Lattice_rom port map(
+ Reset => rst_bar,
+ OutClock => clk_pin,
+ (address(9 downto 0)) => std_logic_vector(Address(9 downto 0)),
+ unsigned(Q) => rom_dat,
+ OutClockEn => one);
+
+R4 : Lattice_ram port map(
+ Reset => rst_bar,
+ Clock => clk_pin,
+ WE => ram_write,
+ address(9 downto 0) => std_logic_vector(Address(9 downto 0)),
+ Data => std_logic_vector(data_wr),
+ unsigned(Q) => ram_dat, ClockEn => one);
+
+-- address(9 downto 0) => (Address(9 downto 0)),
+-- Data => (data_wr),
+-- (Q) => ram_dat, ClockEn => one);
+
+one <= '1';
+rst_bar <= not rst_pin;
+one <= '1';
+--u601 <= cycle_mark;
+
+
+
+mux_add : process(rst_pin, clk_pin)
+begin
+if rst_pin = '0' then
+add <= (others => '0');
+elsif rising_edge(clk_pin) then
+ add <= address;
+end if;
+end process;
+
+ram_address : process (proc_write, address(15 downto 14))
+begin
+ if proc_write = '1' and address(15 downto 14) = "00" then
+ ram_write <= '1';
+ else
+ ram_write <= '0';
+ end if;
+end process;
+
+
+-- ===================================================================
+-- Updated muxer process
+muxer : process (add(15 downto 14), rom_dat, ram_dat, rx_dat, tx_rdy, rx_rdy)
+begin
+if add(15 downto 14) = "11" then
+ proc_rd_dat <= rom_dat;
+end if;
+if add(15 downto 14) = "00" then
+ proc_rd_dat <= ram_dat;
+end if;
+if add(15 downto 0) = rs232_dat then
+ proc_rd_dat <= rx_dat;
+end if;
+if add(15 downto 0) = uart_stat then
+ proc_rd_dat <= tx_rdy & rx_rdy & "000000";
+end if;
+end process;
+-- ===================================================================
+
+rs232_cs : process (rst_pin, clk_pin, address, proc_write)
+begin
+if proc_write = '0' and address = uart then
+ csr_usart <= '1';
+else
+ csr_usart <= '0';
+end if;
+
+if proc_write = '1' and address = uart then
+ csw_usart <= '1';
+else
+ csw_usart <= '0';
+end if;
+end process;
+
+
+
+relay : process (rst_pin, proc_write, address, data_wr(7), clk_pin)
+begin
+if rst_pin = '0' then
+ Pwr_on_pin <= '0';
+ elsif rising_edge(clk_pin) and address = led_port and proc_write = '1' then
+ Pwr_on_pin <= data_wr(7);
+end if;
+end process;
+
+
+end structure;
ispLeaver/Processor.vhd
Property changes :
Added: svn:executable
Index: ispLeaver/UART_RX.vhd
===================================================================
--- ispLeaver/UART_RX.vhd (nonexistent)
+++ ispLeaver/UART_RX.vhd (revision 2)
@@ -0,0 +1,206 @@
+------------------------------------------------------------------
+-- 6502 support module.
+--
+-- Copyright Ian Chapman October 28 2010
+--
+-- This file is part of the Lattice 6502 project
+-- It is used to compile with Linux ghdl and ispLeaver.
+-- The baude rate is 9600.
+--
+-- To do
+-- Nothing.
+--
+-- *************************************************************
+-- Distributed under the GNU Lesser General Public License. *
+-- This can be obtained from “www.gnu.org”. *
+-- *************************************************************
+-- 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 3 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, see
+--
+-- UART_RX.vhd
+-- *************************************************************
+--
+library IEEE;
+--Library UNISIM;
+--library WORK;
+
+use IEEE.std_logic_1164.all;
+use IEEE.numeric_std.all; --Needed for GHDL
+--use UNISIM.vcomponents.all;
+--use WORK.ALFT_GLOBAL_lib.all;
+
+
+-- RX baude rate generator. Zero sync to transitions on RX
+entity UART_RX is
+port(
+ RX, OSC_10MHz, csr_usart :in std_logic;
+ PG : in std_logic; --Power Good.
+ RX_rdy : out std_logic;
+ rx_reg : out unsigned(7 downto 0)
+ );
+end UART_RX;
+
+Architecture behavioral of UART_RX is
+
+--constant define_rx_baude_rate : unsigned (5 downto 0) := "101011"; --115.2 Kbps
+constant define_rx_baude_rate : unsigned (10 downto 0) := "10000010010"; --9.6 Kbps
+constant define_rx_mid_strob : unsigned (10 downto 0) := "01000001001";
+constant define_rx_bits : unsigned (3 downto 0) := x"A"; --start+8+stop
+signal rx_start_pul, br_start_pul, RX_BR_clk : std_logic;
+signal RX_sr : std_logic_vector (1 downto 0);
+signal rx_clk_int : unsigned (3 downto 0);
+signal rx_br_ctr_int : unsigned (10 downto 0);
+signal br_strob, br_mid_strob, end_ff : std_logic;
+
+-- =============================================================
+-- Synchronize BR counter to RX data transitions.
+
+begin
+Start_up:process (OSC_10MHz, PG, RX)
+begin
+if PG = '0' then
+ rx_start_pul <= '0';
+elsif falling_edge (OSC_10MHz) then
+ RX_sr <= RX_sr(0) & RX;
+ if RX_sr = "10" and RX = '0' and rx_clk_int = define_rx_bits then
+ rx_start_pul <= '1'; --Used to sync the BR clock
+ else
+ rx_start_pul <= '0';
+ end if;
+end if;
+end process;
+--====================================
+-- The receive counter sits at end of count until transition
+-- on the RX data in line then it is set to zero
+Init_BR:process (rx_start_pul, rx_clk_int)
+begin
+if rx_clk_int = define_rx_bits then
+ br_start_pul <= rx_start_pul; --rx_start_pul is the transition
+else
+ br_start_pul <= '0'; --Used to start the Receive counter
+end if;
+end process;
+-- =================================================
+
+-- This divides the 10MHz down to the baud rate
+-- The baude rate clock the receive counter
+-- that counts the RX data bits into a register.
+
+RX_BR_counter:process (OSC_10MHz, PG, rx_start_pul, rx_br_ctr_int, rx_clk_int, br_start_pul)
+begin
+if PG = '0' then
+ rx_br_ctr_int <= define_rx_baude_rate;
+ br_strob <= '0';
+ br_mid_strob <= '0';
+elsif rising_edge (OSC_10MHz) then
+ if rx_start_pul = '1' or rx_br_ctr_int = define_rx_baude_rate then
+ rx_br_ctr_int <= (others => '0');
+ else
+ rx_br_ctr_int <= rx_br_ctr_int + "1"; -- + 1;
+ end if;
+ if rx_br_ctr_int = define_rx_baude_rate then
+ br_strob <= '1';
+ else
+ br_strob <= '0';
+ end if;
+ if rx_br_ctr_int = define_rx_mid_strob then
+ br_mid_strob <= '1';
+ else
+ br_mid_strob <= '0';
+ end if;
+end if;
+end process;
+
+-- =================================================
+
+-- This flip flop clocks the counter and Rx data
+
+RX_clock:process (OSC_10MHz, br_strob, br_start_pul, rx_clk_int, rx_br_ctr_int)
+begin
+if br_start_pul = '1' then
+ RX_BR_clk <= '0';
+elsif falling_edge (OSC_10MHz) then
+ if br_strob = '1' then
+ RX_BR_clk <= not RX_BR_clk;
+ end if;
+end if;
+end process;
+-- ====================================================
+
+-- This process counts the bits starting with the start bit
+
+receive_ctr:process(OSC_10MHz, br_strob, br_start_pul, RX_BR_clk, RX,rx_clk_int)
+begin
+if PG = '0' then
+ rx_clk_int <= define_rx_bits;
+elsif rising_edge (OSC_10MHz) then
+ if (rx_clk_int /= define_rx_bits and br_strob = '1') then
+ rx_clk_int <= rx_clk_int + X"1";
+ elsif br_start_pul = '1' then
+ rx_clk_int <= (others => '0');
+ end if;
+end if;
+end process;
+
+Receiver:process (OSC_10MHz, RX, RX_BR_clk, rx_clk_int)
+begin
+if PG = '0' then
+ rx_reg <= (others => '0');
+
+elsif rising_edge (OSC_10MHz) then
+ if br_mid_strob = '1' then
+ case rx_clk_int is
+ when X"1" =>
+ rx_reg(0) <= RX;
+ when X"2" =>
+ rx_reg(1) <= RX;
+ when X"3" =>
+ rx_reg(2) <= RX;
+ when X"4" =>
+ rx_reg(3) <= RX;
+ when X"5" =>
+ rx_reg(4) <= RX;
+ when X"6" =>
+ rx_reg(5) <= RX;
+ when X"7" =>
+ rx_reg(6) <= RX;
+ when X"8" =>
+ rx_reg(7) <= RX;
+ when others =>
+ null;
+ end case;
+ end if;
+end if;
+end process;
+
+Set_rdy :process (OSC_10MHz, rx_start_pul, rx_clk_int)
+begin
+if PG = '0' then
+ RX_rdy <= '0';
+ end_ff <= '0';
+elsif rising_edge (OSC_10MHz) then
+ if rx_clk_int = 9 then
+ end_ff <= '1';
+ end if;
+ if rx_clk_int = 9 and end_ff ='0' then
+ RX_rdy <= '1';
+ elsif csr_usart = '1' then
+ RX_rdy <= '0';
+ elsif rx_start_pul = '1'then
+ end_ff <= '0';
+ end if;
+end if;
+end process;
+
+end behavioral;
+
ispLeaver/UART_RX.vhd
Property changes :
Added: svn:executable
Index: ispLeaver/UART_TX.vhd
===================================================================
--- ispLeaver/UART_TX.vhd (nonexistent)
+++ ispLeaver/UART_TX.vhd (revision 2)
@@ -0,0 +1,157 @@
+------------------------------------------------------------------
+-- 6502 support module.
+--
+-- Copyright Ian Chapman October 28 2010
+--
+-- This file is part of the Lattice 6502 project
+-- It is used to compile with Linux ghdl and ispLeaver.
+-- The baude rate is 9600.
+--
+-- To do
+-- Nothing.
+--
+-- *************************************************************
+-- Distributed under the GNU Lesser General Public License. *
+-- This can be obtained from “www.gnu.org”. *
+-- *************************************************************
+-- 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 3 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, see
+--
+-- UART_TX.vhd
+-- *************************************************************
+--
+library IEEE;
+
+use IEEE.std_logic_1164.all;
+use IEEE.numeric_std.all; --Needed for GHDL
+
+-- RX baude rate generator. Zero sync to transitions on RX
+entity UART_TX is
+port(
+ OSC_10MHz, PG, csw_usart :in std_logic;
+ tx_dat : in unsigned(7 downto 0);
+ TX, tx_rdy : out std_logic
+ );
+end UART_TX;
+
+Architecture behavioral of UART_TX is
+
+--constant define_tx_baude_rate : unsigned (6 downto 0) := "1010111"; --115.2 Kbps
+constant define_tx_baude_rate : unsigned (10 downto 0) := "10000010010"; --9.6 Kbps
+constant define_tx_bits : unsigned (3 downto 0) := x"B"; --start+8+stop+extra
+
+signal tx_clk_int : unsigned (3 downto 0);
+-- signal tx_clk : unsigned (3 downto 0);
+signal br_ctr_tx_int : unsigned (10 downto 0);
+signal br_strob : std_logic;
+signal reg_tx_dat : unsigned (7 downto 0);
+
+begin
+
+-- =================================================
+-- Load data to be transmitted
+ld_tx : process (osc_10MHz, csw_usart, PG)
+begin
+if PG = '0' then
+ reg_tx_dat <= (others => '0');
+elsif rising_edge(osc_10MHz)then
+ if csw_usart = '1' then
+ reg_tx_dat <= tx_dat;
+ end if;
+end if;
+end process;
+-- =================================================
+-- TX baude rate generator
+TX_brg:process (OSC_10MHz, csw_usart, br_ctr_tx_int)
+begin
+if PG = '0' then
+ br_ctr_tx_int <= (others => '0');
+ br_strob <= '0';
+elsif rising_edge (OSC_10MHz) then
+ if br_ctr_tx_int = define_tx_baude_rate or csw_usart = '1' then
+ br_ctr_tx_int <= (others => '0');
+ else
+ br_ctr_tx_int <= br_ctr_tx_int + 1;
+ end if;
+
+ if br_ctr_tx_int = define_tx_baude_rate then
+ br_strob <= '1';
+ else
+ br_strob <= '0';
+ end if;
+end if;
+end process;
+
+-- =================================================
+-- TX process gen clk for uart tx
+transmit_ctr:process(osc_10MHz, csw_usart, br_strob, tx_clk_int, reg_tx_dat)
+begin
+
+if PG = '0' then
+ tx_clk_int <= define_tx_bits;
+ TX <= '1';
+elsif rising_edge (osc_10MHz) then
+ if csw_usart = '1' then
+ tx_clk_int <= (others => '0');
+ elsif tx_clk_int /= define_tx_bits and br_strob = '1' then
+ tx_clk_int <= tx_clk_int + 1;
+ end if;
+end if;
+--------------------------------------
+case tx_clk_int is
+-- Start bit
+ when X"0" =>
+ TX <= '0';
+ tx_rdy <= '1';
+ when X"1" =>
+ TX <= reg_tx_dat(0);
+ when X"2" =>
+ TX <= reg_tx_dat(1);
+ when X"3" =>
+ TX <= reg_tx_dat(2);
+ when X"4" =>
+ TX <= reg_tx_dat(3);
+ when X"5" =>
+ TX <= reg_tx_dat(4);
+ when X"6" =>
+ TX <= reg_tx_dat(5);
+ when X"7" =>
+ TX <= reg_tx_dat(6);
+ when X"8" =>
+ TX <= reg_tx_dat(7);
+-- Stop bit
+ when X"9" =>
+ TX <= '1';
+
+ when X"A" =>
+ TX <= '1';
+-- tx_rdy <= '0';
+ when X"b" =>
+ TX <= '1';
+ tx_rdy <= '0';
+-- when X"c" =>
+-- TX <= '1';
+-- tx_rdy <= '0';
+-- when X"d" =>
+-- TX <= '1';
+-- tx_rdy <= '0';
+ when others =>
+ TX <= '1';
+ tx_rdy <= '0';
+ end case;
+--end if;
+end process;
+
+end behavioral;
+
+
ispLeaver/UART_TX.vhd
Property changes :
Added: svn:executable
Index: ghdl/kernel4.mem
===================================================================
--- ghdl/kernel4.mem (nonexistent)
+++ ghdl/kernel4.mem (revision 2)
@@ -0,0 +1,1030 @@
+#Format=Hex
+#Depth=1024
+#Width=8
+#AddrRadix=3
+#DataRadix=3
+#Data
+A2
+00
+9A
+8E
+80
+02
+8E
+81
+02
+8E
+82
+02
+8E
+83
+02
+8E
+84
+02
+A9
+3F
+20
+0D
+FE
+4C
+23
+FC
+4C
+4A
+FC
+4C
+AD
+FC
+4C
+17
+FC
+4C
+38
+FC
+AE
+83
+02
+9D
+00
+02
+A8
+E8
+8A
+29
+3F
+8D
+83
+02
+98
+4C
+1A
+FC
+AD
+01
+40
+29
+40
+F0
+06
+AD
+00
+40
+4C
+26
+FC
+A9
+00
+4C
+1A
+FC
+F0
+0D
+48
+20
+0D
+FE
+68
+C9
+0D
+F0
+07
+C9
+0A
+F0
+03
+4C
+1D
+FC
+AE
+84
+02
+BD
+00
+02
+20
+85
+FE
+C9
+72
+F0
+6E
+C9
+52
+D0
+03
+4C
+F8
+FC
+C9
+77
+D0
+03
+4C
+31
+FD
+C9
+46
+D0
+03
+4C
+53
+FD
+C9
+47
+D0
+03
+4C
+8D
+FD
+C9
+67
+D0
+06
+20
+85
+FE
+4C
+90
+02
+C9
+53
+D0
+10
+AE
+84
+02
+BD
+00
+02
+20
+85
+FE
+C9
+31
+D0
+03
+4C
+93
+FD
+C9
+39
+D0
+03
+4C
+07
+FE
+4C
+00
+FC
+AD
+01
+40
+29
+80
+D0
+06
+4C
+BD
+FC
+8D
+00
+40
+4C
+20
+FC
+AD
+82
+02
+F0
+F8
+CE
+82
+02
+AD
+80
+02
+A8
+AA
+C8
+98
+29
+3F
+8D
+80
+02
+BD
+40
+02
+4C
+B7
+FC
+20
+34
+FE
+A5
+03
+20
+6B
+FE
+A5
+02
+20
+6B
+FE
+A9
+20
+20
+0D
+FE
+A0
+00
+B1
+02
+20
+6B
+FE
+A9
+0D
+20
+0D
+FE
+4C
+1D
+FC
+20
+34
+FE
+A5
+03
+85
+01
+20
+6B
+FE
+A5
+02
+29
+F0
+85
+00
+20
+6B
+FE
+A9
+00
+8D
+88
+02
+A9
+20
+20
+0D
+FE
+AC
+88
+02
+B1
+00
+20
+6B
+FE
+AC
+88
+02
+C8
+98
+8D
+88
+02
+C9
+10
+D0
+E7
+A9
+0D
+20
+0D
+FE
+4C
+1D
+FC
+20
+34
+FE
+A5
+03
+85
+01
+20
+6B
+FE
+A5
+02
+85
+00
+20
+6B
+FE
+20
+34
+FE
+A5
+02
+A0
+00
+91
+00
+A9
+0D
+20
+0D
+FE
+4C
+1D
+FC
+20
+34
+FE
+A5
+03
+48
+A5
+02
+48
+20
+34
+FE
+A5
+02
+48
+20
+34
+FE
+A5
+02
+8D
+85
+02
+68
+A8
+68
+85
+02
+68
+85
+03
+98
+48
+A0
+00
+8D
+88
+02
+68
+91
+02
+C8
+8D
+88
+02
+CC
+85
+02
+D0
+F5
+A9
+0D
+20
+0D
+FE
+4C
+1D
+FC
+20
+34
+FE
+6C
+02
+00
+A2
+02
+20
+D6
+FD
+A5
+02
+18
+E9
+03
+8D
+89
+02
+A2
+04
+20
+D6
+FD
+A5
+02
+85
+00
+A5
+03
+85
+01
+A9
+00
+8D
+8A
+02
+A2
+02
+20
+D6
+FD
+AC
+8A
+02
+91
+00
+C8
+8C
+8A
+02
+CC
+89
+02
+D0
+ED
+A9
+0D
+20
+0D
+FE
+20
+85
+FE
+20
+85
+FE
+20
+85
+FE
+4C
+1D
+FC
+A9
+00
+85
+02
+85
+03
+8E
+87
+02
+AE
+87
+02
+F0
+22
+AE
+84
+02
+BD
+00
+02
+20
+85
+FE
+AE
+87
+02
+A0
+00
+D9
+93
+FE
+D0
+0A
+CA
+8E
+87
+02
+20
+56
+FE
+4C
+DF
+FD
+C8
+C0
+10
+D0
+EC
+60
+20
+D6
+FD
+4C
+1D
+FC
+48
+8C
+86
+02
+AD
+82
+02
+C9
+3F
+10
+17
+EE
+82
+02
+AD
+81
+02
+A8
+AA
+C8
+98
+29
+3F
+8D
+81
+02
+68
+9D
+40
+02
+AC
+86
+02
+60
+68
+AC
+86
+02
+60
+A0
+00
+84
+02
+84
+03
+AE
+84
+02
+BD
+00
+02
+20
+85
+FE
+A0
+00
+D9
+93
+FE
+D0
+06
+20
+56
+FE
+4C
+3A
+FE
+C8
+C0
+10
+D0
+F0
+60
+8E
+85
+02
+A2
+04
+06
+02
+26
+03
+CA
+D0
+F9
+98
+05
+02
+85
+02
+AE
+85
+02
+60
+A8
+18
+6A
+6A
+6A
+6A
+29
+0F
+AA
+BD
+93
+FE
+20
+0D
+FE
+98
+29
+0F
+AA
+BD
+93
+FE
+20
+0D
+FE
+60
+48
+EE
+84
+02
+AD
+84
+02
+29
+3F
+8D
+84
+02
+68
+60
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+41
+42
+43
+44
+45
+46
+A9
+4E
+20
+0D
+FE
+40
+A9
+49
+20
+0D
+FE
+40
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+EA
+4C
+0D
+FE
+4C
+6B
+FE
+1D
+FC
+00
+FC
+A3
+FE
+00
+FC
+A9
+FE
ghdl/kernel4.mem
Property changes :
Added: svn:executable
Index: ghdl/kernel4.asm
===================================================================
--- ghdl/kernel4.asm (nonexistent)
+++ ghdl/kernel4.asm (revision 2)
@@ -0,0 +1,476 @@
+; Kernel
+; Reads uart input
+; Processes the command
+; raddress = reads one byte outs to uart
+; Raddress = reads 16 bytes outs to uart
+; waddress data = write one databyte to address location
+; Faddress data nn = Fill databyte into nn locations
+; S1bcadd d d d d d chksum= see Motorolla hex format used to load short program
+; Gaddress start from this address
+; Sends the stuff in the output buffer to uart tx.
+;
+;
+ cpu 6502
+PAGE 40,120
+
+led equ $4007
+dat232 equ $4000
+stat232 equ $4001
+tx232 equ $4000
+
+;dat232 equ $290 ;used to help debug
+;stat232 equ $291
+;tx232 equ $292
+
+tx_rdy equ $80 ;bit 7
+rx_rdy equ $40 ;bit 6
+;
+inbuflen equ $40 ;input buffer table length
+otbuflen equ $40 ;output buffer table length
+cr equ $0d ;cariage return
+
+
+; ZERO PAGE STUFF
+* = $0
+ptr dw $0 ;reserve 2 bytes
+hexword dw $0 ;accumulates hex word
+
+
+; STUFF IN UPPER MEMORY
+* = $200
+
+inbuff db 0 ;reserve 64 bytes for command input
+* = inbuff + inbuflen
+outbuff db 0
+* = outbuff + otbuflen
+
+txoutpt db 0 ;output pointer index
+txinpt db 0 ;input pointer index
+txoutct db 0 ;Counter
+inbufpt db 0 ;Ponts where to put kb text
+txtpt db 0 ;Points to text to be processed
+sp1 db $0
+sp2 db $0
+sp3 db $0
+temp_y db 0
+bytcnt db 0
+n db 0
+
+
+page
+* = $fc00
+; This is the main loop.
+;
+main ldx #$0
+ txs ;Set stack pointer to x100
+ stx txoutpt
+ stx txinpt
+ stx txoutct
+ stx inbufpt
+ stx txtpt
+
+ lda #"?" ;Illegal char or restart
+ jsr sendtxt ;or bad frap
+
+loop jmp input ;Read serial character
+back1 jmp process ;It's in reg a and stored in inbuff
+back2 jmp sendbuf
+back3 jmp loop
+;
+;
+page
+; This is where the uart receiver character is picked up and dumped
+; into the input buffer (inbuff)
+code
+input jmp getchar
+; beq back1 ;No new character
+.loop ldx inbufpt ;Returns with it in y
+ sta inbuff,x ;input buffer
+ tay
+ inx
+ txa
+ and #inbuflen - 1
+ sta inbufpt
+ tya
+ jmp back1 ;return with character in a
+
+getchar lda stat232
+ and #rx_rdy
+ beq .exit
+ lda dat232 ;Character in a
+ jmp .loop
+.exit lda #$0
+ jmp back1
+code
+page
+code
+; This is where the complicated stuff is done
+process beq .exit ;It's a null character
+ pha
+ jsr sendtxt ;Echo character to terminal
+ pla
+ cmp #"\r"
+ beq got_cr
+ cmp #"\n"
+ beq got_cr
+.exit jmp back2
+
+got_cr ldx txtpt ;Decode the KB input
+ lda inbuff,x
+ jsr inctxt
+ cmp #"r"
+ beq read1 ;Read one byte rnnnn
+
+ cmp #"R"
+ bne next0
+ jmp readn
+
+next0 cmp #"w" ;Write one byte wnnnn xx
+ bne next1
+ jmp write1
+
+next1 cmp #"F" ;Fill Fnnnn nn xx
+ bne next2
+ jmp fill
+
+next2 cmp #"G" ;goto nnnn
+ bne next3
+ jmp goto
+
+next3 cmp #"g" ;goto 290
+ bne next4
+ jsr inctxt ;Get to end of buffer
+ jmp $290
+
+
+next4 cmp #"S"
+ bne next5
+ ldx txtpt
+ lda inbuff,x
+ jsr inctxt
+ cmp #"1"
+ bne next5
+ jmp scode
+next5 cmp #"9"
+ bne next6
+ jmp flush ;Last S code packet not used so flush
+
+next6 jmp main ;restart bad input
+
+
+
+
+code
+page
+code
+; This is where stuff is pulled from the output buffer (outbuff)
+; and sent to the terminal
+sendbuf lda stat232 ;All regs destroyed
+ and #tx_rdy ;Test uart tx status
+ bne .exit ;In use
+ jmp .gettxt ;char in A for return
+.bak sta tx232 ;Byte to terminal
+.exit jmp back3
+; Pull txt from buffer if not empty
+.gettxt lda txoutct
+ beq .exit
+ dec txoutct
+ lda txoutpt ;out text out pointer
+ tay
+ tax
+ iny
+ tya
+ and #inbuflen - 1
+ sta txoutpt
+ lda outbuff,x
+ jmp .bak
+
+code
+page
+
+page ;This routing reads one byt"\n"e from address
+read1 jsr txt2hex ;Convert string to 16 bit word
+
+ lda hexword + 1
+ jsr hex2txt
+
+ lda hexword
+ jsr hex2txt
+
+ lda #" "
+ jsr sendtxt
+ ldy #$0
+ lda (hexword),y
+ jsr hex2txt
+ lda #"\r"
+ jsr sendtxt
+ jmp back2
+; ===============================================
+
+readn jsr txt2hex ;Convert string to 16 bit word
+
+ lda hexword + 1
+ sta ptr + 1
+ jsr hex2txt
+
+ lda hexword
+ and #$f0
+ sta ptr
+ jsr hex2txt
+
+ lda #$0
+ sta temp_y
+read_lp lda #" "
+ jsr sendtxt
+ ldy temp_y
+ lda (ptr),y
+ jsr hex2txt
+ ldy temp_y
+ iny
+ tya
+ sta temp_y
+ cmp #$10
+ bne read_lp
+
+ lda #"\r"
+ jsr sendtxt
+ jmp back2
+; ==================================================
+
+; This routine writes one byte to memory
+; address space data
+write1 jsr txt2hex ;Convert string to 16 bit word
+
+ lda hexword + 1 ;Save these locations
+ sta ptr + 1
+ jsr hex2txt
+
+ lda hexword
+ sta ptr
+ jsr hex2txt
+
+ jsr txt2hex ;Convert data
+ lda hexword
+
+ ldy #$0
+ sta (ptr),y
+ lda #"\r"
+ jsr sendtxt
+ jmp back2
+; ==================================================
+fill jsr txt2hex ;Convert string to 16 bit word
+
+ lda hexword + 1 ;Save these locations
+ pha
+ lda hexword
+ pha
+
+ jsr txt2hex ;Convert data
+ lda hexword
+ pha ;Data on stack
+
+ jsr txt2hex ;how many bytes?
+ lda hexword
+ sta sp1 ;Number of bytes to fill in sp1
+
+ pla
+ tay ;Data into y
+ pla ;Restore hexword
+ sta hexword
+ pla
+ sta hexword + 1
+ tya
+ pha
+
+ ldy #$0
+ sta temp_y
+ pla
+fill_lp sta (hexword),y
+ iny
+ sta temp_y
+ cpy sp1
+ bne fill_lp
+
+ lda #"\r"
+ jsr sendtxt
+ jmp back2
+
+goto jsr txt2hex
+ jmp (hexword) ;goto user code best return to main x"fc00"
+
+page
+code
+; This routine takes the Motorolla S code generated
+; by crasm and loads it into RAM.
+; The checksum is not checked since there is no comms.
+
+scode ldx #$2 ;convert two bytes byte count
+ jsr cod2hex
+ lda hexword
+ clc
+ sbc #3
+ sta bytcnt ;total bytes to transfer
+
+ ldx #$4 ;convert four bytes to address
+ jsr cod2hex ;hexword points to where data goes
+ lda hexword
+ sta ptr
+ lda hexword + 1
+ sta ptr + 1 ;ptr holds point
+
+ lda #$0
+ sta n
+
+scodelp ldx #$2 ;4 or 2 bytes to form number
+ jsr cod2hex
+ ldy n
+ sta (ptr),y
+ iny
+ sty n
+ cpy bytcnt
+ bne scodelp
+ lda #"\r"
+ jsr sendtxt
+ jsr inctxt ;skip checksum 1
+ jsr inctxt ;and cs2
+ jsr inctxt ;and cr
+ jmp back2
+
+cod2hex lda #$0
+ sta hexword
+ sta hexword + 1
+ stx sp3 ;Save No of bytes to convert this time
+
+.lphex ldx sp3
+ beq .exit
+ ldx txtpt
+ lda inbuff,x
+ jsr inctxt
+ ldx sp3
+
+ ldy #$0
+.nothis cmp asctbl,y
+ bne .next
+ dex ;Got 1 match
+ stx sp3
+ jsr accum
+ jmp .lphex
+.next iny
+ cpy #$10
+ bne .nothis ;next hex char
+.exit rts ;last char
+
+flush jsr cod2hex ;empty buffer
+ jmp back2 ;result of subroutine ignored
+
+
+code
+
+
+page
+; This is where the output buffer (outbuf) is loaded.
+code
+sendtxt pha ;A hold character to be place in buffer
+ sty sp2
+ lda txoutct
+ cmp #otbuflen -1
+ bpl .exit ;buffer should never be full
+ inc txoutct
+ lda txinpt ;out text out pointer
+ tay
+ tax
+ iny
+ tya
+ and #otbuflen - 1
+ sta txinpt
+ pla
+ sta outbuff,x
+ ldy sp2
+ rts
+.exit pla
+ ldy sp2
+ rts
+
+
+code
+page
+code
+txt2hex ldy #$0
+ sty hexword
+ sty hexword + 1
+
+loophex ldx txtpt
+ lda inbuff,x ;input buffer
+ jsr inctxt ;inc counter
+ ldy #$0
+nomatch cmp asctbl,y
+ bne .next
+ jsr accum
+ jmp loophex
+.next iny
+ cpy #$10
+ bne nomatch ;next hex char
+ rts ;not hex char
+
+
+accum stx sp1
+ ldx #$4 ;y holds hex of character
+accloop asl hexword
+ rol hexword + 1
+ dex
+ bne accloop
+ tya
+ ora hexword
+ sta hexword
+ ldx sp1
+ rts
+
+
+hex2txt tay ;A holds byte to convert
+ clc
+ ror a
+ ror a
+ ror a
+ ror a
+ and #$0f
+ tax
+ lda asctbl,x
+ jsr sendtxt
+ tya
+ and #$0f
+ tax
+ lda asctbl,x
+ jsr sendtxt
+ rts
+; inc after reading from inbuff
+inctxt pha ;NOT before
+ inc txtpt
+ lda txtpt
+ and #inbuflen - 1
+ sta txtpt
+ pla
+ rts
+
+asctbl asc "0123456789ABCDEF"
+code
+
+page ;All the start up stuff
+
+nmi_srv lda #"N"
+ jsr sendtxt
+ rti
+
+irq_srv lda #"I"
+ jsr sendtxt
+ rti
+* =$fff0
+ jmp sendtxt ;Links for usrcode
+ jmp hex2txt
+ dw back2
+
+* = $fff8
+;
+indjmp dw main
+nmi dw nmi_srv
+rst dw main ;Should be main, this is for test only
+irq dw irq_srv
ghdl/kernel4.asm
Property changes :
Added: svn:executable
Index: ghdl/usrcode.asm
===================================================================
--- ghdl/usrcode.asm (nonexistent)
+++ ghdl/usrcode.asm (revision 2)
@@ -0,0 +1,111 @@
+;
+ cpu 6502
+PAGE 40,120
+; ****************************************************************************************
+; This is intended to be the template for the user code
+; ****************************************************************************************
+
+* = $290 ;user code starts at $290
+return equ $fff6 ;jump to fcoo to return control and restart
+sendtxt equ $fff0
+hex2txt equ $fff3
+
+
+main ldy #$55
+ ldx #$aa
+ lda #$7e
+ clc
+ adc #$6 ;9-3=6 carry=0
+ php
+ pha
+ txa
+ pha
+ tya
+ pha
+
+ lda #"Y" ;Display Y register
+ jsr sendtxt
+ lda #"="
+ jsr sendtxt
+ pla
+ jsr hex2txt
+ lda #" "
+ jsr sendtxt
+
+ lda #"X" ;Display X register
+ jsr sendtxt
+ lda #"="
+ jsr sendtxt
+ pla
+ jsr hex2txt
+ lda #" "
+ jsr sendtxt
+
+ lda #"A" ;Display A register
+ jsr sendtxt
+ lda #"="
+ jsr sendtxt
+ pla
+ jsr hex2txt
+ lda #" "
+ jsr sendtxt
+
+ lda #"C" ;Display carry
+ jsr sendtxt
+ lda #"="
+ jsr sendtxt
+ plp
+ php
+ bcc clear1
+ lda #"1"
+ jmp cont1
+clear1 lda #"0"
+cont1 jsr sendtxt
+ lda #" "
+ jsr sendtxt
+
+ lda #"V" ;Display overflow
+ jsr sendtxt
+ lda #"="
+ jsr sendtxt
+ plp
+ php
+ bvc clear2
+ lda #"1"
+ jmp cont2
+clear2 lda #"0"
+cont2 jsr sendtxt
+ lda #" "
+ jsr sendtxt
+
+ lda #"Z" ;Display zero
+ jsr sendtxt
+ lda #"="
+ jsr sendtxt
+ plp
+ php
+ beq clear3
+ lda #"1"
+ jmp cont3
+clear3 lda #"0"
+cont3 jsr sendtxt
+ lda #" "
+ jsr sendtxt
+
+ lda #"M" ;Display minus
+ jsr sendtxt
+ lda #"="
+ jsr sendtxt
+ plp
+ bpl clear4
+ lda #"1"
+ jmp cont4
+clear4 lda #"0"
+cont4 jsr sendtxt
+
+
+ lda #"\r"
+ jsr sendtxt
+ jmp (return)
+
+; end of program
ghdl/usrcode.asm
Property changes :
Added: svn:executable
Index: ghdl/crasm.lang
===================================================================
--- ghdl/crasm.lang (nonexistent)
+++ ghdl/crasm.lang (revision 2)
@@ -0,0 +1,227 @@
+
+
+
+
+ text/x-crasm
+ *.asm
+ ;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ;
+
+
+
+
+
+
+ "
+ "
+
+
+
+ '.'
+
+
+
+ adc
+ and
+ asl
+ bcc
+ bcs
+ beq
+ bit
+ bmi
+ bne
+ bpl
+ brk
+ bvc
+ bvs
+ clc
+ cld
+ cli
+ clv
+ cmp
+ cpy
+ cpx
+ dec
+ dex
+ dey
+ eor
+ inc
+ inx
+ iny
+ jmp
+ jsr
+ lda
+ ldx
+ ldy
+ lsr
+ nop
+ ora
+ pha
+ php
+ pla
+ plp
+ rol
+ ror
+ rti
+ rts
+ sbc
+ sec
+ sed
+ sei
+ sta
+ stx
+ sty
+ tax
+ tay
+ tsx
+ txa
+ txs
+ tya
+ phx
+ phy
+ plx
+ ply
+ bbr0
+ bbr1
+ bbr2
+ bbr3
+ bbr4
+ bbr5
+ bbr6
+ bbr7
+ bbs0
+ bbs1
+ bbs2
+ bbs3
+ bbs4
+ bbs5
+ bbs6
+ bbs7
+ bra
+ rmb
+ smb
+ stp
+ stz
+ trb
+ tsb
+ wai
+
+
+
+ cpu
+ page
+ output
+ dummy
+ if
+ else
+ endc
+ macro
+ endm
+ exitm
+ include
+ skip
+ fail
+ list
+ clist
+ mlist
+ nam
+ db
+ dw
+ asc
+ equ
+ integer
+
+
+
+ false
+ true
+
+
+ [0-9a-f][0-9a-f_]*
+ [Ee][+-]?[0-9][0-9_]*
+
+
+
+ (?<![\w\.])
+ [0-9][0-9_]*\#\%{hexnum}(\.\%{hexnum})?\#\%{exponent}?
+ (?![\w\.])
+
+
+
+
+
+ (?<![\w\.])
+ [0-9][0-9_]*\.[0-9][0-9_]*\%{exponent}?
+ (?![\w\.])
+
+
+
+
+
+ (?<![\w\.])
+ [0-9][0-9_]*(E[+]?[0-9][0-9_]*)?
+ (?![\w\.])
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
ghdl/crasm.lang
Property changes :
Added: svn:executable
Index: ghdl/asm2bin.pl
===================================================================
--- ghdl/asm2bin.pl (nonexistent)
+++ ghdl/asm2bin.pl (revision 2)
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+# This and asm2bin converts asm file foo.asm into rom files.
+# 1st type foo.bin used with ghld roms
+# 2nd type foo.mem used with Lattice roms
+# This perl script call crasm to do the assembly.
+# crsasm generates the program listing foo.lst
+
+$name = "$ARGV[0]";
+# The program was compilled at start address
+$progadd = hex("FC00");
+# The code is packed into ROM start address
+$romadd = hex("0");
+$romsize = 1024;
+# was 128
+$add_delta = $romadd - $progadd;
+
+print "Processing $name.asm \n";
+# run crasm to generate *.o and *.lst
+`crasm -o $name.o -x $name.asm > $name.lst`;
+
+open(OBJfile, "< $name.o");
+open(BINfile, "> $name.bin");
+
+$n = 0;
+@file = ;
+
+foreach $line (@file) {
+ if (substr($line, 0, 2) = "S1") {
+ $bytes = hex(substr($line, 2, 2));
+ $HEXadd = substr($line, 4, 4);
+ $address = hex("$HEXadd");
+ $runningadd = $address + $add_delta;
+ $len = length($line);
+ $substring = substr($line, 8, ($len-11));
+ print "$line";
+ print "n = $n, Address = $address, runAddress = $runningadd, del = $add_delta \n";
+
+ while ($n < $runningadd) {
+ print (BINfile "X\"EA\", \n");
+ $n++;
+ print("n is $n \n");
+ }
+
+ $a = 0;
+# while ($a < ($len - 11)) {
+ while ($a < ($len - 11) and ($address > 64513)) {
+ $byte = substr($substring, $a, 2);
+ if ($n eq ($romsize - 1)) {
+ print (BINfile "X\"$byte\" ) ; \n");
+ }
+ else {
+ print (BINfile "X\"$byte\", \n");
+ }
+ $a = $a + 2;
+ $n++ ;
+ }
+ }
+ }
+
+
+close(OBJfile);
+close(BINfile);
+
+# end
ghdl/asm2bin.pl
Property changes :
Added: svn:executable
Index: ghdl/asm2rom.pl
===================================================================
--- ghdl/asm2rom.pl (nonexistent)
+++ ghdl/asm2rom.pl (revision 2)
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+# This converts asm file foo.asm into rom files.
+# 1st type foo.bin used with ghld roms
+# 2nd type foo.mem used with Lattice roms
+# This perl script call crasm to do the assembly.
+# crsasm generates the program listing foo.lst
+
+$name = "$ARGV[0]";
+# The program was compilled at start address
+$progadd = hex("FC00");
+# The code is packed into ROM start address
+$romadd = hex("0");
+$romsize = 1024;
+$add_delta = $romadd - $progadd;
+
+print "Processing $name.asm \n";
+# run crasm to generate *.o and *.lst
+`crasm -o $name.o -x $name.asm > $name.lst`;
+
+open(OBJfile, "< $name.o");
+open(MEMfile, "> $name.mem");
+
+print(MEMfile "#Format=Hex \n");
+print(MEMfile "#Depth=1024 \n");
+print(MEMfile "#Width=8 \n");
+print(MEMfile "#AddrRadix=3 \n");
+print(MEMfile "#DataRadix=3 \n");
+print(MEMfile "#Data \n");
+
+$n = 0;
+@file = ;
+
+foreach $line (@file) {
+ if (substr($line, 0, 2) = "S1") {
+ $bytes = hex(substr($line, 2, 2));
+ $HEXadd = substr($line, 4, 4);
+ $address = hex("$HEXadd");
+ $runningadd = $address + $add_delta;
+ $len = length($line);
+ $substring = substr($line, 8, ($len-11));
+ print "$line";
+ print "n = $n, Address = $address, runAddress = $runningadd, del = $add_delta \n";
+
+ while ($n < $runningadd) {
+ print (MEMfile "EA \n");
+ $n++;
+ print("n is $n \n");
+ }
+
+ $a = 0;
+# while ($a < ($len - 11) and ($address > hex("FC00"))) {
+ while ($a < ($len - 11) and ($address > 64511)) {
+# while ($a < ($len - 11)) {
+ $byte = substr($substring, $a, 2);
+ print (MEMfile "$byte \n");
+ $a = $a + 2;
+ $n++ ;
+ }
+ }
+ }
+print " n is $n \n";
+while ($n < $romsize) {
+ print (MEMfile "EA \n");
+ $n++;
+ }
+
+close(OBJfile);
+close(MEMfile);
+
+# end
ghdl/asm2rom.pl
Property changes :
Added: svn:executable
Index: ghdl/ghdl_rom.vhd
===================================================================
--- ghdl/ghdl_rom.vhd (nonexistent)
+++ ghdl/ghdl_rom.vhd (revision 2)
@@ -0,0 +1,1109 @@
+------------------------------------------------------------------
+-- 6502 ghdl ROM module.
+--
+-- Copyright Ian Chapman October 28 2010
+--
+-- This file is part of the Lattice 6502 project
+-- It is used to compile with Linux ghdl not ispLeaver.
+-- The executable code is pasted into this module.
+--
+-- To do
+-- Complete.
+--
+-- *************************************************************
+-- Distributed under the GNU Lesser General Public License. *
+-- This can be obtained from “www.gnu.org”. *
+-- *************************************************************
+-- 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 3 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, see
+--
+-- ghdl_rom.vhd
+-- ******************************************************************************
+-- ROM memory is mapped to xFC00 *
+-- ******************************************************************************
+
+-- ************************************************************************
+-- ROM read only memory to test the 65C02 micro *
+-- IRQ, Reset and NMI at the top of memory *
+-- Test vectors mapped to my test set up *
+-- I pulled most it from tutorials, if you use it take care *
+-- I do not have the copyright and forgot where I got it. *
+-- I'm sure it's generic. *
+-- I only use it with ghdl and to make a working FPGA *
+-- I use the Lattice EBR Embedded Block RAM. If I ever get there. *
+-- ************************************************************************
+
+library IEEE; --Use standard IEEE libs as recommended by Tristan.
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+entity ghdl_rom is
+Port (
+ rom_dat : out unsigned(7 downto 0);
+ clk, rst, wr : in std_logic;
+ address : in unsigned(15 downto 0)
+ );
+end ghdl_rom;
+
+architecture RTL of ghdl_rom is
+type RomType is array (natural range <>) of unsigned(7 downto 0);
+
+signal add : unsigned(15 downto 0);
+
+signal ROM_hi : RomType(0 to 1023) := ( --FC00
+-- The filename.bin is pasted here, all of it.
+X"E8",
+X"CA",
+X"E8",
+X"A2",
+X"55",
+X"6C",
+X"15",
+X"FC",
+X"CA",
+X"E8",
+X"CA",
+X"4C",
+X"00",
+X"FC",
+X"A0",
+X"AA",
+X"C8",
+X"88",
+X"4C",
+X"08",
+X"FC",
+X"0E",
+X"FC",
+X"EA",
+X"40",
+X"EA",
+X"40",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"EA",
+X"00",
+X"FC",
+X"17",
+X"FC",
+X"00",
+X"FC",
+X"19",
+X"FC" ) ;
+-- Ths stuff you past in ends here, make sure the close bracket and semi-colon are there.
+begin
+
+addressing:process(clk, address)
+begin
+if rst = '0' then
+ add <= (others => '0');
+elsif rising_edge(clk) then
+ add <= address;
+end if;
+end process;
+
+read_rom:process(add, wr)
+begin
+if wr = '0' and add(15 downto 10) = "111111" then
+ rom_dat <= unsigned(ROM_hi(to_integer(unsigned(add(9 downto 0))))) ;
+
+end if;
+
+end process;
+end RTL ;
ghdl/ghdl_rom.vhd
Property changes :
Added: svn:executable
Index: ghdl/ghdl_processor.vhd
===================================================================
--- ghdl/ghdl_processor.vhd (nonexistent)
+++ ghdl/ghdl_processor.vhd (revision 2)
@@ -0,0 +1,288 @@
+------------------------------------------------------------------
+-- 6502 Top module.
+--
+-- Copyright Ian Chapman October 28 2010
+--
+-- This file is part of the Lattice 6502 project
+-- It is used to compile with Linux ghdl not ispLeaver.
+-- It is the address mapping and connecting the other modules.
+-- It is replaced by Processor.vhd when running ispLeaver.
+--
+-- To do
+-- This will be work in process or replaced whatever
+-- project file is needed to control other modules.
+--
+-- *************************************************************
+-- Distributed under the GNU Lesser General Public License. *
+-- This can be obtained from “www.gnu.org”. *
+-- *************************************************************
+-- 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 3 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, see
+--
+-- ghdl_processor.vhd
+--
+------------------------------------------------------------------
+library IEEE; --Use standard IEEE libs as recommended by Tristan.
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+entity Processor is
+
+Port (
+-- data_wr : inout unsigned(7 downto 0);
+ clk_pin : in std_logic;
+-- clk_out : out std_logic;
+-- u802 : out std_logic;
+-- u702 : out std_logic;
+-- u602 : out std_logic;
+-- u1101 : out std_logic;
+-- u801 : out std_logic;
+-- u701 : out std_logic;
+ u601 : out std_logic;
+ rst_pin : in std_logic;
+ irq_pin : in std_logic;
+ nmi_pin : in std_logic;
+ RX_pin : in std_logic;
+-- PG_pin : in std_logic;
+ TX_pin : out std_logic;
+ Pwr_on_pin : out std_logic
+ );
+end Processor;
+
+architecture structure of Processor is
+
+-- COMPONENT DECLARATIONS
+
+component P65C02
+port(
+ data_rd: in unsigned(7 downto 0);
+ data_wr: out unsigned(7 downto 0);
+-- cycle_mark : out std_logic; --Used to signal the cycle usually cycle 0.
+ address: inout unsigned(15 downto 0);
+ proc_write : inout std_logic;
+ reset, clock : in std_logic;
+ irq : in std_logic;
+ nmi : in std_logic);
+end component;
+
+component UART_RX is
+port(
+ PG, OSC_10MHz,RX, csr_usart :in std_logic;
+ RX_rdy : out std_logic;
+ rx_reg : out unsigned(7 downto 0)
+ );
+end component;
+
+component UART_TX is
+port(
+ OSC_10MHz, PG, csw_usart :in std_logic;
+ tx_dat : in unsigned(7 downto 0);
+ TX ,tx_rdy : out std_logic
+ );
+end component;
+
+--component Lattice_rom
+--port (
+-- OutClock: in std_logic;
+-- OutClockEn: in std_logic;
+-- Reset: in std_logic;
+-- Address: in std_logic_vector(9 downto 0);
+-- Q: out std_logic_vector(7 downto 0));
+--end component;
+
+--component Lattice_ram
+--port (
+-- Clock: in std_logic;
+-- ClockEn: in std_logic;
+-- Reset: in std_logic;
+-- WE: in std_logic;
+-- Address: in std_logic_vector(9 downto 0);
+-- Data: in std_logic_vector(7 downto 0);
+-- Q: out std_logic_vector(7 downto 0));
+--end component;
+
+component ghdl_rom
+port (
+ rom_dat: out unsigned(7 downto 0);
+ wr, clk, rst: in std_logic;
+ address: in unsigned(15 downto 0)
+ );
+end component;
+
+component ghdl_ram
+port (
+ ram_dat: out unsigned(7 downto 0);
+ data_wr : in unsigned(7 downto 0);
+ clk, wr, rst: in std_logic;
+ address: in unsigned(15 downto 0)
+ );
+end component;
+
+
+------------------------------------------------------------------------
+-- Signal Declarations
+------------------------------------------------------------------------
+signal address : unsigned(15 downto 0);
+signal add : unsigned(15 downto 0);
+signal proc_rd_dat, rom_dat, ram_dat, data_wr : unsigned(7 downto 0);
+signal rx_dat : unsigned(7 downto 0);
+signal proc_write : std_logic;
+signal one, RX_rdy, csw_usart, csr_usart, tx_rdy : std_logic;
+-- signal cycle_mark : std_logic
+signal rst_bar : std_logic;
+signal ram_write : std_logic;
+
+--signal clk : std_logic;
+--signal clk_pin : std_logic;
+signal counter : unsigned(3 downto 0);
+
+-- I/O ports
+constant led_port : unsigned (15 downto 0) := x"4007";
+constant rs232_dat : unsigned (15 downto 0) := x"4000"; --input and output
+constant uart_stat : unsigned (15 downto 0) := x"4001"; --RX and TX state found here
+constant uart: unsigned (15 downto 0) := x"4000"; --starts the uart transmitting
+
+begin
+
+U1 : P65C02 port map(
+ reset => rst_pin,
+ Clock => clk_pin,
+ data_rd => proc_rd_dat,
+ data_wr => data_wr,
+ address => address,
+ proc_write => proc_write,
+ irq => irq_pin,
+ nmi => nmi_pin);
+-- cycle_mark => cycle_mark);
+
+U2 : UART_RX port map (
+ PG => rst_pin,
+ OSC_10MHz => clk_pin,
+ RX => RX_pin,
+ rx_reg => rx_dat,
+ csr_usart => csr_usart,
+ RX_rdy => RX_rdy);
+
+U3 : UART_TX port map (
+ PG => rst_pin,
+ TX => TX_pin,
+ tx_rdy => tx_rdy,
+ OSC_10MHz => clk_pin,
+ tx_dat => data_wr,
+ csw_usart => csw_usart);
+
+R1 : ghdl_rom port map(
+ rom_dat=>rom_dat,
+ address=>address,
+ wr=>proc_write,
+ clk=>clk_pin,
+ rst=>rst_pin);
+
+R2 : ghdl_ram port map(
+ clk=>clk_pin,
+ rst=>rst_pin,
+ ram_dat=>ram_dat,
+ data_wr=>data_wr,
+ address=>address,
+ wr=>ram_write);
+
+--R3 : Lattice_rom port map(
+-- Reset => rst_bar,
+-- OutClock => clk_pin,
+-- (address(9 downto 0)) => std_logic_vector(Address(9 downto 0)),
+-- unsigned(Q) => rom_dat,
+-- OutClockEn => one);
+
+--R4 : Lattice_ram port map(
+-- Reset => rst_bar,
+-- Clock => clk_pin,
+-- WE => ram_write,
+-- address(9 downto 0) => std_logic_vector(Address(9 downto 0)),
+-- Data => std_logic_vector(data_wr),
+-- unsigned(Q) => ram_dat, ClockEn => one);
+
+one <= '1';
+rst_bar <= not rst_pin;
+one <= '1';
+--u601 <= cycle_mark;
+
+
+
+mux_add : process(rst_pin, clk_pin)
+begin
+if rst_pin = '0' then
+add <= (others => '0');
+elsif rising_edge(clk_pin) then
+ add <= address;
+end if;
+end process;
+
+ram_address : process (proc_write, address(15 downto 14))
+begin
+ if proc_write = '1' and address(15 downto 14) = "00" then
+ ram_write <= '1';
+ else
+ ram_write <= '0';
+ end if;
+end process;
+
+
+
+
+-- ===================================================================
+-- Updated muxer process
+muxer : process (add(15 downto 14), rom_dat, ram_dat, rx_dat, tx_rdy, rx_rdy)
+begin
+if add(15 downto 14) = "11" then
+ proc_rd_dat <= rom_dat;
+end if;
+if add(15 downto 14) = "00" then
+ proc_rd_dat <= ram_dat;
+end if;
+if add(15 downto 0) = rs232_dat then
+ proc_rd_dat <= rx_dat;
+end if;
+if add(15 downto 0) = uart_stat then
+ proc_rd_dat <= tx_rdy & rx_rdy & "000000";
+end if;
+end process;
+-- ===================================================================
+
+rs232_cs : process (rst_pin, clk_pin, address, proc_write)
+begin
+if proc_write = '0' and address = uart then
+ csr_usart <= '1';
+else
+ csr_usart <= '0';
+end if;
+
+if proc_write = '1' and address = uart then
+ csw_usart <= '1';
+else
+ csw_usart <= '0';
+end if;
+end process;
+
+
+
+relay : process (rst_pin, proc_write, address, data_wr(7), clk_pin)
+begin
+if rst_pin = '0' then
+ Pwr_on_pin <= '0';
+ elsif rising_edge(clk_pin) and address = led_port and proc_write = '1' then
+ Pwr_on_pin <= data_wr(7);
+end if;
+end process;
+
+
+end structure;
ghdl/ghdl_processor.vhd
Property changes :
Added: svn:executable
Index: ghdl/Makefile
===================================================================
--- ghdl/Makefile (nonexistent)
+++ ghdl/Makefile (revision 2)
@@ -0,0 +1,63 @@
+# This is to do all the necessary stuff to update and run the files
+wform.vcd : testbench processor p65c02 ghdl_rom ghdl_ram UART_TX UART_RX
+ ghdl -r testbench --vcd=wform.vcd --assert-level=none --stop-time=1ms
+
+65C02.o : 65C02.vhd
+ ghdl -a 65C02.vhd
+
+p65c02 : 65C02.o
+ ghdl -e p65c02
+
+ghdl_rom.o : ghdl_rom.vhd
+ ghdl -a ghdl_rom.vhd
+
+ghdl_rom : ghdl_rom.o
+ ghdl -e ghdl_rom
+
+ghdl_ram.o : ghdl_ram.vhd
+ ghdl -a ghdl_ram.vhd
+
+ghdl_ram : ghdl_ram.o
+ ghdl -e ghdl_ram
+
+UART_TX.o : UART_TX.vhd
+ ghdl -a UART_TX.vhd
+
+UART_TX : UART_TX.o
+ ghdl -e UART_TX
+
+UART_RX.o : UART_RX.vhd
+ ghdl -a UART_RX.vhd
+
+UART_RX : UART_RX.o
+ ghdl -e UART_RX
+
+Processor.o : ghdl_processor.vhd 65C02.o ghdl_ram.o ghdl_rom.o UART_TX.o UART_RX.o
+ ghdl -a ghdl_processor.vhd
+
+processor : Processor.o p65c02 ghdl_rom ghdl_ram UART_TX UART_RX
+ ghdl -e processor
+
+Test_bench.o : Test_bench.vhd
+ ghdl -a Test_bench.vhd
+
+testbench : Test_bench.o processor
+ ghdl -e testbench
+
+
+
+# gtkwave wform.vcd wave_setup.sav
+# crasm -o asm -x asm_code>list
+# sed -f sedscript asm
+# sed -f sedscript asm_code>code
+
+# crasm -o *.o -x *.asm > *.lst
+# sed -f sedscript *.o>*.bin
+
+# asm2bin file
+# crasm -o $1.o -x $1.asm > $1*.lst
+# sed -f sedscript $1.o > $1.bin
+
+
+
+
ghdl/Makefile
Property changes :
Added: svn:executable
Index: ghdl/ghdl_ram.vhd
===================================================================
--- ghdl/ghdl_ram.vhd (nonexistent)
+++ ghdl/ghdl_ram.vhd (revision 2)
@@ -0,0 +1,1124 @@
+------------------------------------------------------------------
+-- 6502 ghdl RAM module.
+--
+-- Copyright Ian Chapman October 28 2010
+--
+-- This file is part of the Lattice 6502 project
+-- It is used to compile with Linux ghdl not ispLeaver.
+-- The executable code is pasted into this module.
+--
+-- To do
+-- Complete.
+--
+-- *************************************************************
+-- Distributed under the GNU Lesser General Public License. *
+-- This can be obtained from “www.gnu.org”. *
+-- *************************************************************
+-- 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 3 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, see
+--
+-- ghdl_ram.vhd
+--
+-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+-- RAM memory is mapped to x0000
+-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+library IEEE; --Use standard IEEE libs as recommended by Tristan.
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+entity ghdl_ram is
+
+Port (
+ clk, wr, rst : in std_logic;
+ data_wr: in unsigned(7 downto 0);
+ ram_dat: out unsigned(7 downto 0);
+ address: in unsigned(15 downto 0)
+ );
+end ghdl_ram;
+
+architecture RTL of ghdl_ram is
+-- type RamType is array (natural range <>) of std_logic_vector(7 downto 0);
+--0 to integer'HIGH
+type RamType is array (0 to 1023) of unsigned(7 downto 0);
+
+signal add : unsigned(15 downto 0);
+signal data_wr_reg : unsigned(7 downto 0);
+signal wr_reg : std_logic;
+
+signal RAM_zero : RamType := (
+
+--signal RAM_zero : RamType(0 to 1023) := (
+-- I needed something for data so this is old ROM stuff.
+X"A9", --0
+X"00",
+X"8D",
+X"12",
+X"02",
+X"A0",
+X"43",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"4E",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"54", --10
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"72", --20 r
+X"66", --f
+X"63", --c
+X"30", --0
+X"35", --0
+X"0d", --cr
+X"18",
+X"69",
+X"78",
+X"20",
+X"D5",
+X"FF",
+X"A0",
+X"5A",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"F0",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"46",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"43",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"90",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"65",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"4E",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"10",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"84",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"56",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"50",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"A3",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"AE",
+X"12",
+X"02",
+X"E8",
+X"8A",
+X"29",
+X"0F",
+X"8D",
+X"12",
+X"02",
+X"A0",
+X"0A",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"05",
+X"FF",
+X"AD",
+X"01",
+X"40",
+X"29",
+X"80",
+X"D0",
+X"F9",
+X"8C",
+X"00",
+X"40",
+X"60",
+X"30",
+X"31",
+X"32",
+X"33",
+X"34",
+X"35",
+X"36",
+X"37",
+X"38",
+X"39",
+X"41",
+X"42",
+X"43",
+X"44",
+X"45",
+X"46",
+X"8D",
+X"14",
+X"02",
+X"98",
+X"18",
+X"6A",
+X"6A",
+X"6A",
+X"6A",
+X"29",
+X"0F",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"14",
+X"02",
+X"29",
+X"0F",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"60",
+X"40",
+X"40",
+X"EA",
+X"EA",
+X"00",
+X"FF",
+X"F4",
+X"FF",
+X"00",
+X"FF",
+X"F5",
+X"FF",
+X"72", --100 r
+X"66",
+X"30",
+X"33",
+X"0d",
+X"A0",
+X"43",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"4E",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"54",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"20",
+X"D5",
+X"FF",
+X"A0",
+X"5A",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"F0",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"46",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"43",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"90",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"65",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"4E",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"10",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"84",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"56",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"50",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"A3",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"AE",
+X"12",
+X"02",
+X"E8",
+X"8A",
+X"29",
+X"0F",
+X"8D",
+X"12",
+X"02",
+X"A0",
+X"0A",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"05",
+X"FF",
+X"AD",
+X"01",
+X"40",
+X"29",
+X"80",
+X"D0",
+X"F9",
+X"8C",
+X"00",
+X"40",
+X"60",
+X"30",
+X"31",
+X"32",
+X"33",
+X"34",
+X"35",
+X"EA",
+X"36",
+X"37",
+X"38",
+X"39",
+X"41",
+X"42",
+X"43",
+X"44",
+X"45",
+X"46",
+X"8D",
+X"14",
+X"02",
+X"98",
+X"18",
+X"6A",
+X"6A",
+X"6A",
+X"6A",
+X"29",
+X"0F",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"14",
+X"02",
+X"29",
+X"0F",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"60",
+X"40",
+X"40",
+X"EA",
+X"EA",
+X"00",
+X"FF",
+X"F4",
+X"FF",
+X"00",
+X"FF",
+X"F5",
+X"72", --200 r
+X"66",
+X"63",
+X"30",
+X"34",
+X"0d",
+X"39",
+X"39",
+X"39",
+X"39",
+X"FF",
+X"A0",
+X"4E",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"54",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"20",
+X"D5",
+X"FF",
+X"A0",
+X"5A",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"F0",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"72", --240
+X"66",
+X"63",
+X"30",
+X"30",
+X"0d",
+X"00",
+X"00",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"43",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"90",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"65",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"4E",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"10",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"84",
+X"FF",
+X"00", --281
+X"06", --281
+X"06",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"56",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"50",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"A3",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"AE",
+X"12",
+X"02",
+X"E8",
+X"8A",
+X"29",
+X"0F",
+X"8D",
+X"12",
+X"02",
+X"A0",
+X"0A",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"05",
+X"FF",
+X"AD",
+X"01",
+X"40",
+X"29",
+X"80",
+X"D0",
+X"F9",
+X"8C",
+X"00",
+X"40",
+X"60",
+X"30",
+X"31",
+X"32",
+X"33",
+X"34",
+X"35",
+X"EA",
+X"36",
+X"37",
+X"38",
+X"39",
+X"41",
+X"42",
+X"43",
+X"44",
+X"45",
+X"46",
+X"8D",
+X"14",
+X"02",
+X"98",
+X"18",
+X"6A",
+X"6A",
+X"6A",
+X"6A",
+X"29",
+X"0F",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"14",
+X"02",
+X"29",
+X"0F",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"60",
+X"40",
+X"40",
+X"EA",
+X"EA",
+X"00",
+X"FF",
+X"F4",
+X"FF",
+X"00",
+X"FF",
+X"F5",
+X"FF",
+X"A9",
+X"00",
+X"8D",
+X"12",
+X"02",
+X"A0",
+X"43",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"4E",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"54",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"20",
+X"D5",
+X"FF",
+X"A0",
+X"5A",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"F0",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"46",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"43",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"90",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"65",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"4E",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"10",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"84",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"56",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"12",
+X"02",
+X"18",
+X"69",
+X"78",
+X"50",
+X"08",
+X"A0",
+X"31",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"A3",
+X"FF",
+X"A0",
+X"30",
+X"20",
+X"BA",
+X"FF",
+X"A0",
+X"20",
+X"20",
+X"BA",
+X"FF",
+X"AE",
+X"12",
+X"02",
+X"E8",
+X"8A",
+X"29",
+X"0F",
+X"8D",
+X"12",
+X"02",
+X"A0",
+X"0A",
+X"20",
+X"BA",
+X"FF",
+X"4C",
+X"05",
+X"FF",
+X"AD",
+X"01",
+X"40",
+X"29",
+X"80",
+X"D0",
+X"F9",
+X"8C",
+X"00",
+X"40",
+X"60",
+X"30",
+X"31",
+X"32",
+X"33",
+X"34",
+X"35",
+X"EA",
+X"36",
+X"37",
+X"38",
+X"39",
+X"41",
+X"42",
+X"43",
+X"44",
+X"45",
+X"46",
+X"8D",
+X"14",
+X"02",
+X"98",
+X"18",
+X"6A",
+X"6A",
+X"6A",
+X"6A",
+X"29",
+X"0F",
+X"AA",
+X"BC",
+X"C5",
+X"FF",
+X"20",
+X"BA",
+X"FF",
+X"AD",
+X"14",
+X"29",
+X"0F",
+X"AA",
+X"BC",
+X"C5",
+X"C5",
+X"FF",
+X"BA",
+X"40",
+X"40",
+X"00",
+X"FF",
+X"00",
+X"FF",
+X"F4",
+X"FF",
+X"00",
+X"FF",
+X"F5",
+X"FF" ) ;
+
+
+
+
+begin
+
+addressing:process(clk, address, data_wr)
+begin
+if rst = '0' then
+ add <= (others => '0');
+ data_wr_reg <= (others => '0');
+ wr_reg <= '0';
+elsif rising_edge(clk) then
+ add <= address;
+ data_wr_reg <= data_wr;
+ wr_reg <= wr;
+end if;
+end process;
+
+read_ram:process(wr, add)
+begin
+ if wr = '0' and add(15 downto 10) = "000000" then --zero page
+ ram_dat <= (RAM_zero(to_integer(unsigned(add(9 downto 0)))));
+end if;
+end process;
+
+write_ram:process(wr, data_wr_reg, add)
+begin
+if rising_edge(clk) then
+ elsif wr_reg = '1' and add(15 downto 10) = "0000000" then
+ RAM_zero(to_integer((add(9 downto 0)))) <= (data_wr_reg);
+ end if;
+end process;
+
+end RTL ;
+
+
ghdl/ghdl_ram.vhd
Property changes :
Added: svn:executable
Index: ghdl/Test_bench.vhd
===================================================================
--- ghdl/Test_bench.vhd (nonexistent)
+++ ghdl/Test_bench.vhd (revision 2)
@@ -0,0 +1,133 @@
+
+-- VHDL Test Bench Created from source file Processor.vhd -- 07-MAY-2008 01:09:40
+--- 25 October 2010 Ian Chapman
+-- ******************************************************
+---- Distributed under the GNU General Public License. *
+---- This can be obtained from “www.gnu.org”. *
+-- ******************************************************
+-- 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 3 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, see
+--
+-- Notes:
+-- 1) This testbench template has been automatically generated using types
+-- std_logic and std_logic_vector for the ports of the unit under test.
+-- Lattice recommends that these types always be used for the top-level
+-- I/O of a design in order to guarantee that the testbench will bind
+-- correctly to the timing (post-route) simulation model.
+-- 2) To use this template as your testbench, change the filename to any
+-- name of your choice with the extension .vhd, and use the "source->import"
+-- menu in the ispLEVER Project Navigator to import the testbench.
+-- Then edit the user defined section below, adding code to generate the
+-- stimulus for your design.
+-- 3) VHDL simulations will produce errors if there are Lattice FPGA library
+
+-- elements in your design that require the instantiation of GSR, PUR, and
+-- TSALL and they are not present in the testbench. For more information see
+-- the How To section of online help.
+--
+LIBRARY ieee;
+USE ieee.std_logic_1164.ALL;
+USE ieee.numeric_std.ALL;
+
+ENTITY testbench IS
+END testbench;
+
+ARCHITECTURE behavior OF testbench IS
+
+ COMPONENT Processor
+ PORT(
+ clk_pin : IN std_logic;
+-- data_wr : inout unsigned(7 downto 0);
+ Pwr_on_pin : out std_logic;
+ rst_pin, irq_pin, nmi_pin : IN std_logic;
+ RX_pin : in std_logic;
+ Tx_pin : out std_logic
+ );
+ END COMPONENT;
+
+ SIGNAL clk : std_logic;
+ signal RX_pin, TX_pin : std_logic;
+ SIGNAL rst, nmi, irq : std_logic;
+-- signal data_wr : unsigned(7 downto 0);
+
+BEGIN
+
+-- Please check and add your generic clause manually
+ uut: Processor PORT MAP(
+ clk_pin => clk,
+ irq_pin => irq,
+ nmi_pin => nmi,
+ RX_pin => RX_pin,
+ TX_pin => TX_pin,
+-- data_wr => data_wr,
+ rst_pin => rst
+ );
+
+
+-- *** Test Bench - User Defined Section ***
+
+clock : process
+
+ begin
+ clk <= '0';
+ wait for 50 ns;
+ clk <= '1';
+ wait for 50 ns;
+end process;
+reset: process
+ begin
+ rst <= '0';
+ wait for 175 ns;
+ rst <= '1';
+ wait; -- will wait forever
+
+ END PROCESS;
+
+--rx_232 : process
+-- begin
+-- RX_pin <= '1';
+-- wait for 5 us;
+-- RX_pin <= '0';
+-- wait for 104 us;
+-- RX_pin <= '1';
+-- wait for 208 us;
+-- RX_pin <= '0';
+-- wait for 104 us;
+-- RX_pin <= '1';
+-- wait for 208 us;
+-- RX_pin <= '0';
+-- wait for 208 us;
+-- RX_pin <= '1';
+-- WAIT;
+--END PROCESS;
+
+
+
+interrupt: process
+ begin
+ irq <= '1';
+ nmi <= '1';
+ wait for 2 us;
+ irq <= '1';
+ nmi <= '1';
+ wait for 100 ns;
+ irq <= '1';
+ nmi <= '1';
+
+ wait; --will wait forever
+
+ END PROCESS;
+-- *** End Test Bench - User Defined Section ***
+
+END behavior;
+
ghdl/Test_bench.vhd
Property changes :
Added: svn:executable