so in the last video we started building
the 16 byte memory which is able to
store 16 bytes we've got the 4 address
lines here to select which of the 16
bytes we're reading or writing to we've
got 8 data lines for inputting the data
that we're going to write into the the
memory location that's selected with the
address line and we've got our 8 outputs
that are buffered through this 8-bit
tri-state buffer so we can output to to
a bus in this video what I want to do is
you know start to connect the address
lines here to our address register and
since the memory address is just 4 bits
we can we can use the 74 LS 173 that
we've used in the past which is a 4-bit
register so I'm going to start by just
getting another breadboard and
connecting it up here like that I'm also
going to remove this this top one and
and connect the clock module that we
built in some of the earlier videos and
it's not that the clock module is
directly related to the memory at all
but just the final layout of the
computer we're going to have the clock
module just above the the RAM and so now
that gives us room in here that we can
go ahead and put together our memory
address register which is going to
connect into our memory address lines
here so I'm going to get these out of
the way for now just move them all down
here just give ourselves a little bit
more room so the memory address register
we're going to use the 74 LS 173 that
we've that we've used many times before
for registers and I'll hook that up over
here that's going to be connected to the
bus because at various points we're
going to have memory address up here on
the bus and we'll want to bring that in
and store that in the memory address
register which will then be connected to
our memory to tell it what address to to
address and and then once that address
is set there then we'll either output
contents from the bus or we might input
a new value from the bus
into the memory but while we're
inputting are outputting from the memory
we need to store the address to which
we're storing or reading from in this in
this address register so we could just
you know it seems like it'd be simple
enough to just take these address lines
and hook them up to this register and
then whatever stored in that register
will be the address that they were
pointing to in our in our memory here
but we don't want to just do that we
also want to be able to program the
computer and when we program the
computer we basically want to just
switch the the memory into a totally
different mode where we're able to set
the address and set the data by hand
with with like dip switches like this
and so we want to have some switches
here that allow us to set what address
where we're pointing to and then we'll
have another set of dip switches where
we can set the data that we want to
write into that memory location so we
can program the computer by hand and
then we want to be able to switch out of
programming mode and use this register
so we basically want to we want these
address lines to either be hooked up to
the register or so that the memory can
be addressed by you know data coming in
from the bus or an address coming in
from the bus or we want to be able to
set the address with these switches and
we want to be able to switch between
those two things you know you can
imagine we've got four bits over here of
address and we've got four bits over
here of address set on these switches
how do we switch between those well this
is this is a fairly straightforward
circuit that you can we can kind of
Reason through that allows us to select
between two different values so for
example and this is just one bit so for
example the first bit of our address
that's stored in our register might be a
and the first bit of our address on the
switches might be B and then we can
select which of those we want to use
using the Select signal and you can kind
of see how that works where if select is
high then this input to the and gate
will be a 1 which means that if this
other input to the N gate is a 1 then
the output is a 1 if this inputs a 0
then the output
so if we're if select is a 1 then this a
signal is just basically going to pass
through the and gate and because this is
inverted this and gate will definitely
always be a 0 because we'll have a 0
coming in here and then the or gate will
just be whatever is coming in hey if
select goes low then this and gate is
basically always going to be off because
we'll have a 0 coming in here and we'll
have a 1 coming in here so this an gate
will pass through the B and then of
course the or gate will be a 0 or
whatever B is and so the output will
just be whatever it B is and so by
setting the Select high or low we're
selecting whether we want a or b to
appear on this output conveniently there
is a chip that does exactly this it's
the 74 LS 157 which is a quad 2 line to
one line data selector so we're
selecting between you know from two
lines to one line which is which is kind
of what we just described and you can
see here on the datasheet it has
essentially four copies of that of that
circuit so you can see the two and gates
in the or gate which is what we were
just looking at here the two main gates
in the or gate and then the inverter
down here for select that's inverting
depending on which whether whether we're
selecting the a the four A's or the four
B's so the single select that selects
between all four A's or all four B's
this also you can see there's a third
input on all of these and gates that
goes to this strobe which is basically
just kind of a master enable so as long
as this strobe is low then this third
input all these and gates will be a one
and essentially that enables the whole
chip so we'll just tie this low for for
our purposes and and then it'll it'll
essentially just behave like like this
circuit that I just showed you so if you
look at the pin out for the 74 LS 157
you can see of course we have our select
input selecting a or B and then you can
see there's an a B and an output a B and
an output a B and an output a B and an
output so it's basically four of
these that are all tied to a single
select and then of course we have our
ground and our power and then this
strobe line which I say will will tie
low to just to enable the thing so this
74 LS 157 will basically allow us to
select you know and toggle between do we
want to use the switches to set the
address of our memory or do we want to
use the memory register to set the
address of our memory so go ahead and
add the 74 LS 157 here we can connect
the power and ground here so we can
connect the power for that guy and then
remember this pin 15 is this strobe
which we just want to set low to enable
this chip so we'll just set that low and
then while we're here I can also connect
the power for our address register the
74 LS 173 so power and ground pull these
LEDs out of here and we're just using
those for testing so we get that powered
up and then the 74 LS 173 this is what
it looks like and remember again you
know it's got four D flip-flops that are
there storing our four bits in our
register and we have you know our output
control which if one in pins 1 & 2 are
low then our output is enabled and we
always want that to be the case so we'll
go ahead and tie pins 1 & 2 low so that
our output is always enabled and then we
also have our our data enable pins 9 and
10 and that controls whether the input
which is going to come from the bus is
is being clocked in on the clock pulse
so this is going to be a control signal
to tell it to store whatever is on the
bus in this register so that's pins 9
and 10 so I'll hook pins 9 and 10
together and then that's just a control
signal that will need to set either high
or low to control whether we're storing
a new value in here then pin 7 is our
clock so we can hook that up to
our clock up here which we've now gotten
near by now these four pins here 11 12
13 and 14 are the the inputs for our
register and so those will be connected
off to our bus at some point and then
our outputs are pins 3 4 5 and 6 so we
can connect the outputs to one of the
the 2 inputs of the one of the 74 LS 157
right because it has these a and B
inputs for the 4 the 4 bits that it that
it has so let's go ahead and connect the
4 bits of the register to the through
the 4 B inputs and then we'll connect
our dip switches to the a inputs okay so
now the outputs of our memory address
register are going into one of the
inputs of our 157 74 LS 157 selector so
we'll be able to select either this or
the the dip switches so now to hook up
the dip switches to the other input of
the 74 LS 157 what I want to do is take
advantage of the way that the inputs on
these chips work which is for for most
of these TTL chips that we're using the
inputs are are tied hi there's a
resistor inside these these chips that
connects the input 2 to +5 volts so if
we don't connect the switches to here at
all then the a inputs on on this will
all be ones by default and if we then
connect some of the inputs to ground
then those inputs that we connect to
ground will be zeros and the rest of the
inputs that aren't connected will be
ones so what we can do is we can connect
this to the switches and then the
switches we can use to selectively
connect a pin to ground or not so for
example for the first bit here pin - is
that a input pin 3 is the B input and
pin 4 is the output so for the B input
we've already have that connected up to
our register for the a input I can
connect that to the first switch here on
our dip switch
and if it's off like this then it's not
connected this is going to be a 1 if I
turn it on then it will complete the
circuit over to this side and if I
connect that side to ground then turning
this on will connect this to 0 and so on
is 0 and then off will be a 1 because
it's not connected and I can do the same
thing for the second bit just connect
the second switch to the a input of our
second selector here and connect the
other side of the switch again to ground
and so if the switch is off then this
input is default to a 1 if the switch is
on then it connects it to ground and it
takes this down to a zero same thing for
the third bit in this case the input is
up here on on the top side of the chip
so I can just kind of run through the
the switch the other way and connect the
ground down here and so then again if
the switch is on then it connects the
ground to that pin if it's off then it
doesn't and so then it defaults to a 1
and then finally for the last bit I can
do the same thing and connect to ground
here one thing that's a little bit
confusing about this is that when the
switches are in the down position here
when they're off then basically we're
inputting all ones and if they're up
like this they're all up there all on
that means that where we are connecting
all of these inputs to ground and so
we're inputting all zeros so it might be
a little bit confusing because usually
you would think down would be zero and
up would be a 1 fortunately there's a
pretty easy solution to that which is
turn the switch around so that when the
switch is down it's on and when it's up
it's off so now we have the 74 LS 157
which can select between either the dip
switch input or the address register
input but we need to have some way of
telling it which one we want so I'm
going to add a switch here that we can
toggle between the dip switches and
their address register and this is a
double throw switch so we can
connect the center pin here to ground
and then depending on whether which
position the switch is in whether we
have pushed in or or pushed out it'll
connect that ground to either the left
panel or the right pin and so something
I want to do just to make this a little
bit I don't know maybe a little nicer to
use is have some indicator LEDs to tell
us which position the switch is in you
can look at the switch and see but I
like having these indicators we can tell
if the computer which mode the computer
is in because we definitely want to be
able to tell pretty easily whether the
computer is in programming mode which
will be the red LED on or in run mode
which means the green LED is on so it'll
do is connect the switch up here to both
these LEDs so one side of the switch to
the red LED and the other side of the
switch to the green LED and then the
other side of the LED will hook up to
our 5 volts through these current
limiting resistors and we need currently
many resistors here you know because
we're connecting when whichever position
the switch is in we're going to be
connecting directly from 5 volts through
the LED to ground and so without a
current limiting resistor will be
pushing tons of current through the LED
and we'll burn it out we don't need
those in these cases because these chips
have resistors you know essentially
resistors on the collector side of the
outputs so it's already going to limit
the current that it can drive but in
this case we do need them and so if I go
ahead and connect up some power here
just to kind of show you what we've what
we've got so far let me just hook up
connect my power all the way through
here and then hook up power to this
whole board of course we've got a clock
going and something in our memory but
what you'll see now is depending on how
we toggle the switch it selects either
green or red basically but the other
thing that happens is what this is
really doing is selecting which of these
two things is grounded and so in this
case the red LED here is grounded in
this case the green LED is grounded too
you know complete the circuit from the 5
volts through the resistor here and so
what we can do is we can connect
the red LED side here to pin one of the
74 LS 157 and pin one is the Select pin
which selects which of the two inputs
we're going to use and so if we're on
the the red LED essentially pin one then
goes low and we're let's see which one
are we selecting so select is low then
it looks like we're we're selecting the
a input so if we're on the red LED so if
pin one is low then we're selecting a
which is our dip switches so red LED on
means that we're using our dip switches
which means we're in programming mode
because we're using a dip switches to
program the computer and then if we
switch modes here then this is no longer
connected and so pin one will default to
being high in which case it's going to
use input two or be rather input B which
is our register over here and so we're
going to be using the address register
of course this will make a lot more
sense if we hook up the outputs of the
74 LS 157 so we actually see what's
going on okay so there's our outputs and
now if we start here in run mode it's
going to you know that our output here
will be whatever we've got in the
register which appears to be all zeros
either that or it's not working right
and if we switch to program mode then
the output here should reflect whatever
our dip switches show so 0 0 1 1 makes
sense we turn those off it's all zeros
and you can see it's it's just you know
whatever we put in our dip switches here
is what we're getting out here and if we
switch back to run mode you see we get
all zeros and that's presumably what is
stored in this register and we can try
to get something else in this register I
think if we set the input signal low
here we should see well I would expect
it to read in all ones because none of
these inputs are connected
oh but our a reset signal is also not
connected so this is constantly being
reset so pin 15 is the clear signal so
we want to keep that high
actually I think we want to keep it low
right okay that might make more sense
yeah so we want to we want our clear
signal to be low so that we're not
constantly clearing this right because
it would it would be defaulting to be
high and then if we bring our data
enable low then it should read in
whatever is on the bus here which is
which is going to default to all ones
but we could try hooking a couple of
these bits let's just hook up two bits
here to ground and then set our our
input signal low okay and then on the
next clock cycle and read that in and so
that's what's in this register now okay
so it looks like we can we can input a
value into this register and it shows up
here if we're in run mode and then if we
switch over to program mode then we get
whatever we set on these switches so now
all we need to do is just hook up our
outputs here which right now we're just
going to these LEDs and actually hook
them into the memory address input of
our of our actual memory
okay so now I've got our outputs hooked
up to our address line inputs of our
memory so let's go ahead and power this
back up again and so we can see it came
up so we're in program mode so the zero
one zero one that we have in our dip
switches is what we're seeing here and
we're seeing something random in memory
so we don't really know what that is but
if we change the address we should see
different things and there we go so if
we go to address zero we see that we go
to address one we see something
different address two something
different address three something
different so there's something different
in each address I mean I guess we don't
know for sure if we're addressing it
right but I I mean it seems reasonable
that if we're going to different
addresses here we're getting different
things and if we switch out of program
mode to run mode we see this goes back
to zero and we see that we get this
whatever random thing was in address
zero so it looks like we're able to
switch between run and program mode and
in run mode we're going to be using
whatever is in our memory address
register and actually we can try to put
that value back in here if we switch
this over there yep and we can see when
that changes we got to a different
address here if we go back to program
mode we have the same address set here
so we see the same thing here if we
change address yeah it looks like it
looks like we're able now to change our
address either in programming mode with
our dip switches or we go to run mode
it's looking at whatever is in our
memory address register here which we
can set by putting some value on these
four pins here which which will be
connected to the bus and then we'll have
a control signal to read from the bus so
great now in the next video we will try
to do the same thing for our for our
data lines because again when we're in
program mode we want to be able to use
the dip switch to set our eight data
line so we can set an address we can set
data and then we can write that data
into the memory and then we can switch
back to run mode and instead of using
the difficulty that we'll use whatever
is on the bus so in the next video we'll
basically do the same thing that we just
did
for data lines and that should wrap up
everything we need for our memory
section