Podcast Lookup

FPGAs

Programming Throwdown

  • November 20, 2013
  • 1 h 21 min
  • Episode 30
Episode page
About this episodeThis show covers Field Programmable Gate Array (FPGA) programming. Tools of the show: Jason: Kaggle http://www.kaggle.com/ Patrick: KiCad…

This show covers Field Programmable Gate Array (FPGA) programming. Tools of the show: Jason: Kaggle http://www.kaggle.com/ Patrick: KiCad http://www.kicad-pcb.org/ . Books of the show: Jason: Mahout in Action http://amzn.to/1eizgRS Patrick: Bebop to the Boolean Boogie http://amzn.to/1cGRdaD

★ Support this podcast on Patreon ★

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

FPGAs

00:00—
  1. A

    Hosting provided by HostTornado. They offer website hosting packages, dedicated servers, and VPS solutions. HostT.net.

  2. B

    Programming Throwdown, Episode 30: FPGAs. Take it away, Jason.

  3. A

    Hey, so, you know, I'm a big fan of board games, as is Patrick. And, been playing a lot of board games lately on the phone. So

  4. B

    You mean, like, Monopoly?

  5. A

    Actually, do they have Monopoly? Oh, no, you know what? I looked into Monopoly on the phone, but it got terrible reviews. Like, a bunch of people were like, the app crashes. There's, like, microtransactions in Monopoly, which that blows my mind. That sounds horrible.

  6. B

    Yeah. No, I was joking.

  7. A

    I was joking.

  8. B

    Most people think board games, Monopoly, not good. I don't like board games.

  9. A

    Yeah, that's right. That is sort of the flow. It's like, let me think. Board games equals Monopoly equals me sitting around for three hours while the two people left, you know, finish the game equals not fun. But, yeah, so I've been playing Ticket to Ride. It's been pretty awesome. Patrick's been playing Carcassonne, or Carcassonne, depending on... I

  10. B

    Won't try to pronounce it. Yeah, I play several board games on my phone. I like this card game, Dominion.

  11. A

    Oh, yeah, Dominion's great. I didn't know they had that on the phone. They can play it

  12. B

    Really fast. I don't know. I have an iPhone, so I can play it on my iPhone.

  13. A

    Oh, I see. Is Dominion, is it free?

  14. B

    Yeah. Well, I have a version I downloaded a long time ago that was free. Supposedly, the guy was going to stop doing it when they actually released a real Dominion. But I don't know if that's ever happened.

  15. A

    That they've recently released a free one, or that he...

  16. B

    So they were going to make an official, the people who would officially license Dominion.

  17. A

    Oh, I see. But they haven't done that.

  18. B

    Yet. Yeah, I don't know if they did. Gotcha, gotcha.

  19. A

    Yeah, they are really fun. I mean, it's the bad thing about Ticket to Ride is that you can either do pass and play, which I've been doing with my wife, where like, you know, you use a tablet and, you know, I put some trains down and I pass it over to her, right? The online play, it forces you to play with strangers, which I think is a terrible design decision. I mean, I think the problem is, you know, you think about it, right? Who makes a board game? Somebody who is like pretty into like math, techie, like, like, like Game Theory kind of stuff, whatever. Those people, you know, would never want to play with friends. They'd always want to play, like, ranked. Like, that's what they have is like this ranked game system where I'm being matched up with somebody from a pool of three people probably who want to play Ticket to Ride. I'm being matched up with.

  20. B

    You should mention, this is only on the Android. On iOS, you can actually play with your friends. Really? Yes.

  21. A

    Oh, man. Yeah, so the, so specifically the Android is literally a copy of the web version. So, yeah, they're using like, you know how Adobe has this thing? I think it's called Flex. I think it's called Flex or Air or something like that. Air, yeah. Air, yeah, where you write code and it works on the web and on the phone. So, these guys are using that, I believe. And yeah, so on the web as well, you can't pick people to play against.

  22. B

    So, for all the people who are extremely confused about Jason talking about putting trains down on a board because

  23. A

    you don't know what this Ticket to Ride game is.

  24. B

    It's a board game that they made an iPhone or now an Android version of and they also have an iPhone, iPad version, iOS version and a web version apparently, which has been out for a while. So, how do you like playing? So, do you have the board game, the actual board game?

  25. A

    No. So I used to play board games with a group of guys back when I lived on the East Coast. And we all kind of split the cost by buying different board games each. And so I did not have the Ticket to Ride game and I still have it. Oh, okay. Okay.

  26. B

    But you have played the physical version.

  27. A

    Oh yeah. A bunch of times. Have you do you have that Ticket to Ride? I do.

  28. B

    I do. I have the Ticket to Ride.

  29. A

    I was amazed how mainstream Ticket to Ride is. Like it's in Walmart. Yeah, they sell it in Target now.

  30. B

    Yeah, that's right. That's right. So how do you feel like the differences between playing it on a tablet phone versus actually moving the pieces and sitting around a table?

  31. A

    Yeah, so for all of these board games, it is way better on the phone on electronic version. I'm just so much, I mean, it's almost to the point where you know if they made tablets just a little bit bigger, I would just play it on the tablet, like even with a group of four people rather than. Yeah. So I find it

  32. B

    depends on the game. Yeah. So like, but like Ticket to Ride isn't that much upkeep and like rules and math that you have to get right. So I actually prefer playing it in person, I think, and people have more fun and conversations when you play on your phone, even if with people in the same room, like everybody's really focused and like, you know, trying to do their thing. And so it gets kind of quiet. People don't tend to converse as much, but then other games that I've played that require like Dominion, I was saying there's like a lot of shuffling you have to do and stuff. So it's actually really nice on the phone because they just do all that for you. So you can just play very quickly. So you can get a game in against the computer or a random person or a friend, you know, in like five minutes versus 20 minutes or 30 minutes.

  33. A

    Yeah, definitely. I mean, of course, you know, the elephant in the room here is being able to create the desktop experience using these devices, right? Like if each person at the table has a phone, a smartphone and there's a tablet or maybe even two tablets in the center of the table, there's no reason why you couldn't recreate the same exact experience just electronically. Like in the sense that like the phones would just have the cards that you'd be. But that's

  34. B

    like the world's most expensive board game.

  35. A

    Oh yeah. Yeah. You have to assume that people already have all of this stuff. Otherwise you have breaks down. But the thing is, your point is valid that like the it's true. When we do the pass and play, we're not talking quite as much as when we're playing the board game. But I think that's more just a fact of you just have to kind of keep passing it back and forth. It's not like really like a board game where, you know, it's just kind of always there. And it's like, it always feels like one person has to be paying attention versus a board game. Everyone can step away. Right. Oh yeah.

  36. B

    I don't know. But they have pros and cons. I don't think they replace each other, but I like to have them both.

  37. A

    Yeah. It makes sense. I mean, for more complex games, like a Grickola, you know, with all those pieces and putting the fences and the pigs and dealing with all that. It's like, that would be so much easier. And then computing the score at the end always took like 20 minutes, you know.

  38. B

    That's true. So what you need is an app where you just take a picture of the configuration of the board at the end and then it scores it for you.

  39. A

    Yeah. Yeah, definitely. Or like, if

  40. B

    you're really bad at chess, you have a chess app that you take a picture of the chessboard and it recommends the next move for you. That'd be awesome. So when you're playing, you know, sneezes, you just whip it out real quick, take a picture. Have you seen

  41. A

    this? Have you seen this where anyone can beat a Grandmaster in chess just by having like two Grandmasters in a room and the person playing the opposite Grandmasters move? Anyways. You know what I mean? Like, you have two Grandmasters. You're playing both of them. The first, the one on the right makes a move and you make the same move to the one on the left. Like eventually you'll win one of those

  42. B

    games. Oh, so you will win one of the two games against a Grandmaster.

  43. A

    Yeah, exactly. Yeah.

  44. B

    Okay. Yes. So,

  45. A

    Yeah. Okay. A pretty cool thing is, just, and we'll get off the subject is Vassal. It's kind of clunky. I wouldn't recommend it unless you got a little bit of techie skills. Um,

  46. B

    Wait, they're listening to our podcast.

  47. A

    Yeah. Well, I guess what I'm saying is don't recommend this to your friends who don't know anything about programming or anything like that. You know, because most people would want to play this with other people. And so if you want to play this with other people, you'll probably have to go to their house and set this up, which is kind of unfortunate, but it's pretty cool. It lets you play over the internet. And basically what they've done is they have a bunch of board games, like probably a hundred something board games. And they literally have just taken pictures of all the cards and the board and all the pieces. And they don't have any of the game logic in Vassal, but they just have the resources. So in other words, if you're playing Monopoly, like on Vassal, you can just put a house anywhere on the board. It's as if you're really playing a board. I mean, there's nothing stopping you from physically putting a house somewhere, even if it doesn't make any sense. Right? So it's very open-ended and supports many different games and you have to kind of enforce the rules yourself. But it does let you play a ton of board games online, which is, I think it's pretty nice. Nice. I'm gonna have to check that out. I haven't tried that before. Yeah, totally.

  48. B

    All right. So onto the news. Our first news topic seems to have been very controversial online. And that is this new product called Coin, which is at only coin.com. Where Coin is a revolutionary new credit card device—or just card device, I guess. And the idea is that it is a small electronic thing that is the same exact size as a normal credit card, rewards card, driver's license, this kind of thing. And on your phone, you take a picture of the front and back of the card, and then you run it through a little card reader that they send to you. Similar if you've ever seen like the Square device is what I imagine it being. Cause it's not out yet. You swipe it, then it kind of knows what's on the magnetic stripe and it has pictures of the front and back. Then you can sync from your phone via Bluetooth to this device and have up to, I think it says eight cards where at the push of a button on the front, there's a little screen embedded. And when you push button, you can cycle through your cards. And then if you want to use your debit card, you select a debit card and swipe. If you want to use your credit card, you punch this button again and you know, it's your credit card and you can swipe. So

  49. A

    How does this—what's the connection between this and the phone?

  50. B

    So the idea is that the phone is needed because if somebody wants to see that you actually own the card, I guess, and also that like, you know, prove you have the card, then you want to have that on the phone. Also the phone is what's used to transmit the details of what the card, like how to be that card.

  51. A

    Oh, oh, right, right, right. I see what you're saying.

  52. B

    So like, on the mag, I don't know that much about it, but like the magnetic swipe of these cards, like the strip on the back that the dark color typically has magnetic particles that are, I don't think they're encoded or encrypted very well. I mean, encoded somehow, but they're not encrypted very strongly. And basically when you swipe it, some pattern comes off that is like the card number, what the card is and your name and your billing address or something like just

  53. A

    A few items or something as well. Right. The what? The CVV, those three numbers. Oh yeah. Yeah.

  54. B

    Or maybe in like the expiration date, but like just a string. And so if you have a mag reader, like Square or something else, you can basically just get clear text. Basically what's on the front of the card by just swiping. Right. So this device presumably will reprogram the magnetic stripe to whatever you've selected when you push the button. And then when you swipe it through the reader, we'll just think that card was swiped through. That's awesome. So, does

  55. A

    There's anything about how much it'll cost or anything?

  56. B

    So I, Oh, I forgot now.

  57. A

    Oh, actually I'm on the website. Now you can pre-order. If you pre-order it's $55. If, you know, once it is launched that it's $105.

  58. B

    Oh, okay. Yeah. So there's, it seems really interesting, but people have a lot of concerns, I guess legitimate or not, but that has like, it seems pretty legitimate. Like it doesn't seem like an obvious scam. It's backed by some pretty big companies and VC firms. And the weird thing is though, is that they require you to prepay your pre-order. So this is slightly similar to Kickstarter, but if Kickstarter doesn't succeed, you don't pay. But if it does, then you pay and eventually get your item. But normally when you pre-order something, you pay when it ships, but here they're collecting it upfront. So you pay now so they

  59. A

    can do all their

  60. B

    manufacturing. And it doesn't, as far as I can tell, like, I mean, they have prototypes, but it doesn't exist yet. Right.

  61. A

    Right. So as,

  62. B

    as with anything, there's a risk. And there's also a risk that, you know, like if you go to a restaurant and the person takes your card, they could in theory switch to a different card on purpose or by accident. Yeah, but that

  63. A

    doesn't help them any year. Does it?

  64. B

    I mean, no, but like, people have these also like accepting it. Right. Like, I don't know what this is. This isn't Visa or Mastercard.

  65. A

    Like, Oh, that's

  66. B

    where do I? So there's just like, it'll be at least initially, there'll be a lot of uncertainty from people, but it would be nice to get rid of all the extra cards, right? Like, and just carry one. Yeah.

  67. A

    Actually, you know, you're absolutely right. Like, think about this, you know, your debit card ever, as everyone knows is much, much more, much less secure than a credit card. It's actually very hard to reverse a transaction on your debit card, whereas it's almost trivial on a credit card. So somebody could say at a restaurant, you know, artificially add to your bill, like somehow scam you that way and then switch it to your debit card. And, you know what I mean? Like, and then it would be harder to get your money back.

  68. B

    Yeah. So, I mean, that's one concern. They have some nifty safety features. Like if the card gets too far away from your phone, it could auto disable or send an alert to your phone so that you knew like, okay, like that's a cool feature.

  69. A

    I guess that's true. If they have the phone, the phone can always like, there could always have a button that says, you know, lock my card. So yeah, that's

  70. B

    what I was thinking. Like a valet mode or whatever. Like, yeah. So like they

  71. A

    Could disable it from changing, or yeah, you disable it completely, or just disable. Yeah. There's like you said, disable it from change.

  72. B

    But like, one of the things—so there's been other startups that are attempting to do similar style things. And some of them it's by essentially you swipe one card and then they hold some pool of money, and then you can select on kind of like the backend what card you want it to go to, which is a very different thing and has other problems. But one of the nice things about that is that that website can then track all of your purchases across all of your cards versus

  73. A

    like this.

  74. B

    Coin thing. You can't track your purchases because it knows it got swiped, but it doesn't, for instance, know how much money was charged because they're not a part of the actual transaction.

  75. A

    Yeah. That makes sense.

  76. B

    So we'll see. It's definitely interesting. I like to see people innovating in this area because the current credit card stuff isn't that great. So,

  77. A

    Yeah, right. Definitely. Yeah. I mean, you think about it, if they get this right, you almost don't need a wallet anymore. I mean, if you get it down to only needing two cards, maybe there's like a better, you know, carrying, you know, utensil for that. Right? I mean, the wallet in general, but where am I going

  78. B

    to put the pictures of my kids on your phone? Okay.

  79. A

    Yeah. Okay. That works. The next news article Dart turns 1.0. So we talked about Dart. I believe we did a whole show on Dart, pretty sure. Yes. Yeah. And you know, we're both big fans. I'm a very big fan. I think Dart is amazing. I have had to write a lot of JavaScript, and I found recently there's some good tools that make JavaScript a little easier. In terms of, you know, there's a tool called TypeCast, which is pretty nice. I think we might've talked about it, but you know, Dart kind of gives you a lot of these things, and it gives you a really nice set of batteries. As we always say, there's plenty of batteries included in Dart, such as, you know, HashMaps and Lists and all these great things. Even like, you know, TreeSet, OrderedMaps, et cetera. So it turns 1.0, which is pretty awesome. This article that we've linked to talks a lot about the different features of Dart. You know, the common criticism of Dart is that it just doesn't have that widespread adoption. I mean, it has that, it has this critical mass problem, right? Where you have just so much infrastructure built in JavaScript. And even though Dart 1.0 makes it much easier to access JavaScript code from Dart, you still—it's incredible. There's an incredible amount of inertia to move people off of JavaScript. I mean, it doesn't matter what the alternative would be. I mean, if you look at popular alternatives to JavaScript, they are almost always just small enhancements to JavaScript, like TypeScript, which compiles to JavaScript, CoffeeScript, which compiles to JavaScript, so on and so forth. So this is pretty difficult, but I believe strongly this is a really great language, and we'll hopefully see it continue to get adoption.

  80. B

    Are there any other browsers besides Chrome that can run Dart natively yet?

  81. A

    I don't think so. And in fact, you can't run Dart natively in Chrome either. So, yeah, there's a special version of Chrome that you can download, which does let you run Dart natively. But for one reason or another, it's still not part of the regular Chrome. Okay. Yeah. So there's actually no browser which lets you do that. But looking right now to see if I don't think that Firefox or any of the

  82. B

    So it says that, yeah. So currently when you part of the Dart Software Development Kit is a version of Chrome, Chromium.

  83. A

    Dartium. Yeah.

  84. B

    Oh. A version of Chromium. I see.

  85. A

    Oh, yeah. Right. I misread. Right. No worries. But but yeah, the you know, I don't really know why. I mean, I could only guess that maybe like they're having trouble with mobile or something. I have no idea. But but so to finish that thought, you can convert your Dart code to JavaScript using this thing called dart-to-JS, and then it will run in any modern browser. So. Nice. Yeah. Very cool.

  86. B

    So the next article we have is a successful ability of a qubit to last for 39 minutes.

  87. A

    So is that the guy who jumps from block to block, changing the colors and swears when he gets hit?

  88. B

    Wait, that's Q-Bert, isn't it? Oh,

  89. A

    You're absolutely right.

  90. B

    Yeah. Close, but not quite. Right. So a qubit is the name for a quantum bit, and I'm probably going to butcher this because I've always wanted to learn more about quantum computing and computers and have never successfully managed to make heads or tails of it. But so if you have a normal bit, it can be zero or one, but in quantum physics, and in quantum events, you can have things that are not just unknown. Like you don't know if there's zero and one, but actually exist in both zero and one with some probability. Right. And so if you have that, it's called a superposition. So it's unknown. And it's really easy for something to interact with this particle or this qubit that is in this superposition to interact with it. And once something interacts with it, essentially you've made a measurement of what the state actually is and the superposition collapses and now you have an actual either zero or one. Yeah.

  91. A

    So let me maybe are you going to do better? Here we go. No, no, I'll just come up with it. So a lot of people don't understand quantum mechanics and someone explained it to me in a way that's kind of morbid, but actually made a lot of sense to me is, like, let's say you completely cut off ties to say your grandmother, for example, right? So assuming your grandmother is alive, then as soon as you do that, your grandmother is like 99.99% alive, but like some small, like epsilon, you know, like 0.001% dead. Like she's in the superposition state where she's part dead because you don't know if she's alive or dead. Now, if you never speak to your grandmother for, let's say 80 years, and let's say, assume you're young enough where you can live 80 years and still be around, then your grandmother, you don't know that she's dead, but she's in a new superposition state where she's, you know, 99.999% dead and, you know, some small percent alive, right? Because most people don't live to whatever she would be, let's say 180, right? So extremely rare. So once you go and visit her or her grave or what have you, then you know immediately. And then as Patrick said, the superposition state collapses and now it's, it's either zero or one. And so, but the important thing here is that there's sort of like this gradient, right? So it's like, it went from 99%, you know, false 0% true. And then over time it like slowly shifted to, to the opposite. And so this is what sort of quantum programming is all about. It's sort of taking advantage of the stochastic nature of various problems to create these superposition states. And then hopefully the end goal is to sort of observe these superposition states, you know, multiple times and then aggregate those results into an answer. So there's a lot of connections between ideas of like, you know, confidence and probabilities and these kinds of things and the quantum world.

  92. B

    So there's this idea of like a actual quantum computer, which is like a current computer we have now, but does all the operations possible in parallel or something like this. Right. And you can do things really, really fast and that's kind of like a general purpose computer, but they have now things that are claiming to do quantum computing, which is more like along what Jason's saying, which is like, if you take the traveling salesman problem and you represent the initial, you know, state of the world, then you perform in a quantum fashion, the some set of operations, and then you get to end and you have a whole bunch of possible outcomes, but some of them will be optimal. And you want to observe which ones those were by having tried a whole bunch in parallel. And that relies on needing this probability distribution at the end. But if things lost their superposition along the way, like something bad happened in the device and an accidental measurement was taken by another particle colliding with the qubit, then the operations at the end don't work out right. Exactly. And so you can know that something happened wrong and you won't, but you don't know what the right answer would be. You just know that something bad happened. Yeah.

  93. A

    Exactly.

  94. B

    And so the important thing about having a qubit which lasted 39 minutes is that like at room temperature is the other thing, because typically you keep it really, really cold because things move slower. And so then I'm probably butchering this, but like,

  95. A

    No, no, the way I understand.

  96. B

    It is like at really cold things move slower, right? So it's easier to keep things from colliding with the particle, but at room temperature, you know, things are zipping around. Right. And so it's much more likely that a particle will collide with the qubit or something will happen that will cause the position to collapse.

  97. A

    Right. Exactly. I mean, so just to complete the thought, if something collides with a qubit, that means you know where that qubit is. That means it's not in a superposition state.

  98. B

    So yeah, you've taken some measurement of it, right? Whether you meant to or not.

  99. A

    Exactly.

  100. B

    Because you could then observe that particle. And yeah.

  101. A

    It's sort of like, if you ever watch the World Series of Poker, any of these poker shows on television and you see sort of the person's chance of winning, right? And then as soon as they draw a card, all of a sudden, it's like it goes from, you know, 30 to 70%, like 99 to zero or something, right? So it's that kind of thing where if, you know, as soon as you see that card, all of the dynamics change. And so if you have a card on table and don't, and you don't flip it over, now you're exposed to a wide variety of outcomes.

  102. B

    These things are all really fascinating and really interesting to me. I wish I had more time to understand it better and explain it better. But yeah, if you're interested, you should go read more about it.

  103. A

    Yeah, definitely. Yeah, maybe we should look into this, and next book of the show should be quantum. We should put onus on ourselves to find some. Or

  104. B

    You should go watch every YouTube video about this, and then we can have an actual show, and you can just tell us about it.

  105. A

    Yeah, yeah, exactly. Okay. Okay. So my, so last story of the show, hacking Candy Crush. I thought this was totally awesome. Actually, the title is technically 'Winning at Candy Crush,' but it's pretty great. Basically, this guy. So what is Candy Crush? Oh yeah, so Candy Crush is an online game that is built in Flash, but it uses JSON, you know, XML, HTTP requests to send data to a server. So for example, you play this game in Flash, you beat a level, and then it actually packages some information on how that level had progressed and terminated, sends that as a JSON string to the server. The server then sort of decides whether to give you a new level or to have you repeat the current level, et cetera. And it sends that back to you, and then et cetera. And more things happen. So, you know, the server actually will send you the content of the levels one at a time. So, you don't actually have the complete game. But yet this person was able to pretend like he beat a level by sending the right JSON to the server, getting the new level content and then repeating. And it's pretty awesome. Actually, the person's profile picture is just him like with his goofy grin. And he just seems like the perfect person to do something like this. And even if you read further down, the content is great. And the comments, he replies to almost all the comments, and it is pretty hilarious. Actually, the whole thread I thought was really amusing. So, if you want to see how to hack online games, this is pretty epic.

  106. B

    Or how not to design your online game.

  107. A

    Oh yeah, that's true. Yeah. There's this cool thing called encryption. I mean, but yeah,

  108. B

    not trusting clients.

  109. A

    Yeah, yeah, exactly. Because somebody

  110. B

    could write a malicious client.

  111. A

    That's actually an extremely good point. I mean, for people who are designing, you know, any kind of server-side apps, you know, you have to expect your client to do, you know, one thing is, if you encrypt the string, then usually the decryption algorithm will just bomb out, right? But if you're not doing anything like that, yeah, you at least want to make sure that the person is doing something sane. There was actually a fascinating article. I'll see if I can find it, you know, for another episode where all about sort of the arms race between Chinese hackers who were hacking World of Warcraft so that they could get loot and sell it for real money, and the World of Warcraft security team. And really interesting. Basically, you know, they had a bunch of rule, they had a rule-based system where if any of the rules fired, they had a human evaluate the activity and then ban the account. Then one of the rules, for example, was if you moved more than say, you know, a thousand strides in less than a second or something like that, right? Then they fired some rule saying this person's doing something which isn't physically possible in the game, right? And these guys got around the rule by they started reverse engineering the rules after getting so many accounts banned. They'd moved 999 units and then wait a second. And they wrote had scripts which did that. So I know the whole thing was really interesting. I'll see if I can pull it up.

  112. B

    So, this is actually really common. This is a whole thing. I was reading something similar about when you can like take your, you know, Xbox 360 controller and modify the electrical contacts where the button presses happen to have rapid fire, right? So, everybody's probably seen these like on old consoles, you could buy rapid-fire game pads. Yeah, right. And instead of when you push the button, it's just making one electrical connection. It would sit there and make it, break it, make it, break it, make it, break it, and give you rapid fire. But that, you could use that to cheat in some games. And so, they actually like tried to detect on the server side for online play. For local play, they don't really care. But for like online play and people gaming the system to get better rankings, they tried to do things like detect the distance between key presses, the time between key presses. There we go. And so, if you're pressing too regularly and fast, then they know you must be cheating, right? Right. And so, then they can ban you. So, then the people who did these illegal mods to the controllers had to embed little microcontrollers which would vary the timing so that it looked human enough and be just fast enough that it was helpful, but not too fast that you would get caught.

  113. A

    Gotcha. So, yeah. It had some Gaussian noise or something to the clicks so that they weren't all. But it's crazy that

  114. B

    people would spend time doing this, right? Like making microcontrollers and then selling them. And I wonder if it's profitable. I have no idea.

  115. A

    Yeah. Who knows? I mean, I remember at one point I had a mouse where you could hit the button. There was a button you could hit on the mouse that would make the scroll wheel have no friction. And you could just spin indefinitely and it would just keep spinning. So, I used this button and then I bound the mouse wheel to like firing a pistol in Counter-Strike. And that was pretty fun. But I mean, that was a long time ago. I bet you get banned for that now. All right. So, enough about hacking video games. So, now we're doing the book of the show. My book of the show is Mahout in Action, which is, you know, there's many of these inaction series of books. Mahout, I believe we talked about it in the Machine Learning, one of the machine learning podcasts. But Mahout is a machine learning suite of algorithms. Some of them run on Hadoop, which is, as we talked about, like a MapReduce framework. Some of them actually just are meant to run on a single machine. So, if you just have, you know, a machine sitting around or, you know, you want to do some coding, you can actually use the algorithms in Mahout without having to set up, you know, a bunch of nodes, a bunch of clusters or anything kind of complicated. So, I've recently been using this a lot. It's pretty awesome. It has a bit of a learning curve, Mahout does, which is why this book is so great. It actually walks you through how to use many of the algorithms in Mahout. And I feel like it's a pretty good read. I'm not all the way through yet, but I'm pretty happy with what I've read so far. Wait, so you're recommending a book when you don't know the ending? Yeah. I have a feeling it ends with an appendix.

  116. B

    Oh, spoiler. But what if it's a cliffhanger?

  117. A

    Check out our book two. Actually, I found

  118. B

    out. Or what if there's a microtransaction at the end of the book? You can't read the last chapter until you pay $5 more.

  119. A

    You know, they actually have that. It's kind of sad. But my wife was reading a free book from the Play Store. And sure enough, a few chapters in, it was like, oh, why don't you do an in-app or in-book transaction to get the rest of the book? I was like, that sucks. Oh, that's pretty devastating. I mean, they should at least tell you. Maybe they did. Yeah, yeah.

  120. B

    If they're up front about it, it's like, oh, you know, this book isn't free, but we give you the first three chapters for free.

  121. A

    Yeah, they might have said that, but it's, you know, in that small text that nobody ever reads. Oh, okay. Or at

  122. B

    least your wife doesn't read.

  123. A

    Yeah, exactly. Yeah.

  124. B

    Oh. All right. So my book is Bebop to the Boolean Boogie. That sounds awesome. And if you could say that five times fast, I will give you a thumbs up. So this is in theme with our episode topic. And it was a book I read actually many years ago. I think I may have found it at the library. I'm not sure where I found it at. And it was when I, before I had taken up much programming. And it describes just like it's saying, well, it doesn't actually say, but Boolean Boogie. It's talking about a lot about Boolean logic and specifically about Boolean logic in reference to how it would be used in circuits. Oh, wait.

  125. A

    So this isn't like a fiction, like sci-fi book or something.

  126. B

    No.

  127. A

    Oh, okay. Sorry. I

  128. B

    have a legitimate, actual, useful book this time.

  129. A

    No, no. It's not a dig on you. I just, I saw the title and I just thought for sure this was a sci-fi book. So why?

  130. B

    It attracted to me when I guess I was in probably middle school or early high school was that—yeah, so it's a really fun approach. So similar to the recommendation of the design patterns book, Head First Design Patterns, it takes a, you know, somewhat lighthearted approach to design patterns, but it is a serious, you know, learning. It's just like you do learn the design patterns that they go over. This is very similar. It takes a lighthearted approach.

  131. A

    Yeah, it got some really good reviews on Amazon and a couple of their websites. So yeah, it looks pretty awesome. I'll definitely see it. It actually got a perfect five stars on Amazon.

  132. B

    Yeah, that's pretty awesome. So I haven't, I'm vaguely remembering it from a long time ago and there's, this cover isn't the cover that I remember seeing. So I'm sure there's a new edition now or something. But yeah, so it goes over like if you're new to programming, especially it could be helpful. Or if you're interested in—so a lot of people talk about like circuits and electronics and electrical engineering. And so there's analog stuff and digital stuff. And to do any, you know, digital stuff, you're going to get into kind of Boolean logic and learning about that kind of stuff. And this, we'll go over that. Like what is an AND gate and how does it function? What is an OR gate? How does it function? What about exclusive OR? How do you count in binary? How do you do binary math at like a gate level? How do you?

  133. A

    do like, how?

  134. B

    do you call them? Cardinal maps or whatever. Like optimizing if you—what's called a truth table. So like you have inputs that are either zero or one and you have many of them. And here's the output you want for each set of inputs. How would you devise a set of gates to do that? And so this will come into play. We'll talk about this maybe more in a little bit level and a little bit later and in the episode. But this book goes over that, and it does it in a lighthearted and fun way that I remember being fond of when I was younger. Not that you have to be young to read it. I'm sure it's equally fun now, and I should bring it back out and read it again. But that's my recommendation.

  135. A

    Cool. Cool. Yeah, it sounds awesome. I'll give it a go. All right. Tool of the show. Tool of the show. So my tool of the show is actually a website. It's Kaggle, K-A-G-G-L-E. And it's pretty amazing. So basically, so Kaggle is a data science competition website. And so, you know, it's funny. A lot of people don't really know what, you know, a data scientist is or what that even means. I mean, they think it's someone like a lab coat who like mixes data from one vial to another. And so this is pretty interesting. It's interesting. It—the site has a handful of competitions that are fake competitions meant to sort of teach you about data science, which I think is extremely extraordinary. Because it—it really sort of like helps you understand that it's not about, you know, programming in a certain language or something like that. It really sort of tells you sort of, it gives you a list of sort of data science problems and then walks you through several solutions, which is pretty great. Now they also have, you know, serious competitions with real rewards. And the way it works is they provide you with a data set. So there's a competition going on right now where they provide you with a bunch of data from Stack Exchange. So these are the—Stack Exchange is the sort of mothership for Stack Overflow, Math Exchange, and all these other websites where you can ask questions, right? So, people generally tag their questions. So, you know, you might ask a question like, oh, I keep getting this Java runtime exception. And then you tag the question Java so that, you know, people looking to answer questions will be able to do filtering, right? So, Kaggle has a competition where they give you a bunch of questions with the tags. And then they give you another set called the test set of questions, but you don't know what the tags are. So you are supposed to produce the tags for that test set and then send your predicted tags to them, to their server. And they will score them and give you a score back. And the goal is to get the highest score. So all of these have a deadline, each of these competitions. And the scores are pretty awesome. Like here's one flight. One thing too, about these competitions. I don't know for a fact, but I believe pretty strongly that the people that are posting these competitions have like a vested interest in the algorithms.

  136. B

    Well, considering the reward for this one is like, what does it say? $200,000. I'm pretty sure somebody has a vested interest in

  137. A

    It. Yeah. So, General Electric, I guess that's who this is, right? They are offering $220,000 for somebody who can solve this data set as completely as possible over the next 30 days. That's actually pretty extraordinary. Most of the rewards are pretty small. Actually, Facebook has a competition and the reward is allegedly a job at Facebook, which is I think pretty interesting, but you know, most of the time the rewards are $5,000 or something. The ones where the rewards are knowledge, that's sort of a special case. That means these are ones that are meant to teach you data science and how to be a data scientist. Nice. So is it the case that like this GE?

  138. B

    One or whatever. I didn't read it, but like, is it the case some of these require what was that? The Netflix Prize was a while back. Like they require a certain threshold of embeddement to be reached before they award a prize or somebody will get the prize at the end of this time period?

  139. A

    Yeah, that's a really good point. So, if you look at the leaderboard for any of these competitions, they actually have some special spots on the leaderboard, which denote sort of milestones. And they expect all of those milestones to be completed. Like for example, looking at the GE one, they had a sample submission benchmark. And I guess you have to do, if you don't do better than the benchmark, then they won't, you won't get an award. Like for example, Stack Exchange, their benchmark is they pick the four most popular tags and see if it's any one of those. And if you can't do better than that, then they, you know, if no one can do better than that, then no one gets a prize.

  140. B

    Okay.

  141. A

    But from the competitions that I've seen thus far, every one of the competitions has been won by somebody. Okay. So yeah, it's pretty interesting. I mean, I don't know sort of how competitive it is. Anytime you have something like this with the whole internet involved, you have to expect that you'll get the best and the brightest. And so, although they're offering this $220,000, I wouldn't go in there expecting to win it or wanting to win it. I'm sure there are whole armies of people working on this, but it's still phenomenally cool to work on this and on any of these and get some good results and test your, if nothing else, it's more data for you to test your system on.

  142. B

    Well, test your system on, learn these techniques. And like, I'm sure this kind of thing is just, even if people don't know what this site is, when you go for a job or to change jobs that, it'll let you talk about things very confidently. And you can point people to like, oh, here's stuff I did. Like I did these type of analyses.

  143. A

    Yeah, exactly. Exactly. There's also a forum for each of these competitions and you can post, you can answer questions, ask questions, et cetera, on the forum. And yeah, I think it's phenomenally interesting. I definitely recommend everyone check it out. That's awesome. Yeah. And there's 34 days to go on the Facebook recruiting competition. So by the

  144. B

    time you hear this, you're not going to have much left.

  145. A

    Yeah.

  146. B

    No, I'm just kidding.

  147. A

    Yeah. So these competitions are actually pretty interesting. Yandex, which I believe is the Russian search engine, is offering $9,000 to somehow do a better job ranking given the personal preferences of the users.

  148. B

    I don't know. I think this stuff is really interesting

  149. A

    And it's pretty cool that the data is right there for you to access. It's like usually you have to go scraping Wikipedia or doing something painful to get data. But here's just a bunch of really awesome data just waiting to be downloaded. So cool. Yeah, definitely. So now we're onto FPGAs.

  150. B

    Wait, we're skipping my tool of the week. Okay. Oh man. I'm so sorry. So my boat

  151. A

    started with K and I think I just, I don't know. My eyes just skipped it.

  152. B

    It's okay. So my tool of the week is KiCAD or KiCAD. I don't know how you pronounce it. K-I-C-A-D.

  153. A

    Okay.

  154. B

    And this is a tool again, in theme with the show, how apropos that rhymed, um, is a tool for designing electrical circuits and building PCBs, printed circuit boards. So if you're going to make your own circuit, which if you get involved in any kind of hardware microprocessor stuff, you'll eventually kind of want to do. This is an open source tool that's free, no limitations, and lets you kind of lay out. I want to have a resistor and I want to have this processor chip and I want to have these inputs and outputs and plop them down, arrange them, connect them up, and then build a board that would represent that schematic. And that's something that's normally done by very expensive software. So a lot of people use this tool called like Eagle or there's another one. I think it's called Altium. But these are like very expensive, like thousands of dollars, to have these boards and people use these to build like the motherboard in your computer. Right? So like, oh, I need slots for RAM and a slot for this processor. And you know, I need these ports over here and this Northbridge. And so like all those things get laid out and may have like, you know, four layers of different planes of circuit copper, in the single board that is your motherboard or six, or I don't even know how many are in a motherboard. But I don't want to learn any of that.

  155. A

    That sounds way

  156. B

    too complicated, but I have been doing some projects like with an Arduino. We've talked about Arduino before, a Raspberry Pi. And you want to like connect things together and you don't want to have to use little wires. You could use a tool like this and either make your own printed circuit board, which is something I actually want to try to do sometime or send it to a company. So I actually did this before I had an RGB LED that, so it's one LED device, but it has three LEDs embedded inside of it. One red, one green, one blue. So you can make it any color you want. And I print, I made a little circuit board. That's like an inch square or less, and connects pins. So you can plug it on a breadboard to the pins of the LED, which didn't fit on a breadboard. Well, and so I was able to design that in the tool and get it ship it off to a company. And then they sent it back to me, my little PCBs. And I got like three of them from this place. And

  157. A

    it only costs like $3. Wow. So you can basically, you can make, you can make like a single board computer that does something relatively simple for, you know, 20 bucks or something.

  158. B

    So it depends. Like it's based on the size of the board you need, how many layers you need. It gets complicated really fast, but if you don't know about this tool, it's cool. You should check it out. This one's open source. And so you don't run into limitation of size. So some of the other ones are limited, like you can't go bigger than three inches by two inches.

  159. A

    And if you do, then

  160. B

    like you'd have to pay. But if you're designing something simple and only having like one surface, you might want to make something actually pretty big that you could do yourself. And you couldn't choose that tool. So, when I've been teaching my stuff, myself, this stuff, I wanted to do it on something where I wouldn't ever have to worry about running into some limitation. And feeling bad because I'm not going to spend thousands of dollars to buy the tool.

  161. A

    Yeah, right. Definitely. This is super interesting. It's actually, I love these Olo stats. They're on many different open source sites, but it says that it's 585,000 lines of code in KiCad. So I don't know what that's doing, but is doing, there's a lot of effort there. So, so there's

  162. B

    a lot of things around like place automatically routing the little electrical paths and stuff like that. It's pretty cool. You should check it out. And actually, recently CERN got involved with the project, and they want to use it for doing a lot of their circuit designs. So they're starting to contribute to the project.

  163. A

    Oh, very, very cool. This is super interesting. Yeah. Check it out. Did you—how do you deal with like, so I noticed on the picture here, it has like a physical switch and a physical serial, like a serial, you know, serial out. How do you, I mean, the company that you send the schematic to, do they also do the switch part too? And

  164. B

    Everything. No. So typically you decide in advance, like I want a switch, and then there's like common switches or they may have it in a library, or you may specify it yourself based on the data sheet of the switch that you've picked out. And then when you get it back, there are companies which will populate the board for you, like go ahead and solder everything on. But that's typically much more expensive. I don't even—I've never even looked into that. But basically what I do is like, oh, I have these common parts already around, and I've made some example circuit, and I just want to put it on a board. And so you solder it on yourself. So, you know, in advance, like I have this switch, and you drop it on.

  165. A

    So you take a few of the parts from your nuclear submarine that you use to hunt for Superman's body and use that to build your next project. I'm going to say yes, but I don't know what you just said. But yeah, check it out.

  166. B

    If you're into hardware, it's pretty cool. You probably already know about it. And if you don't, and it strikes your interest or the things I said pique your interest, you should look into it.

  167. A

    One more thing on this, and then I'll let you off the hook, but where do you go to buy the things like switch it, like

  168. B

    very basic things like this. Like switches,

  169. A

    motors, how do you get any of that?

  170. B

    Yeah. So the internet, of course, that's one answer.

  171. A

    So most of the electronics. Yeah.

  172. B

    So it's actually kind of difficult. So there's a couple, like you'll learn about, like these places: DigiKey, Mouser, Element14. Like there's different places you'll learn about. And maybe we can talk more about this in another episode because it's actually really fascinating. I'm really into this presently. But yeah, so like there's websites like that, but they serve people who are literally doing this for a job, right? Like building motherboards or building the electronics that go into cars or just TVs, anything. Right? And so they're getting parts for them. And if you search for, like, a resistor, they'll have a million different kinds of resistors. Well, that's really overwhelming.

  173. A

    So then,

  174. B

    there are other places like SparkFun that are more hobbyist oriented where they have the most common ones. Like we know you'll probably want this. Like this is the most basic switch. If

  175. A

    you just need a switch,

  176. B

    just choose this switch.

  177. A

    So you could go to SparkFun, like find a few things and then go to DigiKey to complete the collection or something.

  178. B

    Yeah. Like if they didn't have something, you can also go—there are local electronic stores. So there's like a place here specifically that I've gone to in the Bay Area of California that has what they call surplus electronics. So companies go out of business or there's old equipment and they sell it to this place, and then they allow you to come in and you can buy stuff really cheap. And they just have like bins and bins of resistors and, you know, various capacitors. Yeah. It's actually awesome to go to. It's really

  179. A

    cool. Oh my gosh. We got to go. Okay. Are you—is it baby safe? Like if we were holding the baby, no, no, he would reach out and electrocute himself or something.

  180. B

    Well, not electrocute, but like swallow it. It's tons of tiny components, right?

  181. A

    Oh yeah. All right. We'll have to find some time to do this. This sounds pretty epic.

  182. B

    Okay. It is pretty cool. It's a lot of fun. So anyways, so on to FPGAs.

  183. A

    Yeah. FPGAs. So I actually, I think I know. So of course, you know, just some background. I did almost entirely theoretical computer science. And Patrick majored in computer engineering. As a result, I am a complete Luddite when it comes to any of this. But I know a few things and I will try my best to keep up. So FPGA is programmable Gatorade. What's the F? Oh yeah. Field-Programmable Gate Array. And I'll let you take it from there. Okay.

  184. B

    So this is going to be an interesting topic. We'll talk a little bit about programming because, um, programming FPGAs is kind of interesting and different, but also just about like how FPGAs may interact with processors. So if you're ever doing any what's called embedded systems programming, you often deal with FPGAs or can deal with FPGAs at a company. So they're very common in a lot of commercial applications or, just depending on what you're trying to do, you may come across it and it's good to know cause you'll see it out there and people talking about it if you're doing any non-theoretical or only high-level application programming. So, a little bit of history is that we talked a little bit, and when we were talking about the book of the show about Boolean logic and AND gates and OR gates. And these are the things which kind of represent when you have like a one and a zero and you want to say, if only if both of them are true, do I want the output to be true? And so you have that Boolean logic and you can use Boolean logic to describe, you know, ever-growing complicated components. So with just a few AND and OR gates, you can describe a thing called a multiplexer, and a multiplexer says like, I have five different input lines and I want to specify which of those five get put onto the output, or I have two numbers into what's called registers, little bits of memory, and I want to add them together. So you can specify that with just a handful of AND and OR gates. And once you have all of those components defined, you can add those components together and actually build CPUs. So that's how, you know, a processor gets built is from a collection of these digital gates. In fact, there are a couple gates that can be used to make all other gates. So with only a single type of gate, you could actually build an entire CPU. And if you ever take any classes of it or follow any tutorials about this, it is actually really rewarding. One of the things I did when I was in school is start from those AND and OR gates and actually build up to a whole, I think we made a four-bit.

  185. A

    processor and you actually had memory and

  186. B

    an instruction set and you had to learn like what assembly programming really is about. And a little switch that you were at the clock, like you would switch the switch up and down and actually clock the CPU. So it was like a one Hertz four-bit processor. And the final exam for the lab part of the class was actually the TA for the lab would bring in a piece of memory on a chip, plug it into your CPU that you had built and you would sit there and clock it and you would have LEDs that represented the output. And he would write down after 10 clicks of the clock, like what the LEDs were after 20, after 30. And then they had to be right in order for you to pass. And it represented the instructions actually being executed and the results being displayed. And you had no idea what was in his instruction set that was on his, you knew what the instruction set was cause they gave it to you, but you didn't know what specific program he had just run on your processor.

  187. A

    Oh, I see. So, from and correct me if I'm wrong, I think the reason why one would want to program their own FPGA is because when you work with just a regular processor, you're doing things in serial and the processor can do anything, you know, you want, it can do, you know, multiplication, add division, you know, many other operations, but, but it's designed to do like to do any of those. And it's not really balanced one way or the other, or I guess it is balanced. It's not biased one way or the other. And so if you need to do, you know, 40 add operations, they're just all going to queue up one after another. Now the processor will try to do like out-of-order execution and, you know, processors have gotten very complex, but the reality is, you need to add an entire array of numbers at once. That's the way, that's the way your program is designed or your algorithm you want to create is design. Then with an FPGA, you can literally have eight copies of the add mechanic all running at the same time.

  188. B

    Yeah. So that's like a really good idea. So like, if you have like a 32-bit processor and you want to add two 64-bit numbers, right? So the 32-bit processor there means like the width of the data coming through is, this is a lot of hand waving, but basically that you can have 32 bits per number and you can add two of those numbers together, but you have 64-bit numbers. Well, that means you have to do the adding twice, you know, once for each pairing. But like you said, you could in an FPGA have 256-bit adding. So add 256 bits twice at one time. And if you wanted to do custom things like, oh, I want to multiply this acute, you know, add it to the previous results and also do this other custom thing. That's only to me. A processor won't have that special logic. Processors sometimes do have specialized logic if it's not too specialized and they think it's useful to everyone. But an FPGA can have whatever logic you want. So it can do custom things that are crazy and don't make sense and do them all in parallel all at once because there isn't, the way the clocking works, it isn't like this thing feeds to that thing, feeds to that thing, feeds to that thing by necessity. It can just be like, I want to do all this stuff at once all at the same time.

  189. A

    Yeah, exactly.

  190. B

    And so that is a reason why you would have an FPGA and it's going to get a little that we could go into like a lot of the history and stuff and ways of representing it. But I think I'm actually going to skip over it because I think it'll end up being kind of boring.

  191. A

    One other thing I'll mention about the FPGA is that it saves a lot of power, right? I mean, as we talked about the processor is a general-purpose machine that has many, many different instructions and it's actually extremely complex and does a has what's called a pipeline where it can be working on several instructions at the same time. But if you're working on, you know, building a phone or a small device that, you want to put in your car or something like that, then power becomes an issue. And so, you know, writing your stuff in FPGA might make the difference between something running for an hour on battery or four hours or longer, right?

  192. B

    Yeah. And there's other things that, you know, processors just don't do good at because the idea with a processor is it's like set, like whatever gates they put into a processor, cause processors and FPGAs are both kind of gates fundamentally. Whatever they put into a processor, they select one set of gates and that's all you get. And so they have to optimize for a lot of cases so they can sell it to a lot of people and they don't know what you're going to do. But the FPGA is just the raw collection of gates. So you could take that collection of gates and build the same processor in it. And they actually do. That's called like a soft core. So you can take an ARM processor like is in your cell phone and manifest it in an FPGA. Okay. So arrange the collection of gates and FPGA to be an ARM processor. And if you want like extra floating-point ability, you could add it in. If you wanted extra, like, you know, like an extra wide pipeline, you could add that part in or take parts out and you can interesting. That's what's, that's what the field programmable part is about is like in the field, not in the factory. Like you can change the combination of gates so you can bring in and drop out your own processor or even things which we wouldn't normally do in a processor.

  193. A

    Oh, I always wondered where the field came from. And that makes sense. Like the field as opposed to the factory. I like that.

  194. B

    So we can get into, yeah, it's a long discussion talking about like the kind of actual like engineering things behind this and what happens. But you can define like an FPGA to do any kind of things you might want to do in a processor or things which you wouldn't want to do in a processor. And the ways that you kind of program them, like write the programs. One is, we were talking about like logic gates and logic gates have symbols. And you can kind of draw a circuit, a schematic that describes what you want the FPGA to do. So like I want it to look at switch number one and switch number two. So like switch being like, as an example, like a light switch. So I only want to turn on the lights in my living room if both light switch one is on and light switch two is on. So I have an AND gate that looks at light switch one and light switch two and them together. And the output goes to determine if the light is going to be on or off. And you could draw a little picture of that. And the FPGA would be able to replicate that logic. But as you get to bigger and bigger and bigger and bigger devices and more complex logic, those gates become like even worse than writing an assembly code, like even lower level. So then what you, what they have is some sort of what they call hardware definition language. So you'll hear VHDL or Verilog, and VHDL and Verilog are without getting into specifics on their ways of describing how the FPGA should function and how things should have, like you could use that. I want to add what's in place number one to place number two when the clock ticks. So every time the clock ticks, whatever's in location one and location two, add them together and put them in location three. Every time I get a clock tick.

  195. A

    Oh, I see. So it implements the ADD operation, I guess, for you.

  196. B

    Right. So it determines how to configure the technology inside the FPGA to basically do the ad operations every time you have a clock tick. So that's one of the things that's interesting about FPGAs versus processors is that an FPGA, like you have to talk about the clock. So in the processor, you talk about like, oh, my clock speed is 16 megahertz or one gigahertz. And that means that like some operation, an operation that completes in one cycle completes in one, one millionth of a second for a megahertz. And I can count how long a certain set of operations will take. So if you need to do something really fast, you need to know how long each instruction takes. With FPGA, it's even more prevalent that you have to think about clocks and how fast your clock is running and that each time the clock ticks, because you're kind of defining this pipeline, like a step A, I want to do this. Step B, I want to do this. Step C, I want to do this. So every time the clock ticks, things are moving down the pipeline, but the next set of things are coming in right behind them. And that's for what you call kind of like streaming operations. So FPGAs are used heavily in streaming operations. Like if you imagine a video camera has data coming in every time it takes a picture. So a video camera is just taking lots of pictures, one right after the other. And those pictures just keep coming in and coming in and coming in and coming in. And in a processor, if you spend slightly too long processing one of those frames, all of a sudden, all those other frames after you get pushed down the line and you end up with a problem. In an FPGA, you're defining that like every clock, I'm doing this, then this, then this, and those frames just keep feeding in. And it's doing the same thing pretty much every time.

  197. A

    And yeah, it can't really get backed up because there's no pipeline or buffer. Well, it's like

  198. B

    you've defined it so strictly, right? So it's not like there's not, it's not like branching, right? Like, oh, if I see, you know, the color blue, do this. If I see the color green, do this. You know, you don't do those kinds of things. FPGA is much more about doing like a known set of operations. Like I want to, you know, divide every pixel by, you know, three, and then add it to what the value of the previous pixel was. So it's kind of like you want to define that. And we talked previously about like GPU programming and how GPUs don't like having branches in them. Right? Because when you do general purpose GPU programming, the branches make it more difficult to kind of to do. And so FPGAs are similar in that regard. They're really good for when you know precisely what you want to do every time, and you don't have a lot of complex logic and algorithm around it. So that talks about

  199. A

    what it's really? What about the, like if you have, so if you're writing this VHDL or Verilog and you, so it sounds like you're almost writing arithmetic, like add these two registers and do this. How do you specify like these things can be done together, but this thing needs the other thing? I mean, does it figure out all the data dependencies for you?

  200. B

    So partly, right? You're defining. Yeah. So you're defining like, oh, here's kind of like this component. And this

  201. A

    component feeds into this component. So kind

  202. B

    of like functions. Right? So that's the equivalent. But it is a data flow language. Right? So you're describing how the data flows through the system. And so you're describing that flow. And it is something kind of starkly different from writing an imperative program. It's much more functional programming kind of style. Okay. So the reason why like FPGAs are good is like we talked about that, you know, doing things in parallel. So you have one processor, so you can add one set of numbers. But if you wanted to do like 10 of those at the same time, you might have like 10 cores in your processor, then you could do it. But like an FPGA, if you're doing some simple thing, you could just create 100 of these cores where a core does some very basic operation over and over again. And you can just keep creating more and more and more of them. And so you can get that parallelism very easy. And for like we said, certain sets of algorithms where it's very set what you want to do, and you just want to compute it and you want to do it really fast and over and over and over again, taking time to implement that algorithm in FPGA can get you a lot of speed.

  203. A

    Gotcha. Yeah, it also affects the power greatly. Like they, a lot of the smartphones now do MPEG decompression on, well, not an FPGA, but on, actually, how does that work? So if you write something in an FPGA, can you turn that into a processor?

  204. B

    Yes.

  205. A

    Okay. Sort of. Gotcha.

  206. B

    So a lot of those, they're called like coprocessors you'll hear about. So like the MPEG encoder. So it could be that that's just like another normal processor, but more likely it's a very specialized processor that's called an ASIC. And I don't know what ASIC stands for actually. Something IC, which is integrated circuit. I

  207. A

    will look it up right now. Okay.

  208. B

    All right, good. So basically an ASIC, you can take an FPGA description, a VHDL description, and synthesize an FPGA, which means figure out how to take this field programmable, this reprogrammable set of gates that you can interlink in different ways to represent the logic that I've defined in my VHDL program. But by the same token, the tool could also say, take that set of logic and determine the set of masks you would need to make to etch away at the silicon to actually make a custom chip out of silicon that does that one specific thing.

  209. A

    Gotcha. But once you do that, ASIC stands for Application Specific Integrated Circuit, which I don't know what that means.

  210. B

    Application. So like I said, so it's like once you make an ASIC, that's it. Like you can't change it anymore. It involves a lot of engineering costs to kind of determine how to go down to the actual gates and determine I only want these sets of gates and it's not reconfigurable. And once you make it, that's it. And you use it for a specific purpose. And so that's probably what like that MPEG chip is about. So somebody wrote this description and VHDL of how to do a portion of the MPEG encoding process really, really fast. And then they actually went and had a specific silicon chip made that does just that. And then they put it in all the smartphones. So an FPGA would be like the first step to that, like the prototyping step before moving to an ASIC. But it could also be that you ASIC is too expensive for your need. And so you just continue to use an FPGA. So like an ASIC per unit, like per chip would be a lot cheaper because it's doing, you know, it's like made and only does one thing. But like the initial cost, like you'd have to buy thousands of chips.

  211. A

    I see. You can't just like go buy one. So maybe this going back to this first news story about coin, I guess maybe they will, you know, take this preorder money that we give them and put the logic for switching the credit card numbers and things like that on ASIC. Yeah, so they could. Does that make sense? OK.

  212. B

    I mean, I don't know that that's what they're doing. But it is like an example of what you could do.

  213. A

    Gotcha. Yeah. So like there are much smaller than an FPGA that does the same thing. I mean, is it is it vastly different or is it about

  214. B

    So? So, yeah, I would say that, yeah, like if you had an equivalent, how big of an FPGA do you need to hold a set of operations versus an ASIC? The ASIC can be much smaller because FPGA needs to have all this extra routing and switching logic to be able to be reconfigured.

  215. A

    And you don't

  216. B

    need that in the ASIC. Like you're hardwiring one specific configuration. OK. So some of the things that make it difficult is there this FPGA programming falls in kind of a weird space. Right? So computer science people like, you know, Jason was describing himself would be very, you know, distraught to learn about all these details they had to pay attention to about clocking and interfacing with external power and those kind of things. And electrical engineers don't always enjoy programming. Some do, but some, you know, don't really want to do programming. And so this FPGA programming falls in between those two disciplines. And sometimes it's hard to find people who want to or have the ability to do it. And it can be difficult sometimes to take the logic of like a C program and actually determine how to do the same thing with the constraints of FPGA programming and VHDL.

  217. A

    Gotcha. Yeah. I mean, to Patrick's point, right? Like the reason why you'd want to do this in FPGA is to get some kind of like parallelism or speed benefit or something like that. So you can't just take your C program with the for loops and things like that and just put it directly into VHDL or Verilog because you lose all of your benefits. So so when you go to something like an FPGA, you have to think about the data dependency. Like, can I do all iterations of this for loop at the same time? Or if I can only do part of them at the same time, how do I structure my operations so that I know they're finished in time for the next batch to start? Things like that.

  218. B

    Yep. And testing is pretty hard. So, like I said, FPGAs, you know, interfaces don't have like the processors handle interfacing with outside world with all this specific logic. But like on an FPGA, they're meant to be used in different ways. And so often you have to worry about interfacing the outside world and determining the set of inputs you want to test against. So, like what happens if one of the inputs to your FPGA isn't to zero or one, but is floating around? What happens to your algorithm?

  219. A

    And how do you test that? What does that mean? How could it not be zero or one?

  220. B

    So, okay, we'll get sidetracked, but it's okay for a second. Okay, so like if a processor just for ease is running at five volts, so you powered it with five volts, then when it sees a given pin that is called an input pin, if that pin is at ground, then it says it's a zero. If it's at five volts, it says it's one. So that works really well. Digital says it needs to be either zero or one. Right? But what happens if you don't connect anything to that pin and the pin is just getting electromagnetic interference and it's varying from zero volts to eight volts to two volts to six volts?

  221. A

    Oh, oh, you have to deal with that while you're programming.

  222. B

    So, so yeah. So like it could just be flapping around on you. Right? Like and typically because of the nature of the way FPGAs sometimes want to handle those kinds of things, you have to handle those kinds of things versus like in a processor, people assume you don't want to handle those kinds of things. So they typically build the board such that doesn't happen. Gotcha. Also, the tools like still there isn't really good like open source tools for programming FPGAs and synthesizing like what amounts to the compiler, the thing that takes your VHDL and determines here's how I would program a set of logic gates. And even like I looked around because I wanted to as like a hobby, like like really programs. I've done some FPGA programming in the past for work-related stuff. But like as a hobby, like I wanted to do it. And the boards are typically pretty expensive to get one and actually, you know, try it out. And the tools themselves are very expensive. So, you know, thousands of dollars for these tools that compile these FPGA programs that you write. And often they're student versions or free versions. And there are even some tools and I've used a couple of them before very limitedly where you actually can use a restricted set of C language to define an algorithm and it'll synthesize the FPGA for you. So, it'll take your C language, compile it to VHDL, and then take that VHDL and pass it into one of these tools. Oh, wow. That tool will make the FPGA. And those are getting better. And one day people hope that like you'll just be able to program an FPGA in C++.

  223. A

    But if you do that, how do you tell it that, you know, that it should have, you know, three add, three add modules? Yeah.

  224. B

    So there's special kind of pre-processor tags you add and say like kind of hash, you know, pound in parallel eight and then a for loop. Right?

  225. A

    So do eight

  226. B

    iterations of this for loop in parallel. I made that up. But like that would be an example of what?

  227. A

    you write. Right? Yeah. So you annotate your code to help. Right? That's pretty cool. Yeah. I'm looking. I'm looking around on Google Shopping. Yeah. Yeah. It looks like it'll run you a few hundred dollars to get FPGA, which actually isn't that bad. No. They have some, they have some smaller ones that are sub a hundred dollars.

  228. B

    So, yeah. But versus like, you know, I've played around with little microprocessors and writing C code like Arduino style and you can get an Arduino for, you know, $20 or the processor that is used on there. You can get for like a dollar 30.

  229. A

    or dollar 50 or something. Yeah, that's true.

  230. B

    So, one of the interesting things is, you know, a lot of times you pair an FPGA with a processor because they both have their advantages. And so you can either talk like, you know, serial to the FPGA and communicate with it. Or oftentimes what's interesting is when you go to a memory address in C, then you are actually setting some pins on a microprocessor to hold the address that you specified. So in binary, these pins will represent that address you specify. And then another set of pins will start taking on the values of the data you write to that address, for instance. Some of the memory you have is what's called internal memory. When you do that, nothing will happen on those pins; you'll just write to internal RAM. But other parts of the address space are called and will map to these pins that are exposed on the outside of the processor. And when that happens, the FPGA could actually be sitting there. So one way you can talk to an FPGA is to say like, at address 5000, when you put the number three, I'm going to go turn this light on. And when you write the number four, I'm going to go turn it off. You can actually talk to it by writing kind of specific values to specific addresses. That's a lot you'll see common, even when you write like device drivers are handled that way.

  231. A

    I always wondered this: if you try to set the pins that are connected to the output of an FPGA instruction, what happens then? I mean, does the world collapse?

  232. B

    No, it's handled. But yeah, you got to be careful.

  233. A

    So what would happen? Like nothing would happen?

  234. B

    If you, I'm not actually sure what would happen. If you had two output pins connected just to each other, they'll try to drive each other. So I guess one would win.

  235. A

    Oh, I see.

  236. B

    That would take on whatever value of one of them or some value in between. I don't remember.

  237. A

    Well, I guess maybe—sorry, the question I was asking is, can you do it? Can you go through an FPGA backwards? Like what happens if you, instead of setting the input pins and then reading the output pins, if you set the output pins, what would happen? Would the electricity go backwards to the FPGA? No. No.

  238. B

    Typically, it's configured where the outputs are configured in one of three states: a pin is configured in one of three states to be an input, an output, or what's called disconnected, like a high impedance state where no matter what you do, otherwise it's not going to affect it. When it's an input, it's trying to read the value, so anything can happen on the thing. When it's an output, if two things are an output, they'll compete. And typically there's circuitry built in to protect them from the current flowing backwards. But what happens is what's called contention on the line. So whatever that piece of wire between the two will, it's undetermined whether it'll be a zero or a one, whether

  239. A

    it'll be positive or ground. Gotcha.

  240. B

    But yeah, they typically protect themselves from having current to flow backwards. That would be bad.

  241. A

    Yeah, right. Okay. That makes sense.

  242. B

    So like I said, you know, a processor and an FPGA could be embedded together on a device. You can also have a version of the processor inside of an FPGA. So some part of the FPGA is currently representing a processor, and then other parts, other things.

  243. A

    Oh, interesting. And

  244. B

    That's called soft cores. And so you can embed like an ARM processor inside your FPGA. And now people even talk about doing things like if I enter different modes of operation, having a processor to load a different program, as it were, on the FPGA. So reprogram the FPGA in the middle of something to behave differently. Oh, wow.

  245. A

    So you go to watch a video and the FPGA reprograms to be an MPEG decoder. That's

  246. B

    right. And now I'm recording a video. So it switches to be an MPEG encoder. You know, and now I'm doing something else.

  247. A

    How come that isn't widespread? It sounds like an amazing idea.

  248. B

    I mean, I think it's just one of those very difficult things to do. Like how to figure, like not only do you have to program the FPGA once, now you have to like figure out the code for all these different ones and then when to switch. Gotcha. Gotcha. And then it might just be easier, like as technology gets better and better, like instead of having reprogramming it between two different modes, you just have an FPGA that's twice as big. And then you can program it to be both at the same time.

  249. A

    Oh, true. That makes sense.

  250. B

    So, but people have talked about it and there's some interesting stuff around that.

  251. A

    Well, this is very cool. So from what you've taught us, we should be able to go on DigiKey, buy some cool motors and electronics and FPGA, and go to town. That's pretty awesome. I might try this.

  252. B

    Yeah, this isn't our normal episode. Like I didn't really go through the merits of VHDL or Verilog or how to

  253. A

    Program them. Oh yeah, it sounds like there aren't really any competition for these two.

  254. B

    Yeah, but you know, hopefully spark some interest or explain what it is. A lot of people have heard the term FPGA and just don't know what it is, or what it does, or how it's different.

  255. A

    Yeah, yeah, definitely. This is awesome. I've always wanted to build, to do something in the robotics space on my own, but I've never had the talent to do it. So maybe this will be, even just something as simple as, like if it could just go and open the fridge and get a sandwich or something like that. Even if I have to tag the sandwich, you know, something very simple, it'd be fun to just do it for fun.

  256. B

    Yeah, that's still setting your sights a little high. Yes. I'm going to amuse myself with like getting an LED

  257. A

    to blink on and off. Yeah, I guess that's true. I should probably start there. Okay. So. All right. Cool. Well, I think that's a show. Yeah. Thanks a lot for helping carry this show. It's a really interesting topic. I thought it was awesome.

  258. B

    All right. And thanks for all our comments, people encouraging us to get back on our mics and record the next episode.

  259. A

    Yeah, definitely. It's pretty hard, right? Because, you know, we've been going through a lot of changes. I actually work across town now. So it was a big transition for me. And actually, yeah, we installed Ticket to Ride in our house. And so we have trains going by constantly. So now when I mute

  260. B

    that audio, people aren't going to know what you're talking about.

  261. A

    Oh, a tear. Okay. But yeah, we've had a lot

  262. B

    of personal stuff. Trains are driving by my house.

  263. A

    Yeah. Now you can't mute it. Not without everything being awkward. But yeah, so I've had a lot of personal stuff going on. But I appreciate everybody's patience. And, you know, we definitely have a lot of fun doing this show. I learned something brand new every show. And I'm sure you guys do, too. So, you know, thanks for all the support. And have a good time.

  264. B

    All right. Until

  265. A

    Next time. If you build anything, you have to let us know. I want to see pictures.

  266. B

    All right. Bye. See you later. The

  267. A

    Intro music is Axo by Binar Pilot. Programming Throwdown is distributed under a Creative Commons Attribution ShareAlike 2.0 license. You're free to share, copy, distribute, transmit the work, to remix, adapt the work. But you must provide attribution to Patrick and I, and shareAlike in kind. See you later.