I built my own graphics card

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you know homebrew cpus are one thing and by this point you all know that i've lost my mind enough to try and build one of those but they're kind of a dime a dozen these days i feel like everyone and their mom kind of has one already but homebrew transistor transistor logic graphics cards built on breadboards that's a whole other story little harder to get your hands on one of those and that's exactly what we're building [Music] today so when i say transistor transistor logic graphics card built on breadboards what exactly do i mean well just so everyone is on the same page transistor transistor logic is the type of logic implemented by these little things integrated circuits or ics which are the basic building block of this graphics card each one of them runs on five volts and implements various functions like boolean logic counting arithmetic operations and the like a graphics card of course is something that takes video data and generates something that a display can show ours won't be so card like but i'm going to keep calling it that for branding purposes and finally a breadboard is one of these things a prototyping board with the horizontal and vertical pins connected which we'll be throwing our ics on to build the thing and with that out of the way the key to understanding how the circuit needs to work is understanding how the signal it needs to generate works in our case this is a pal composite video signal you know like the one that's been used since the early 20th century with those old school yellow cables we need to figure out how to send the video data through a wire like that so that something on the other end can make sense of it so starting from a point of near zero knowledge i went off to do some research and after i'd read for a while off of various websites i found around the internet they all seem to have this diagram on them to explain what the deal with composite video was so let's take a look at it the basics to understand it are the signal is analog meaning in contrast to digital it doesn't operate on zeros and ones but rather variable voltage between zero volts and one volt the signal is interlaced and runs at 50 hertz this means that we send 50 frames per second but instead of sending one whole video frame at a time we actually sent one half of the frame each time we send data alternating then between the even lines and the odd lines the resolution of the signal is something like 720 by 576 pixels give or take a few depending on how the tv scans things but we'll be operating in a much lower resolution and i mean much lower we're going with 208 pixels across by 240 pixels high also a whole bunch of these websites include a bunch of stuff about a color blast or something that i didn't really understand or even read about it looks like it was kind of hacked in there since composite video was originally only supposed to be black and white but since i don't really want to worry about that we're only going to be making black and white video this also makes my job much easier and saves us some video memory since now each pixel can be represented by just one bit or just one zero or one after my initial research i had to actually first find a screen that could display this sort of composite video signal nowadays everything is fancy and digital and uses wack-ass signals like hdmi and displayport to find the few decades old screen that would actually be displaying our signal i went down on the town to find the finest monitor that 100 danish crowns could buy some off-brand digital thing with a thin green line down the middle but it turns on just fine it has the right port so it should be good enough for my purposes anyway we'll worry about the exact contents of the signal later on my first task was kind of just to assimilate this knowledge into my brain and try to generate the signal in software before i even started thinking about it in hardware luckily i had the perfect test bed for this sort of thing on arduino these things if you don't know what they are are basically a convenient little microcontroller mounted on a circuit board and if you don't know what a microcontroller is it's basically a programmable really really really underpowered and specialized computer used for controlling electronics and if you don't know what a computer is or what electronics are well you're kind of a lost cause how do you get to this video anyway typically you would program the arduino in this custom processing like language with a fancy ide and all but i realized really quickly that this just wouldn't be fast enough to generate the video signal so i had to crack open vim and bust out the old c skills once more i am inevitable [Music] and after many hours of course of beating my head against a circuit board shaped wall i was able to get the arduino spitting something out that resembled a real video signal it was a little messed up but to start with i mean anything is better than nothing and with some more attempts at getting things to work reaching various levels of success as you can see here i eventually got a stable image drawing well by image i kind of just mean a white square but you know that's definitely progress and there was still this weird thing happening near the top with the square that i kind of had to figure out but soon after that i had some vertical lines drawing showing that the arduino was actually making pixels and not just one big wide block and eventually i fixed up this bendy issue at the top so that there were stable vertical lines on the screen turns out this exercise was actually really useful since it helped me a lot in understanding how the video signal should actually look anyway on to the next step making a circuit for this bad boy so while this runs on in the background i'll explain exactly how this works the circuit runs with a four megahertz clock so each clock cycle is exactly 250 nanoseconds or there are four million clock cycles per second it's based around two counters one 10-bit counter to count every half scan line up to a total of 624 per frame and another 8-bit counter to count 256 times each scan line i call these the half scan scanline or hsc counter and tick or tkc counter respectively the 10-bit counter is incremented once every 128 clock cycles so it rolls over 50 times a second and the 8-bit counter is incremented with every clock cycle so it rolls over every 64 microseconds which is exactly the length of one scan line so now if we take a better look at the signal we can understand why these two counters need to be how they are so let's pull this diagram back up and take a closer look at it the signal actually has four different parts but ours will have six since i've added in some blank padding space on either end of the actual video data these are just empty or black scan lines this means that out of our 624 half scan lines the 10-bit counter goes through five equalization pulses five post equalization pulses 32 scan lines or 64 count of blank scan lines 240 scan lines or 480 count where we send actual pixel data to the screen then 32 more blank scan lines and finally six pre-equalization pulses for a total of 624 half scan lines or 312 scan lines similarly the tick counter divides up into four different periods for each part of the scan line there are four microseconds of sync at zero volts six microseconds of back porch at 0.3 volts 52 microseconds of actual data sending 0.3 volts for black and 1.0 volts per wide and finally 2 microseconds of front porch at 0.3 volts to finish the scan line and how do we keep track of these counters well each one of these circuits here is a comparator it just takes in the counter value and compares it against some constant number to determine when we need to go to the next state of each counter and how do we track the states from these comparators through these circuits called sr latches each one has a set signal which sets the value of the latch to 1 and a reset signal which resets the value of the latch to zero if we hook these up in succession to our comparators with the right numbers we know exactly where we are in the period of each counter only one sr latch is triggered at a time for each of the two counters and after that the circuit is kind of simple basically just a bunch of combinatorial logic to figure out exactly when 0 volts 0.3 volts and 1 volt should be emitted oh and to get this thing to display a real image super easy for that we just hook up some memory in our case a read-only memory chip and then we just use the hsc counter and the top five bits of the tkc counter to figure out what byte to look at in the memory then we use the bottom three bits the tkc counter to figure out which bit to show on the screen either a zero or one which of course correspond to black or white this does lead to kind of a video memory layout where the image isn't actually contiguous in memory and each line of video data has five bytes of nothing before it and one bite of nothing after it but it's really convenient to implement on the circuit and that's the whole thing hope things aren't too complicated and that this is easy to build it would be a shame if all this ended up becoming some giant mess of wires across seven breadboards it's wildly unstable if you even try and touch it but we'll figure that out when we start to build it but first after this fancy circuit diagram was done i had to convert it into something that could actually be built with those integrated circuits lotterson wasn't exactly equipped with all of the ics that i needed to get this diagram working so i had to break out the java programming skills first to add in some extra circuits to the simulator and once those were in i got to the circuit design initially i was going to have each wire drawn visually like you can see here but well also as you can see here that started getting really messy really really fast so i changed two tunnels for everything which has the added benefit of giving nice labels for all of the wires and yeah i know this isn't exactly what lagerson was really intended for but i mean who cares once the cereal was cooked up it was finally time to build this for real so after a few orders from some electronics companies a couple trips down to the local store i had everything i needed to build the circuit and so i got started on a live stream actually it got off to a fun start being my first stream and all what's good can you guys hear me all right you guys see me there there are way more of you in here than i thought they would be are you all just like unemployed or something anyway this is what we're this is what we're making today okay i think tc has the ripple count output on this can anyone confirm or deny that does anyone else is anyone like if you're following along at home with your data sheets um then tell me if tc is the right output let's see is it electronics half reading the chip stocks and the half failing and wiring um mostly failing and wiring it through me i'm not seeing any yeses or dab emojis in the chat so that's what i'm gonna do uh let's see if when i turn this thing on uh like my power goes out that could be fun that will make her an interesting stream at least hmm you know pray pray to whatever god you worship check it out that's super cool that's the first time i've ever done anything with like integrated circuits dab emojis if you're okay with me moving the camera not that this is a democracy and you guys have any say [Music] all right eventually i got everything figured out and everyone had their chance to yell at me and chat for not knowing a single thing about electrical engineering they are 5 volt leds i don't need 5 these are 5 volt leds i do not need a resistor for these no please stop spamming resistors these are 5 volt leds and by the end of the stream i had 8 bits of the 10 bit counter wired and running okay so that's bit this is gonna count eight bits by the way you know if assuming everything is correct uh let's get up to 16 okay and then ripple carry oh no that totally didn't work okay we did something wrong thanks to everyone who showed up there will definitely be more streams in the future after the stream though it was back to regularly recording things and assembling the circuit and this ended up taking a long while please ignore the massive skips in the middle this really did take a long time and it included some fun bugs such as non-functional integrated circuits voltages that hung out in between 0 and 5 volts which cause floating values and unpredictable logic well the whole deal really anything that people warn you about when you're building a circuit that can happen kind of did happen it's not like it wasn't my fault either to be honest i am to put it very lightly terribly unqualified to be building something like this in spite of that fact though i did eventually get the circuit to throw up an image onto the screen well not a real image but just using one of the bits of the tick counter to toggle between 0 and 1 on each scan line the final bit of the circuit build was the part that handled the memory for this i had to build my own arduino based eeprom programmer to make something for the images to be read off of god bless you benita for your video on this topic of course when this is hooked up to the final machine it will be using real video ram instead of a read-only memory chip anyway once the eeprom was properly programmed and hooked up the first tests of this were well okay but there were still a few issues to iron out and then more issues later and well things things went okay and finally now we're kind of caught up to real time see i really want to use the graphics card to display an image for the thumbnail for the video but you can see all these errors in it so i kind of need to debug those there's this clipping on the edges that can be avoided these gray lines and some more data errors but i'm sure this will be easy to fix one hour later okay about an hour later we have a white screen which is good this is what i'd expect none of the garbage we had earlier at least three hours later okay a few more hours and well no progress i'll check back in a bit one eternity later it's midnight i finally realized that the problem isn't me it is the eprom it's too slow i'm going to sleep so after countless hours of working on this i finally realized something when coming through the docks for the thousandth time this ebrom chip isn't fast enough to drive the screen that's why we have these great lines that's why the data is messed up at a load speed of 150 nanoseconds there's just no way that it can keep up with the clock speed of 250 nanoseconds when the delays of all the other logic are taken into account this is my best working theory at least so until further notice this is the best we've got and to be honest i'd say it's pretty damn good for a homebrew graphics card with that though thank you very much for watching be sure to come back for my next video where i'll be building the rest of the components for this computer and i'll see you then [Music] you
Info
Channel: jdh
Views: 281,113
Rating: 4.9682636 out of 5
Keywords: graphics, gpu, programming, electronics, ben eater, 3d, 2d, custom, homebrew
Id: OW1EmG7b4DU
Channel Id: undefined
Length: 15min 34sec (934 seconds)
Published: Sun Aug 29 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.