Skip to content

Commit 2b9ebdb

Browse files
committed
📝 Finished version 1 of documents
1 parent 94e98e4 commit 2b9ebdb

25 files changed

+1466
-28
lines changed

build/doctrees/environment.pickle

5.27 KB
Binary file not shown.

build/doctrees/implespec.doctree

2.13 KB
Binary file not shown.

build/doctrees/implspec.doctree

17.5 KB
Binary file not shown.

build/doctrees/index.doctree

16 Bytes
Binary file not shown.

build/doctrees/memory.doctree

4.09 KB
Binary file not shown.

build/doctrees/units.doctree

49.8 KB
Binary file not shown.

build/html/_sources/implespec.rst.txt

Whitespace-only changes.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
Implementation Specific (implspec.py)
2+
=====================================
3+
4+
5+
This page contains informations about the :ref:`utility` functions
6+
needed to operated the CPU such as generating bits, inverting bits,
7+
bit and reading bits.
8+
9+
.. _utility:
10+
11+
Utility Functions
12+
*****************
13+
14+
These functions exist due the the implementation in Python and to
15+
make testing the functions and methods easier. The logic remains
16+
the same without these functions.
17+
18+
Push to Tuple
19+
-------------
20+
21+
`Push to tuple` takes in an `n` sized array of binary values and
22+
creates a tuple of binary values **Tuple-binary**.
23+
24+
.. TIP::
25+
The bits are reversed to make trailing zeros important
26+
For example: ``1,0,0, 0...`` is 4 (in binary) but will not be recognised
27+
because when pushed to the tuple it will be ``(...,0,0,1)`` is
28+
which means 1 (in binary). When reversed: ``0,0,1,...`` and pushed
29+
to a tuple it will be ``(0,0,1,...)``
30+
31+
.. HINT::
32+
Tuple-binary values are always in reverse binary order. Where the
33+
left most bit is the least and the vice-versa.
34+
35+
.. _generate-bits:
36+
37+
Generate X Bits
38+
---------------
39+
40+
Generator function exists to make writing tests and inputs easier. Without
41+
this function I would have to `'cheat'` in a sense and use string subscripting
42+
with integer conversion.
43+
44+
There are `4`, `8` and `16` bit generators.
45+
46+
They take in a one `n-bit binary number` (where n < specified-bit).
47+
48+
Returns a tuple-binary of size `n`.
49+
50+
.. code-block::
51+
52+
generate8Bits(0b10)
53+
Output: (0,1,0,0,0,0,0,0)
54+
55+
generate16Bits(0b10)
56+
Output: (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
57+
58+
Generate Stream Bits
59+
--------------------
60+
61+
Due the implementation of the :ref:`generate-bits`, the 16-bit variant of :ref:`stream-bits`
62+
needs to be of size 16.
63+
64+
Where the function does this:
65+
66+
.. code-block::
67+
68+
if bit == 1:
69+
return 0b1111111111111111
70+
else:
71+
return 0b0000000000000000
72+
73+
Call the function ``generateStreamBits`` and provide one 1-bit value.
74+
75+
.. code-block::
76+
77+
generateStreamBits(1)
78+
Output: 65535 # decimal representation
79+
80+
Tuple to Binary
81+
---------------
82+
83+
Tuple-to-binary takes in a tuple-binary of size `n` and produces
84+
a value of size `n` in an integer representation (it will be of type ``int``
85+
in Python).
86+
87+
The argument supplied is the `tuple-binary`.
88+
89+
The return value is an `integer`.
90+
91+
.. code-block::
92+
93+
tupleToBinary((1,0))
94+
Output: 2 # decimal representation
95+
96+
.. Decimal to Binary
97+
.. -----------------
98+
..
99+
.. Decimal-to-binary takes in a decimal number
100+
101+
Less Than Zero
102+
--------------
103+
104+
In order to determine if a number is negative (less than zero) the 16th
105+
bit is read. If it's 1 then the number is negative.
106+
107+
The argument supplied is the `tuple-binary`.
108+
109+
The return value is an `integer`, 1 if its true, zero if false.
110+
111+
.. code-block::
112+
113+
isLessThanZero((1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0))
114+
Output: 1
115+
116+
isLessThanZero((0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1))
117+
Output: 0
118+
..
119+
.. Reverse Bits
120+
.. ------------
121+
..
122+
.. Reverse-bits reverses the order of the supplied tuple-binary.
123+
..
124+
.. The argument supplied is the `tuple-binary`.
125+
..
126+
.. The return value is the reversed `tuple-binary`.

build/html/_sources/index.rst.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ A 16-bit CPU built in Python by Neo Sahadeo.
55

66
.. toctree::
77

8+
implspec
89
units
910
memory
1011
processor

build/html/_sources/memory.rst.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,21 @@ The return value is the `16_bit_binary`.
192192
register.read()
193193
Output: 2
194194
195+
.. _program-counter:
196+
197+
Program Counter
198+
***************
199+
200+
The `Program Counter` is a `register` and a :ref:`increment-16` linked togther
201+
with the option to use a different starting value other than ``0``.
202+
203+
The ``Counter`` class can be used by calling the ``inc`` method.
204+
205+
The arguments needed are a stream-bit (see :ref:`stream-bits`), a `16-bit binary number` and a :ref:`clock-cycle`
206+
207+
The returned value is the `next incremented value` or if the stream-bit is enabled it will
208+
be the supplied `16-bit binary number` (which comes from `register 'a'`).
209+
195210
.. _ram:
196211

197212
Random Access Memory

0 commit comments

Comments
 (0)