 Good afternoon everybody and sorry for this pose and the wrong format of the slides. I think it happens sometimes and Soon enough you'll see that it's not the only fault here so What is Lua? What is Lua Jit and why it might be interesting or it is interesting to port One to the other one First a few words about myself and as you've already see I'm not really a software developer, so I know Not so much about the software and spent Last quarter century Developing hardware where the software is usually runs on and here it was the different systems embedded systems and system Now it's system on modulus and most of them are FPGA or SOC FPGA based systems on modulus And yes, I can write some code on VHDL, but it's again not a software it's more a description of the low-level hardware and Usual problems I have with the software is not how to develop the software itself But how to make this software run on the hardware and not just on the new hardware But on the hardware which is not known to be working yet and Recent development new architectures and soft core CPUs running on the FPGA are not making my life any easier because now I'm not only I'm not only not sure that Some part of the hardware not working, but I can be sure that the CPU is also maybe not quite working right So this talk is about the initiative project to port the Lua and specifically Lua JIT implementation to the RISC-5 architecture But for me as I said, it's not interesting by itself, but you apply it to solve the problems with the early hardware bring up and With a diagnostic and debugging this hardware Unfortunately this project is the Fortunately for me it's a very early stage and it's not so many people involved in it So please don't be disappointed by the end of this talk that nothing is available and nothing is working it's more and Lightning talk why it might be interesting what approaches to be take what benefits we will get if and ever it's done Probably in this development room nobody is interested to listen once again why RISC-5 is good why we should use it or anything should be ported to it for the application of the hardware development it's And especially for the soft CPUs RISC-5 is good because it's free and because it has Modular and extensible approaches So it's possible to take the core CPU run some basic software If the CPU is so soft core CPU is good enough and is running and the software in the state to bring up this non-working hardware and non-working CPU and then you can build upon this solid foundation and to add some extensions both to your hardware infrastructure and to the CPU itself because I Sir instruction set architecture reserved some space for the custom instructions and for the custom extensions of the CPU architecture And why if it's also important There are already several hardware products from the company I'm working for at the moment which do utilize the soft core RISC CPU processors running on the FPGA songs and Later this year the SOC FPGA with RISC-5 cores and system on model hardware based on this chip are going to be available So we need some tools we need some software to debug it to demonstrate its operation to test it in production Okay, why lower 20 or 30 years ago to bring their hardware for initial prototype hardware I've been to exercise the hardware and test it I've been pretty much happy to using the fourth language. It's small compact easy portable to the New platforms and it provides you an interactive tool to probe all the registers to fiddle with your hardware to see What actually is going wrong with it or going right with it? Nowadays I think not so many people are writing any fourth Even less are using it in production environment But there seems to be a better also kind of niche Alternative to that that it's an allure language. It's very small and compact and It provides you an interactive environment where you can define your functions. You can touch all the pieces of your hardware since it's very compact posix See plain C code. It's very easy to port to the new architecture it provides an interface to See language, so if you can Access some parts of your hardware in C just map some registers and touch them then it's equally well and easy to be done from lower from your interactive shell and Yeah, compare According to the interpreter language bench benchmarks lower. I think one of the two on the top if not the fastest one, but Usually for those applications, it's not really critical In any way, you are typing on the keyboard much slower And this approach was using lower to bring up hardware and to debug it has been first tried by myself firm Something like already eight years ago to bring up The end test the high-speed serial transceivers, but then it was a nice CPU proprietary Intel back then Altera and Definitely, it's much it would be much more interesting and sensible now to do it on the risk 5 platform Just not to be connected to this particular hardware and particular FPGA vendor why lower jit lower jit is an Implementation of the lower language with the just-in-time compiler very efficient compact fast even faster than the lower itself but for me as the most attractive if the not the only most most attractive for single reason to try it was that lower jit It by itself includes a dynamic assembler and that allow Allows to experiment not only with something connected externally to the CPU block, but allows you Interactively experiment with what is inside the CPU to add some new instructions and so on of course it's and for Any real software developer it would be a probably much easier to add support for new assembler instruction in their Binutils, LLVM, GCC, but all those things are Way too heavy and even if it would be Possible or if some software developer would be sitting next to me and doing that It still would not be possible to experiment with those things Interactively on the target with the lower jit and it's built-in dynamic assembler It's possible to write piece of code with new assembly instructions You've just introduced in your soft core CPU and try them out to experiment with them Also in another second order of importance reasons That's the Lua jit compiler Lua jit is used in several Interesting projects in the software defined radio much smaller scale, but also interesting compared to the GNU radio But still an interesting one and provides somewhat more consistent and cleaner environment Let's say lower is ten times smaller than Python So lower radio is ten times smaller than GNU radio Maybe hundred times smaller, but then it's faster. It's cleaner and it gets you better chances to understand What's going on really there? Toronto database have never ever tried it really but what I read about it It's an fast in-memory Database and apply lower application server so for some high-grade loaded sites and Enterprise level of applications and also a nice compact lower power distribution which includes The dynamic assembly are not only for the C preprocessing, but for lower preprocessing So it's just a compact cross-platform lower distribution also based on utilizing lower jit and if as soon we have a Lua jit ported to the risk 5 all those and many other Platforms and applications making use of Lua jit will be available or easily available There are of course some downsides Apparently this project is Not under active development. It's a prime it used to be and mostly and single person development Mike Paul and It looks like since 2017. He's not actively contributing to this project, but still taking some patches and there were recent Development of the arm 64 and meet 64 bit ports of Lua jit Some of them were presented here on the first damn two years ago if I'm not mistaken But still the future may be uncertain as with any open source and free projects For the Specific applications of the Lua jit. It's not uncommon for the companies to make forks and just to support their forks not to contribute to the mainstream and It was good and bad according to the MIT license the Lua and Lua jit code is under so and it's somewhat lacking behind the Mainstream Lua development, which is now it's the version 5.3 Lua jit is stick to 5.1, but it's not the only lower based project stick to this version. So Maybe maybe not What is Lua jit? itself consists of as I said the most attractive part for myself is the dynamic assembler it's an Actually, it's a preprocessoral written in Lua itself which takes a mixture of C and assembled code and generate plain C code which when compiled and executed generates Binary, so it's kind of two or three step cross compiling environment and it allows an easy dynamic Relocation of those steps either to cross compile environment or to the target and the Lua power distribution Lua jit distribution Lua power I've mentioned earlier Provide the same preprocessing not only for the C code, but for the Lua code itself So you write the mixture of Lua and assembly your target assembly code preprocess it with dynamic assembler you get the C or Lua executable for C you compile it and run it for Lua You just run it on the interpreter is on target on your cross development host and you get the binary for your target architecture And with Lua it's possible to run it all this flow on the target itself Then the virtual Lua virtual machine, which is compatible the binary compatible by application binary interface and Byte code compatible with the standard Lua virtual machine But it's highly optimized and written on the hand optimized assembler and compiled with the dynamic assembler and Then there is a trace in jit compiler of course dynamic memory management and garbage collector and There are various extension models which are a foreign function interface the ABI for the calling the C functions is the same as for the standard Lua and Lua jit binary bit operations Which are now a part of Lua 5 5 point 3 But initially they were introduced by the load jit itself And of course there is a floating point support Lua itself supports only a single type of the number And it's a floating point but For most embedded MCU application MCU class applications or embedded controller applications You can skip all the floating point all together and make your life much much easier Current status is a very short and disappointing one Yes, Lua itself can be compiled and run on the both on the spike simulator and on the Target hardware. I have run it on several I think two or three different soft core CPUs on two different FPGAs family. So there is a solid base for tests and reference platform to compare with both in terms of the accuracy of implementation correctness of the implementation and in performance Jit repository for Changes make file changes to support the new architecture and built environment. So just the basic initial steps Then the git repository contains the all the instructions from the base 32-bit integer set Not much more than that. It's just 48 instructions. If I'm not mistaken Accelerate all the assembler macro assembler stuffs such as the registers and renaming and hanging immediate Arguments and labels relocation handling is walking progress. So pretty much nothing is walking and Everything else. So I would say 95% of walk is still in the long long running to-do list So if anybody is willing to join it and contribute to it, then you are more than welcome Is it to fork it yourself or to send patches? As I said the to-do list is much longer than the current status list. So what remains to be done is Pretty much everything No need to repeat that But much more interesting where we go from here when it's ready and when we have this basic core system is broken And those stuffs are really interesting. Unfortunately, we have to go through the porting and the laborer's efforts before we there risk 5 foundation reserves the J extension specification for the G exactly for the jit compiling languages The question is that what languages are currently heavily you are heavily using the jit compilation The most heavyweights player I would say are Java and JavaScript not sure maybe C sharp and Obviously because behind those Languages those environments. There are huge corporations with a lot of software hardware developers and some budget behind Definitely they will try to shape these risk 5 J extension through the foundation through their contribution I am pretty much sure that they are not aware of any efforts, but pretty much sure that there are efforts to support to jit compilation on risk 5 for all those things but So the question is who and in what direction will shape this J extension of risk 5 architecture when foundation starts to work on it and Having a really smaller light weights Luagit implementation might be an interesting test bench And it would be great to have it before the extension itself is Specified so we can see if and how it compares to it then of course because we can change not only the hardware but the CPU itself and Do it dynamically or almost dynamically? It would be interesting to experiment with the different hardware assisted techniques for the jit compilation to the detect hot traces because the Luagit compiler is Analyzing the execution threat of the virtual machine at runtime and compile the hot path in this machine and jit compile hot path and Some execution counter performance counters in the CPU may be helpful to Provide these hardware systems for the hot trace detection thing goes for the Memory management and garbage collection with the hardware systems for it Then the thing which is really interesting is there some custom and the target application specific acceleration development and in this case once again the dynamic assembler would provide a very Comprehensive and useful test and evaluation test and prototype platform because you can just specify the new Assembler instruction on the interactively on the lower level and have it immediately compiled and have the binary code compiled in it And directly on the target So if not in production environment and when this everything is committed to the silicone But for the soft core CPUs and the interactive development and debugging of those functionality That would be a really interesting and since I've already mentioned that 30 years ago fourth was Language of choice for such experiments. There is nothing that would prevent to write another fourth on the assembler On the dynamic assembler of Luagit and then once we have an interactive fourth shell It takes just in two or three screens to write a new assembler on this fourth And it looks like I'm going in the loops now so Thank you for your attention and if you have anything to contribute any questions, please feel free to contact to download to scan Thank you Yes, any questions Because of higher max, I'm working on the reptile jet another legit fork and I'm wondering if you're aware of what the other folks are doing at the moment for example In record, it's something that we're working on right now We are porting the By code interpreter It's written in the same lead to see we're almost done with that. Oh, so that would kind of like save you Yes, but for the so the question was if I am aware of what's the other logic forts are doing Not really much aware of that. So I've seen that RT RT company if I'm not mistaken the name they are supporting ports of logic to MIPS 64 bit and arm V8 64 bit architectures Toronto They are mostly targeted on optimizing the performance for their database application So the I think they are providing some functionality which improves the in-memory database handling and They've do they've done it directly in the legit of then There was some other one, but I You can talk to me either tomorrow or yeah later today I can find the link as there are and on some publications Loavela if Okay, I'm not going to elaborate about this one Yep, oh, thank you just starting with that and porting the virtual machine from the Logite virtual machine to from assembler to see yes, of course it that would save a lot of porting in Efforts that would be much easier to port it But then probably for the price of optimization and performance Maybe maybe not are specifically for the floating point as far as I know the logic is making use of None taken Not sure how and if it's supported in your port. So think here. I think yeah, I'm not only started late, but I finished late too Sorry about that and I think it's in break now. Yes. Oh So something all of us are really needed