Post B6eMPskab92NZ5t83k by gloriouscow@oldbytes.space
(DIR) More posts by gloriouscow@oldbytes.space
(DIR) Post #B6eMPmq2ZxphEGOOiu by gloriouscow@oldbytes.space
0 likes, 0 repeats
This weekend, I think I will try to get the DE-10 Nano controlling an 8080 CPUI'd like to generate an emulator test suite for the 8080. I haven't previously because it's a chip that requires weird voltages and has a minimum clock of around ~1MHz. #retrocomputing
(DIR) Post #B6eMPn39nCKBswWsAS by gloriouscow@oldbytes.space
0 likes, 0 repeats
What would be a fun demo is to run Space Invaders. Little trivia, if you didn't know Space Invaders used an 8080 CPU.It had some custom hardware - the 8080 has no shift operations (you're going to rotate, and you'll like it) so they added hardware to do shifting.
(DIR) Post #B6eMPnEr5hgMTE0DOy by gloriouscow@oldbytes.space
0 likes, 0 repeats
The Space Invaders hardware is so trivial it's already cemented itself as a entry-level emulator, alongside the probably more popular Chip-8. And I don't even have to emulate the 8080, since I'll actually have one.The only thing I'm not sure of is how I'd put a screen on on the DE-10 Nano.
(DIR) Post #B6eMPnSgGIk1A6TFx2 by gloriouscow@oldbytes.space
0 likes, 0 repeats
I have a RA8875 driver board and screen I was originally going to use for fuzzing the MC6845 , but I got Area 5150 working without having to resort to such measures (Although I think it would still be fun, and I might Discover Stuff).
(DIR) Post #B6eMPnf5WAfLmaHAI4 by gloriouscow@oldbytes.space
0 likes, 0 repeats
If I'm feeling particularly sassy I could even hook up a joystick.Space Invaders' sound effects were generated by analog circuitry, and so most emulators use samples for playback. I could use a Pico to stand in for the Space Invaderrs sound hardware!
(DIR) Post #B6eMPntGfS0aUYuUOO by gloriouscow@oldbytes.space
0 likes, 0 repeats
unfortunately the DE-10 Nano is not 5V tolerant like the RP2350 is. It's probably not even -5 or -12V tolerant either.
(DIR) Post #B6eMPo5JwdeL5wY7BA by gloriouscow@oldbytes.space
0 likes, 0 repeats
I have one of these. It's a RetroShield, by 8-bit Force. It's designed to let you interface an 8080 CPU with an Arduino or, as seen here, a Teensy via a Arduino-compatible adapter board. The Teensy adapter board has level shifters because the Teensy is 3v only. How convenient for us! Remove Teensy, plug in FPGA.8-Bit Force overclocks the Teensy as the Teensy is bit-banging the 8080 furiously to get close enough to the 1MHz clock so that the CPU doesn't hang. But we don't need to worry about that. We have a Cyclone V FPGA, baby.
(DIR) Post #B6eMPoKD3HYjq7W0O0 by gloriouscow@oldbytes.space
0 likes, 0 repeats
Space Invaders runs its CPU at close-enough-to-be-practically 2MHz. This is no sweat. Also no sweat is emulating the cabinet's massive 1KB of RAM and 7KB of VRAM.I honestly expect to spend most of my time futzing with the display.
(DIR) Post #B6eMPoVYN6dKPIp44G by gloriouscow@oldbytes.space
0 likes, 0 repeats
The monitor in Space Invaders is in portrait orientation - its just sitting on its side, so the graphics are all rotated 90 degrees. We can just rotate our display too, of course, but it would be nice to do that in hardware if possible. I should probably read this display controller's datasheet. It has some interesting features - it has some hardware drawing primitives. Maybe it can rotate for us.
(DIR) Post #B6eMPoeloq0Qrt8QQy by gloriouscow@oldbytes.space
0 likes, 0 repeats
The RA8875 can draw lines, boxes, even draw text in various font sizes.It doesn't seem to rotate bit-blits.. However, you can tell it to rotate fonts. So we can rotate the screen, and still have some text output.
(DIR) Post #B6eMPop3CcEHNlwdSS by gloriouscow@oldbytes.space
0 likes, 0 repeats
This was my set up for the teensy / mc6845 experiment.Note the lack of any level shifters. I measured the voltage output of the mc6845's output pins as being under 3.3v even when powered with 5v, but I was really sort of YOLOing stuff here.
(DIR) Post #B6eMPoyGeLbNqMFzpA by gloriouscow@oldbytes.space
0 likes, 0 repeats
We talk to the display controller via SPI. SPI is a four-wire serial protocol with problematic terminology. it is faster than the electrically simpler, 2-wire i2c protocol.there are tons of examples of talking to SPI devices in Verilog so I don't have to figure out how to do that, I can just steal the code directly https://github.com/janschiefer/verilog_spi
(DIR) Post #B6eMPp9byAfyPXZ3VQ by gloriouscow@oldbytes.space
0 likes, 0 repeats
if you basically use a real CPU but emulate everything else, are you basically putting the CPU in the matrix?
(DIR) Post #B6eMPpKbJJSyxchpdQ by gloriouscow@oldbytes.space
0 likes, 0 repeats
...Verilog doesn't have strings.
(DIR) Post #B6eMPpUsh5gpTVW2eu by gloriouscow@oldbytes.space
0 likes, 0 repeats
Okay, we've either initialized the screen properly or not, but it's doing something. We have a white screen.
(DIR) Post #B6eMPpfs2ETq1aeomu by gloriouscow@oldbytes.space
0 likes, 0 repeats
the fun thing about implementing something over an untested protocol implementation is that you don't know if the protocol is broken or the way you're talking to the thing is brokenwhynotboth.jpg
(DIR) Post #B6eMPpsdGmgkfAd0gC by gloriouscow@oldbytes.space
0 likes, 0 repeats
If this happens do not panic. This just means your Cyclone V hungers for blood. You have a lot of blood, give it some. You won't miss it
(DIR) Post #B6eMPq2ueYubB3RDhg by gloriouscow@oldbytes.space
0 likes, 0 repeats
I wonder how many times I've written a Hello World program.no i didn't write a bitmapped font engine in fifteen minutes, the display controller has built in fonts and text output. Most of the display commands are fairly simple sequences of opcode and parameters. There are a lot of them, but we don't really need to do anything for the moment besides maybe a few diagnostic strings - if we could track the 8080's program counter that would be cool.The main function we need is blitting the space invaders bitmap to the screen from memory.
(DIR) Post #B6eMPqH5nqFpt24Xo0 by gloriouscow@oldbytes.space
0 likes, 0 repeats
Space Invaders has a resolution of 224x256. Which is actually 256x224, because again, the monitor is sideways. This screen is 800x640, annoyingly just not quite large enough for a clean 3x scale-up. I'll just have to fill the margins with cats.
(DIR) Post #B6eMPqPbID3mJQ3L4C by gloriouscow@oldbytes.space
0 likes, 0 repeats
The first thing we need trying to drive an 8080 is a clock. Or rather, two clocks.You see, the 8080 is an extremely asinine design and needs three goddamn voltages and two stupid out-of-phase clocks.You know the Z80? The fantastically successful chip that was in bajillions of devices over three decades? The z80 succeeded by being the 8080, except not stupid.
(DIR) Post #B6eMPqc0Y4z6vtrFPE by gloriouscow@oldbytes.space
0 likes, 0 repeats
Or in other words, the Z80 is the Tandy 1000 to the 8080's PCjr.
(DIR) Post #B6eMPqmztDm7Tz01XE by gloriouscow@oldbytes.space
0 likes, 0 repeats
phi 1 and phi 2 are kinda inverse of each other, but phi 2 is longer... why, Intel. why. this is the sort of thing that must have been a real bitch to do on the Teensy, but is perfect for an FPGA. FPGA don't care. We'll just skip the PLL entirely and make 8080 clock function that consumes the raw 50Mhz clock since we've got a clean evenly-divisible clock target.
(DIR) Post #B6eMPqwvIJiNyldx0S by gloriouscow@oldbytes.space
0 likes, 0 repeats
i don't think we need the bus arbitration pins for the moment - the rest of the chip maps pretty cleanly to one of the DE-10 Nano's 40-pin GPIO headers.Yeah, I said one, it has like 80+ GPIO on top of the normal Arduino headers. Bonkers. I could probably hook up a Z80 and an 8080 and make them fight each other to the death
(DIR) Post #B6eMPr8Gc8myXwx0gi by gloriouscow@oldbytes.space
0 likes, 0 repeats
here we go, two clocks for our dear lumpy 8080Φ1 looking a little sad but I'm sure its fine. it's fine. it'll be fine.
(DIR) Post #B6eMPrLjo3Z3DjFlgW by gloriouscow@oldbytes.space
0 likes, 0 repeats
i'm guessing Φ2 could be a little longer, Φ1 looks good though, other than being a bit melty.this is official semiconductor science, by the way, it's called onion sheet engineering
(DIR) Post #B6eMPrW1Bpmtjc3yi0 by gloriouscow@oldbytes.space
0 likes, 0 repeats
doing things with this level of precision is pretty wild - on ArduinoX86 it was hey, 8088, your duty cycle is "yes"
(DIR) Post #B6eMPrhMVerUInN2OG by gloriouscow@oldbytes.space
0 likes, 0 repeats
as an industry professional with an entire two weeks of FPGA experience I officially deem this "pretty darn good"
(DIR) Post #B6eMPrqvw4WAmTqgJE by gloriouscow@oldbytes.space
0 likes, 0 repeats
We have a 50MHz base clock, and a 2MHz target clock. This requires a very difficult mathematical technique called "division"This gives us a translated time base of 25 base cycles, of which Φ1 is high for 4 base cycles, and Φ2 is high for 13.
(DIR) Post #B6eMPs1ZIX1bJSpAsy by gloriouscow@oldbytes.space
0 likes, 0 repeats
here's the sauce always @(posedge clk) begin if (!reset_n) begin phase_count <= 8'd0; phi1 <= 1'b0; phi2 <= 1'b0; cycle_tick <= 1'b0; end else begin phi1 <= (phase_count >= PHI1_START) && (phase_count < PHI1_END); phi2 <= (phase_count >= PHI2_START) && (phase_count < PHI2_END); cycle_tick <= (phase_count == (CYCLES_PER_CPU - 1)); if (phase_count == (CYCLES_PER_CPU - 1)) begin phase_count <= 8'd0; end else begin phase_count <= phase_count + 8'd1; end end endis there a better way to do this? almost certainly
(DIR) Post #B6eMPsDyYOwvvwd5E0 by gloriouscow@oldbytes.space
0 likes, 0 repeats
Let's assemble our retroshield
(DIR) Post #B6eMPsOFwBAmRpRIFU by gloriouscow@oldbytes.space
0 likes, 0 repeats
LED works. That's good. I always wire these things up backwards.
(DIR) Post #B6eMPsZbG0FN10kLvk by gloriouscow@oldbytes.space
0 likes, 0 repeats
Ready to go! Now where did I put the 8080 board...
(DIR) Post #B6eMPskab92NZ5t83k by gloriouscow@oldbytes.space
0 likes, 0 repeats
What say ye, little jumper wire found on my carpet beneath the desk?Your bends whisper of past projects. What did you help me do?I thank you. I shall try to take you on a new adventure.
(DIR) Post #B6eMPt5VLNlebxfpey by gloriouscow@oldbytes.space
0 likes, 0 repeats
Well this is going to be a much shorter thread if I can't actually find where I put the 8080.I wonder what being organized is like.I swore I saw it a week ago. You know how you see something but somehow fail to remember the context of its position? I thought it was on my workbench. It is not.
(DIR) Post #B6eMPtVjlqkdvJwmY4 by gloriouscow@oldbytes.space
0 likes, 0 repeats
It was probably time
(DIR) Post #B6eMPthR4M6oVbQ7ma by gloriouscow@oldbytes.space
0 likes, 0 repeats
I'm trying to remember why I bought 16 CGA cards. They're everywhere.Imagine you were looking for something and you had to lift up a CGA card to search each spot
(DIR) Post #B6eMPttULXkZ6z3kZM by gloriouscow@oldbytes.space
0 likes, 0 repeats
Woot! I found it. It was in a box marked "my PCBs" which although technically true in the sense of ownership I dont think that's what I meant when I wrote that on there.
(DIR) Post #B6eMPu47i0Fzdy2F96 by gloriouscow@oldbytes.space
0 likes, 0 repeats
What's on this thing? First we have four 74HC245's. These are octal bus transceivers. Not sure what we need those for if we're raw-dogging the CPU but they can't really hurt to have. The schematic shows that two of them buffer the address lines, one buffers the data bus, and the other buffers some miscellaneous signals like reset, intr and sync. Oh, and a LED. We're gonna blink the shit out of that.
(DIR) Post #B6eMPuMua9HmaEpFQm by gloriouscow@oldbytes.space
0 likes, 0 repeats
Then we have these thingies.This is the primary reason I never tried to make a 8080 PCB for my Arduino stuff. Because if it ain't TTL I don't know what I'm doing.Looks like this thing is a DC-DC converter that takes 5v and outputs 15V. How does a DC-DC converter boost voltage? Excellent question. Go ask someone who actually knows.
(DIR) Post #B6eMPubRi6ubJJcr5M by gloriouscow@oldbytes.space
0 likes, 0 repeats
This board inverts the clock lines. I thought that was odd, but then I noticed this.Oh right, a 9V clock. Everybody knows you need a 9V clock. Silly me. Rather than do any boosting, I suppose this code generates an inverted clock, which passes through an open-collector inverter with its outputs pulled up to 12V.There are solder pads you can bridge if... like the driver is struggling to pull down the output clock line you can gang up three drivers? I don't know enough to call this sketchy but I think it might be sketchy.
(DIR) Post #B6eMPun90cGltb6CJs by gloriouscow@oldbytes.space
0 likes, 0 repeats
I'm really going to have to check everything out under the scope once this is all hooked up.
(DIR) Post #B6eMPuy8Ll3mRgEyRs by gloriouscow@oldbytes.space
0 likes, 0 repeats
So this is my little setup. It's kinda messy. But we have our display controller, the de10-nano, the retroshield 3v teensy board, and the retroshield 8080 board. I just need to jumper gpio1 over to the teensy headers.
(DIR) Post #B6eMPvBFYzYH6MNRtQ by gloriouscow@oldbytes.space
0 likes, 0 repeats
I think the clocks look okay nowI'm just gonna send it. Let's plug the 8080 in and see if it starts incrementing its address lines. Or whatever an 8080 does when it reads garbage
(DIR) Post #B6eMPvOMmE2ll2VvKy by gloriouscow@oldbytes.space
0 likes, 0 repeats
All we really have to do is feed it all 0's on the data bus, because 0x00 is the NOP opcode on an 8080. It will happily do that until the heat death of the universe, so we should then see the address pins counting.
(DIR) Post #B6eMPvbTzSXGPieOmW by gloriouscow@oldbytes.space
0 likes, 0 repeats
A NOP takes 4 clock cycles, so a 2MHz 8080 will execute NOPs at 500kHz. Half of those will be at odd addresses, so we should see A0 toggle at 250kHz if the 8080 is now running.... well, would you look at that.It's times like this I freaking love being a huge nerd.
(DIR) Post #B6eMPvlPOYTWuVIKFk by gloriouscow@oldbytes.space
0 likes, 0 repeats
I've hooked the RESET pin up to one of the DE10's user switches so I can flip the switch to hold the CPU in reset and watch A0 stop, then flip the switch back and watch it start running again. Sweet.
(DIR) Post #B6eMPvwkiNY7TgbNw0 by gloriouscow@oldbytes.space
0 likes, 0 repeats
So just a few more things to do - we need to read the status byte during SYNC, we need to dispatch reads/writes to memory or IO as appropriate, and we need to implement an interrupt that fires off every 16,666 cycles
(DIR) Post #B6eMPw5cBQddvAkSkS by gloriouscow@oldbytes.space
0 likes, 0 repeats
Okay this might be a hot take and maybe it's just a skill issue but I freakin hate sockets with round holes. I don't know what the point is besides to ensure you bend a pin trying to insert your chip.
(DIR) Post #B6eMPwK9JOGSeFY4P2 by xot@mastodon.gamedev.place
0 likes, 0 repeats
@gloriouscow Their point is they provide a much more secure connection than dual- or single-wipers. But because they deform, they aren't great for chip reinsertion. Breaking pins is just a bonus.
(DIR) Post #B6eMPwhBvihDniKTJo by gloriouscow@oldbytes.space
0 likes, 0 repeats
@xot i don't know i don't have a lot of chips just falling out of regular sockets willy nilly
(DIR) Post #B6eMPwq3OlmkFCTY8G by xot@mastodon.gamedev.place
0 likes, 0 repeats
@gloriouscow Maybe not willy-nilly, but vibration will cause an IC to unseat from a dual-wipe socket faster than a machined socket. Another problem I've noticed with wiper-style sockets is that the contacts are flimsy and can be crushed if the registration between the pin and wiper is off. There will be a weak or no connection, the socket is ruined, and the fault isn't immediately visible. I'm not arguing for machined sockets. They are often a pain in the ass.
(DIR) Post #B6eMPwzynrj0jz7TbU by gloriouscow@oldbytes.space
0 likes, 0 repeats
A colorful mess.
(DIR) Post #B6eMPx26fxQUqa7Av2 by gloriouscow@oldbytes.space
0 likes, 0 repeats
@xot good thing i'm not making vibrators...yet
(DIR) Post #B6eMPxGdnv3JZeumZc by astraleureka@social.treehouse.systems
0 likes, 0 repeats
@gloriouscow @xot socketed vibrators for home upgradability purposes 👁👄👁