Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/09/08 15:46
Modified:
  08/09/08 15:55

Read: times


 
#157356 - take a look at the content
Responding to: ???'s previous message
Per Westermark said:
The problem with free IP cores are that they tend to be described in VHDL. This is good for compilation into silicon or into FPGA or similar. But I need to do the emulation using C.

Yes, I can of course read the VHDL and use as specification when writing the C code.

Exaclty!

Emulating a processor in itself isn't so extremely hard. But the complexities quickly increases when the emulated processor has an MMU. Emulating a MIPS in an ARM7 would indirectly mean that a smaller processor has to emulate a larger.

If you poke around the www looking for a compiler called XPL0 (that last digit is a zero) you'll find a compiler that was written for the MCS6502 but which emulates a 16-bit machine. It's been in use for about 30 years, and folks are still using it, though in other contexts.

The concept with RISC processors is that each instruction should be simple, so that the hw can run at a very high clock frequency. But that also implies that it may take multiple instructions to perform the job of a single CISC instruction. And a normal RISC program tends to be larger because of the many (but regularly formed) instructions needed.

That's the theory, though the results I've observed have often been disappointing.

If I develop my own abstract machine, then a 32-bit machine isn't a problem since I can make sure that it matches the capabilities of an ARM7. If emulating a real processor, then it is porbably way better to emulate an 8-bit or 16-bit processor. 8-bit and 16-bit processors are better optimized for use with limited memory, and they are also free from MMU and other complexities.

I have been thinking a bit about the SDCC compiler and emulating a Z80, or the gcc compiler and emulting an AVR chip. I have written emulators for both the Z80 and the AVR Mega88 so I would at least have a running start if I select any of these cores.

Another alternative I have been looking at is to use Small-C
http://en.wikipedia.org/wiki/Small-C
either with Z80 emulation, or possibly with a customized virtual processor.

A possibility would also be to see if there are any usable 8086 emulators, which would indirectly allow a lot of old MS-DOS tools to be used.



There's more than just VHDL in the provided package on OpenCores.

What's even more important, is that the author of that particular MIPS implementation has provided a simulator-compatible testbench, which will show you how to verify that your implementation works. The general principles are applicable to other cores, too, but that will give you something with which to compare.

If you're interested in the Z80, there are several Z80-compatible simulators that run under MSDOS and support lots and lots of HLL's for Z80 and 8080 under the guise of CP/M emulators. These provide a perfectly useable development system for the Z80 under CP/M, and also for the Z80 without the support of the OS. On your current PC, these will simulate the Z80 at many times the Z80's performance, yet provide perfectly useable code. There are now, and long have been, compilers for COBOL, FORTRAN, PASCAL, LISP, BASIC, and 'C', among many others, as well as interpreters for some of those same languages.

While it might be fun to do what you suggest, if you plan to target Z80, the work has all been done. I don't know how much of all that has been made available in source form, but there are disassemblers ... if you're a glutton for punishment.

BTW, there are some 'C' <=> VHDL/Verilog tools out there.

Further, if you intend to add an MMU to an existing architecture, you may be disappointed with the performance. For example, the fastest Z80's I've got lying about are specified operate at 20 MHz. None of the OpenCore IP's I've seen operate at that speed, despite the fact that the FPGA's in which they run cost 10-100x as much. There's little to gain, methinks.

That MLITE IP runs on the XILINX Spartan3E starter kit, costing about $100. That provides everything that the entire system needs, including a very large SDRAM, FLASH, ethernet, etc.

I'd recommend, at least, having a close look at what's been done. Keep in mind that VHDL is a language targeted at modeling a logic set for simulation, and not just for implementation in programmable logic. The MIPS is, in fact, complete with a readily available 'C' compiler, and this package provides a simulator. That strikes me as a "golden" opportunity.

Keep in mind that, while the source code won't be portable to your specific requirement, what you learn from it will be.

RE


List of 20 messages in thread
TopicAuthorDate
Virtual or existing architecture for emulation            01/01/70 00:00      
   Additional info about host/usage            01/01/70 00:00      
      How about MIPS?            01/01/70 00:00      
         VHDL            01/01/70 00:00      
            take a look at the content            01/01/70 00:00      
               I think 8 or 16 bit is optimum            01/01/70 00:00      
                  Maybe you should start with an ARM chip            01/01/70 00:00      
                     I2L sounds interesting            01/01/70 00:00      
                        It's probably best to check with the maintainers            01/01/70 00:00      
                           Doesn't seem to be a C to I2L            01/01/70 00:00      
                              The LLVM Compiler Infrastructure            01/01/70 00:00      
                              Since there's help available ...            01/01/70 00:00      
      With the low price of 8-bit single chip MCUs...            01/01/70 00:00      
         Slave processors not an alternative            01/01/70 00:00      
   Users            01/01/70 00:00      
      Probably debugging on PC            01/01/70 00:00      
         Are you really going to do that!            01/01/70 00:00      
            Existing building blocks helps            01/01/70 00:00      
               It hasn't been done for you but ...            01/01/70 00:00      
            When I was in school ...            01/01/70 00:00      

Back to Subject List