How to add a custom module, based on GPIO #147
Replies: 4 comments 15 replies
-
More likely it will provide you knowledge, fun, and excitement! I wouldn't bet on it making you (almost anyone) rich 🤣 Jokes aside, can you please provide a reference to a branch/fork with your modified sources? That will make it easier for other users/contributors to better understand what you are trying to achieve. My very first feeling is that you are making it more complicated than it should. You should not replace/duplicate the GPIO component yet. You can plug your logic outside instead. That will allow you to reuse the existing software drivers, memory map, etc. Once you succeed on that, you can evaluate other tighter integration approaches. |
Beta Was this translation helpful? Give feedback.
-
I'll take that as well. I created a fork/branch here: https://github.com/motius/neorv32/tree/add-custom-module
That is the opposite of what I was trying to do 😄 |
Beta Was this translation helpful? Give feedback.
-
Hey there! As @umarcor already said: you can add custom blocks via the external bus interface. However, if you want to add new functionality to the processor internally, then the Custom Functions Subsystem (CFS) is the right place to start. I think it would be easier to use the CFS first before you start modifying existing components or adding completely new modules. The CFS is something like a an "empty template module" that is explicitly intended to add custom functionality. All the interface stuff is already there: address assignment, C-language support, internal bus protocol handling, etc.
The CFS provides 32x 32-bit memory-mapped registers for the interface: neorv32/sw/lib/include/neorv32.h Lines 538 to 611 in e07f1f3 Some time ago, I used the CFS to implement a WS2812 interface (this is now an individual module -> If your are interested in implementing CRC: I also did that for a different project: Regarding your modifications of the GPIO controller: At first sight, your VHDL code looks good. Maybe there is a problem with the definitions of Another minor thing: I think this is not VHDL-compliant (at least not with GHDL and pre-VHDL2008), but is accepted by most toolchains: case addr is
when plam_in_addr_c => data_o <= inp_data; |
Beta Was this translation helpful? Give feedback.
-
Hey guys! First, it's been really cool playing around with the neorv32 😎! Thank you for this project! To contribute to the discussion I wrote this simple guide: How to add a custom module - Cyclic Redundancy Check (CRC32) - Nexys A7 Board I tried to be as organised and clear as possible 😅. I know there is still so much complexity to take into account. What do you think about it? Does it make sense to use it as a Tutorial (or at least starting point)? Looking forward to your comments! |
Beta Was this translation helpful? Give feedback.
-
Hi!
I have been trying to add a custom module to neorv32, based on the GPIO module. For context, I am an absolute novice at FPGA programming and don't really know VHDL. The module itself is trivial (for now, it just writes the input register to the output register - once I get it working I might try something slightly useful, like crc32), but the module itself isn't the point - the point is to figure out how to add modules (and hopefully document it for the next person). The reason I'm doing this as an absolute novice if because I like RISC-V and want to convince my colleagues that RISC-V + FPGAs + custom modules will make us rich 😄 .
To achieve this, I basically copied the GPIO module and changed the word GPIO to a different one and replaced the logic with, what I think, just a copy from the input to the output register. I did the same thing with the GPIO .h/.c files. Then I hunted down all the other places in the code where the GPIO module is mentioned and added my module in those places as well.
I got all of this somewhat working, except that the results don't make too much sense, which is why I'm here, asking questions 😄 .
Let's start with the list of files I added:
All these are copied over from the GPIO module and simplified somewhat.
And here is the list of other files I touched, to add this module to the core that I run in the simulator (I use the ghdl scripts in the sim folder to test for now):
The C code I run to test this is:
And the VHDL (again, this is a naive copy of the GPIO module):
Now to the issues that I have:
Which brings me to the questions:
out_data <= inp_data;
copy the data from my input reg to the output reg?)So far, I really enjoyed working with neorv32, I was able to program both an ice40 with the Open Source toolchain and a nexys a7 with Vivado and flash custom programs on it, without any kind of prior FPGA knowledge. I hope I can sort out my issues with this custom module and make it available somehow as a Tutorial.
Beta Was this translation helpful? Give feedback.
All reactions