Skip to content

Commit

Permalink
Merge pull request #32 from jamesjiang52/ram
Browse files Browse the repository at this point in the history
Remove processor classes, will be rewritten later
Lots of misc changes
Added condition code flags and stack pointer for processor
  • Loading branch information
jamesjiang52 committed Feb 9, 2019
2 parents 9d2a3f8 + d4b8a17 commit dd70241
Show file tree
Hide file tree
Showing 17 changed files with 1,642 additions and 994 deletions.
303 changes: 250 additions & 53 deletions bitwise/processor/ALU.py

Large diffs are not rendered by default.

109 changes: 0 additions & 109 deletions bitwise/processor/BUS.py

This file was deleted.

64 changes: 64 additions & 0 deletions bitwise/processor/FLAG.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"""
The following classes are defined:
ConditionCodeFlags
"""

from .. import wire
from .. import gate
from .. import storage

Wire = wire.Wire
Bus4 = wire.Bus4
Bus8 = wire.Bus8
Bus16 = wire.Bus16


class ConditionCodeFlags:
"""Construct a new set of condition code flag flip-flops.
Args:
data_bus: An object of type Bus16. The data input to the flip-flops.
overflow: An object of type Wire. The overflow input.
carry_out: An object of type Wire. The carry-out input.
clock: An object of type Wire or Clock. The clock input to the
flip-flops.
z: An object of type Wire. Indicates when the value on data_bus is
equal to zero.
v: An object of type Wire. Indicates when an arithmetic operation
produces an overflow.
n: An object of type Wire. Indicates when the value on data_bus is
negative.
c: An object of type Wire. Indicates when an arithmetic operation
produces a carry-out.
"""
def __init__(self, data_bus, overflow, carry_out, clock, z, v, n, c):
if len(data_bus) != 16:
raise TypeError(
"Expected bus of width 16, received bus of width {0}.".format(
len(data_bus)
)
)

z_not = Wire()
v_not = Wire()
n_not = Wire()
c_not = Wire()

or_1 = Wire()
or_2 = Wire()
or_3 = Wire()
or_4 = Wire()
or_5 = Wire()
not_or = Wire()

gate.ORGate4(*data_bus[0:4], or_1)
gate.ORGate4(*data_bus[4:8], or_2)
gate.ORGate4(*data_bus[8:12], or_3)
gate.ORGate4(*data_bus[12:16], or_4)
gate.ORGate4(or_1, or_2, or_3, or_4, or_5)
gate.NOTGate(or_5, not_or)

storage.DFlipFlop(not_or, clock, z, z_not)
storage.DFlipFlop(overflow, clock, v, v_not)
storage.DFlipFlop(data_bus[0], clock, n, n_not)
storage.DFlipFlop(carry_out, clock, c, c_not)
Loading

0 comments on commit dd70241

Please sign in to comment.