Author Topic: newb question  (Read 1921 times)

0 Members and 1 Guest are viewing this topic.

Offline vivi-dTopic starter

  • Contributor
  • Posts: 42
  • Country: us
newb question
« on: July 18, 2022, 07:27:22 pm »
I was wondering if you could help me understand more about FPGA development...

Suppose someone wanted to recreate newerish video game console, is it enough to just describe the instruction set in VHDL to recreate a processor. Or is there more involved that I haven't learned of yet?

No solder before coffee! Unless it's 0201...
 

Offline pbernardi

  • Contributor
  • Posts: 19
  • Country: br
Re: newb question
« Reply #1 on: July 18, 2022, 08:12:46 pm »
Hello,

Theoretically you could describe a instruction set and make a processor using HDL language. But the behavior of this processor have some real-life limitations:

1) The target processor you described have to fit in the logic you have in the FPGA (FPGA does not have infinite logic and because it is programmable, with predefined cells, it will waste more logic than a fully customized ASIC)
2) The FPGA has speed limits (IOs, general logic, DSP, BRAM, etc.). Usually you can find these limits at target datasheet.

As the result of 1) and 2), if you implement a processor which fits an FPGA, the odds are you implement a much slower processor than a "newerish video game console", *if* you describe the processor flawlessly (which is a very difficult task).

Moreover, the processor is only one of several necessary parts of console. You need also some kind of ROM storage (one SSD, HDD, disk for older consoles, or even cartridges), and a volatile memory (SDRAM or some of several kinds of DDR{1/2/3/4} modules). Memories, in general, are prebuild in FPGA and divided in small BRAM modules, so you cannot have as much memory you want. Usually, you can have enough memory for cache in a FPGA and that is it.

So, once you cannot embed memory, you have to think at least on some kind of flash/ram controller + caches added to the processor. (+ interfaces with keyboard, control, power supply, etc.). All this put, the effort to develop this from scratch is *huge*.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4702
  • Country: dk
Re: newb question
« Reply #2 on: July 18, 2022, 08:36:28 pm »
Hello,

Theoretically you could describe a instruction set and make a processor using HDL language. But the behavior of this processor have some real-life limitations:

1) The target processor you described have to fit in the logic you have in the FPGA (FPGA does not have infinite logic and because it is programmable, with predefined cells, it will waste more logic than a fully customized ASIC)
2) The FPGA has speed limits (IOs, general logic, DSP, BRAM, etc.). Usually you can find these limits at target datasheet.

As the result of 1) and 2), if you implement a processor which fits an FPGA, the odds are you implement a much slower processor than a "newerish video game console", *if* you describe the processor flawlessly (which is a very difficult task).

Moreover, the processor is only one of several necessary parts of console. You need also some kind of ROM storage (one SSD, HDD, disk for older consoles, or even cartridges), and a volatile memory (SDRAM or some of several kinds of DDR{1/2/3/4} modules). Memories, in general, are prebuild in FPGA and divided in small BRAM modules, so you cannot have as much memory you want. Usually, you can have enough memory for cache in a FPGA and that is it.

So, once you cannot embed memory, you have to think at least on some kind of flash/ram controller + caches added to the processor. (+ interfaces with keyboard, control, power supply, etc.). All this put, the effort to develop this from scratch is *huge*.

and once you have done that you miss the parts that most people never get to; development tools so you can actually make something with that fancy new CPU you just made

 

Offline pbernardi

  • Contributor
  • Posts: 19
  • Country: br
Re: newb question
« Reply #3 on: July 18, 2022, 09:17:20 pm »
Well, vivi-d stated in his case about an existing instruction set, so I suppose in this case the processor would have at least some kind of support.

But for a new instruction set, yes, there is no development tools for CPU with non-standard instruction set.  :-+
 

Offline Someone

  • Super Contributor
  • ***
  • Posts: 4934
  • Country: au
    • send complaints here
Re: newb question
« Reply #4 on: July 18, 2022, 11:07:52 pm »
Current state of the art:
https://github.com/MiSTer-devel/PSX_MiSTer

Good luck implementing a CPU and/or GPU and/or DSP, they aren't always fully documented!
 

Offline vivi-dTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: newb question
« Reply #5 on: July 19, 2022, 12:10:37 pm »
Quote
As the result of 1) and 2), if you implement a processor which fits an FPGA, the odds are you implement a much slower processor than a "newerish video game console", *if* you describe the processor flawlessly (which is a very difficult task).

Is the difficulty of describing a processor flawlessly due to not having the right docs? Is there more than knowing the instruction set and how many clock cycles each instruction takes?
No solder before coffee! Unless it's 0201...
 

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4310
  • Country: nl
Re: newb question
« Reply #6 on: July 19, 2022, 01:18:03 pm »
A processor is more than just the instruction set.

1) There is the ALU
2) There are the registers
3) Stack mechanism
4) Instruction pointer and instruction fetch mechanism
5) Instruction decoding
6) etc.

And that is just a simple processor. For the more complicated ones there is memory management, pipelines, caches.

If you are thinking about such an operation from scratch it might be an idea to first write an emulator on a computer to get an understanding of the instructions and workings of this processor you have in mind.

Edit: Take a look here: https://www.tutorialspoint.com/microprocessor/microprocessor_quick_guide.htm
« Last Edit: July 19, 2022, 01:19:54 pm by pcprogrammer »
 

Offline vivi-dTopic starter

  • Contributor
  • Posts: 42
  • Country: us
Re: newb question
« Reply #7 on: July 19, 2022, 02:21:34 pm »
Thanks for the link! I'm starting to appreciate the complexity lol
« Last Edit: July 19, 2022, 02:26:07 pm by vivi-d »
No solder before coffee! Unless it's 0201...
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: newb question
« Reply #8 on: July 19, 2022, 03:18:52 pm »
As a learning project, there is the LC3 processor from Patt & Patel

https://www.amazon.com/Introduction-Computing-Systems-Gates-Beyond/dp/0072467509

It's a simple RISC type processor of somewhat limited capacity but it's a great start.  The project is laid out for microcoding and a worksheet is provided.  I used the Finite State Machine without microcoding approach but there's nothing wrong with microcoding.  In some ways, it is easier.

Figure C.2 gives you just about all you need to know to write the VHDL code:
Figure C.3 gives the hardware layout

http://users.ece.utexas.edu/~patt/05f.360N/handouts/360n.appC.pdf

Appendix A provides info on the instruction set

https://www.cs.colostate.edu/~cs270/.Summer22/resources/PattPatelAppA.pdf

This project is used by a lot of universities as part of the hardware design program.  Info is all over the Internet.  And, yes, there is an assembler.  It easily runs at 100 MHz on a Xilinx Artix 7 and can probably run at 200 MHz with a little effort.  But that's SLOW compared to a Teensy 4.1 at 600 MHz and a really fast design.

https://www.pjrc.com/store/teensy41.html

There's a pretty good intro to CPU design in this project.  Figure the main file (I called it LC3.vhd) for around 1000 lines of code.  There are several components that add a few hundred lines (UART, BlockRAM, etc. See attached file explorer page
).
« Last Edit: July 19, 2022, 03:31:27 pm by rstofer »
 

Offline pbernardi

  • Contributor
  • Posts: 19
  • Country: br
Re: newb question
« Reply #9 on: July 19, 2022, 03:21:19 pm »
Quote
As the result of 1) and 2), if you implement a processor which fits an FPGA, the odds are you implement a much slower processor than a "newerish video game console", *if* you describe the processor flawlessly (which is a very difficult task).

Is the difficulty of describing a processor flawlessly due to not having the right docs? Is there more than knowing the instruction set and how many clock cycles each instruction takes?

Lack of documentation is of course a factor. In the end, I think it depends really on what instruction set you are going to try. RISCV for example, is a FPGA-friendly ISA (https://www.hackster.io/news/the-rise-of-the-dark-risc-v-ddb49764f392 presents an implementation in one night!)

Some other processor just have too many instructions to decode or are too irregular (CISC processors with different instruction cycles, long pipelining, etc.). In the end, I think, describing a simple, not optimized processor with a simple ISA is not an big issue. But if you want to describe an complete processor to work fast and efficiently, this is a challenge.

To give you an idea: most soft cores works at 100-200MHz range at best. For low-ends FPGAs, it is not uncommon to find processor implementations working at speeds <100 MHz.

You might take a look at some soft cores to have an idea. There are some references:

- Opencores: https://opencores.org/
- There is a thread here about RISCV: https://www.eevblog.com/forum/fpga/the-neorv32-risc-v-processor/
- You can look at some old processors which are now open source: J-core or PowerPC for example.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9933
  • Country: us
Re: newb question
« Reply #10 on: July 19, 2022, 05:27:08 pm »
PACMAN!

There is a Z80 core ( named T80) at OpenCores.org that can be modified slightly to play PACMAN using the ROMS from the MAME PC implementation.

https://opencores.org/projects/t80

https://www.fpgaarcade.com/kb/pacman/

I realize that this is nothing like a modern game console but installed in a cocktail table, it is kind of cool.  You can buy one prebuilt or, if you like woodworking, build your own.  There are plans on the Internet

https://www.henningludvigsen.com/index.php/2020/12/23/building-a-cocktail-arcade/

There are also some Raspberry Pi game emulations around.

I also added a compact flash to that T80 core and installed CP/M 2.0 - worked very well.  Hint:  Watch that Interrupt line, it floats high and that causes a recursive interrupt.  You need to get control of the signal.

 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: newb question
« Reply #11 on: July 19, 2022, 05:58:03 pm »
I learned a lot by porting MikeJ's PacMan implementation to various FGPA boards. His projects are very well done and typically work very nicely.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3889
  • Country: us
Re: newb question
« Reply #12 on: July 19, 2022, 06:19:34 pm »
You can make soft processors for a variety of instruction sets in an FPGA, and do so fast enough to emulate older gaming systems but not modern consoles.

That is only the start of what is needed as the CPU is only one part of a gaming console.  A lot of it also depends on how accurate you want to be.  For an in-depth look at what it takes to fully emulate all aspects of the hardware (CPU, video and audio processors, and other peripherals) of a 30 year old gaming console check out: https://arstechnica.com/gaming/2021/06/how-snes-emulators-got-a-few-pixels-from-complete-perfection/ but also realize that functional SNES emulators that could play most games but did not provide pixel/cycle accurate behavior were already widely available in the late 90s.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: newb question
« Reply #13 on: July 19, 2022, 07:54:57 pm »
It takes a fairly large FPGA just to emulate the humble NES and it was quite a few years before that was well implemented so that puts things into perspective. FPGAs are a lot of fun for recreating vintage hardware but even that can be a big project. I've done several bronze age arcade games and it was not easy to get those working and I didn't even create the CPU for them, I used the existing T65 core.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf