Vivado Custom IP with Memory Mapped I/O

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and this is another project of another vibrato tutorial project in this one I want to walk you through the process of connecting the processor logic and the FPGA fabric together so I'm going to go ahead and start this whole process as it was a brand new project and so we're going to make a new project I'm going to call it project two it's another RTL project we're going to skip through all of this stuff once again I'm going to choose the Zed board and let this empty project be created to create the structure for the processing side we actually instead of creating an IP and creating vera log files we actually want to work through this IP integrator and create a block design and it's block design is going to have high-level connections between existing IP from the IP catalog and I'm going to get this started now I'm in a blank design I get to start by adding the board zinc system and here at the very bottom the zinc seven processing system and let that add and let's make this full screen design links is quite helpful here this designer assistance when window is going to pop up periodically and it's going to allow us to do this run block automation and I'm just going to walk it through and whenever it pops up let the automation do its job so at this point we've connected to zinc to the external DDR memory that's on the bed board and I could theoretically walk through this customization wizard and turn on or turn off different aspects of the the system the processing system so for example I could turn on you are at zero which might be kind of handy in order to for instance be able to see the output packet from the P language program we are going to build later on but other than that we're kind of done with this block diagram the for also the time being the other thing that I need to be able to do now is to create a custom piece of intellectual property that's going to be our FPGA design and to do that I'm going to use tools and then create a package new IP and I'm going to walk through this wizard I want to create a new ax e for peripheral remember the ax e bus is what connects the arm to the external peripherals and so we could call it whatever we want to call it here I'm going to call it link or IP and it's going to create this in a shared repository in this case this this repository is unique to this processor to this project if you know that you're going to be using a bunch of different projects that share the same IP you could actually have repositories and in some shared location and multiple projects could use it but we're just going to start with this one does this particular project I don't need to have anything fancy I'm going to allow my barrel log design to interface to the ax e bus and that's it we're going to be a slave to the ax e bus we're not going to be a master where we can initiate transactions with other devices I don't need interrupt support the default number of registers is more than sufficient for what I need here and they add to the IP repository and at this point now I can go back to the IP catalog and if I browse through here there's my blinker IP and if I double click on it I can then add IP to the block diagram and so now my custom IP is part of our project here I'm actually not going to run this connection automation this incident I want to make some changes to this blinker IP I want to connect it to the LEDs that are on the board and the switches that are on the Zed board so I'm going to right click on the project and erect click on the block here and I want to edit an IP packager this is an option that's going to allow me to make changes to this device it's actually going to open up another Vivaro and then on top of this one okay so now and in this overlay that's the other of a bottle project and if I expand this I see that I have of a bottle IP and I have an acci I pee the way that these files are organized is the top-level IP is a pass through all of the signals for the AXI bus passed straight through this top-level module into another layer down into this is the user module so if we take a look at that in the hierarchy this is the next layer down and this module is actually handling the AXI bus transaction all the signals that arrived to this modules are from the AXI bus at this point and what is trying to do is mediate any kind of memory read or memory write the four registers that we requested in the wizard are present here at slave reg 0 1 2 or 3 and there's a whole series I'm just kind of scrolling down through this file where it's monitoring the signals coming in from AXI bus and trying to either read or write to those registers so this is the logic here this is implemented memory map register right and so if the memory bus is indicating a right to one of our four register memory addresses then we're going to capture that data from the active bus and store it into the appropriate slave reg register so 0 bytes away from the beginning of our memory address and slave reg 0 4 bytes laner is right 1 4 bytes after that is reg 2 and 4 bytes after that is reg 3 we see here all we're doing in this logic is a simple case statement looking for matching address and copying it into zero one two or three further down we have the logic to handle reads from the AXI bus and this is detecting a change on any of the registers that are in here and whenever there's been a change it will assign the value from the slave register that's been stored or as indicated in the read address part of the bus request and assign its data to the output of the AXI bus so when this module has been selected for reading then we'll drive the data into whoever has been trying to read from us and again we're going to be using the address the zero bytes away from the beginning the start address is reg 0 4 bytes laters 1 2 & 3 and so on now that's fine that's all well and good we've memory map 12 bytes of memory that's some sorry 16 bytes of memory we have 4 for 32-bit registers 4 bytes each but our goal here is to connect these to the blinky lights the LEDs that are on the board and so what I really want to be able to do is take the LEDs the the eight bits that correspond to the LEDs and maybe have them be mapped into one of the register values so that if you put a value on the LED on the register the LEDs will match and then I want to be able to read from the switches the toggle switches that are present on the board there's eight of those and so I want to be able to map the switches and be able to read the values of the switches but you can't write to the value of the switches just like it doesn't make any sense to read from the LEDs so to do this what I want to do is I'm going to use these four registers and one of the first things I'm going to do is I always like to have some kind of a sanity check I'm going to take one of the registers and use it as a Who am I and then it returned just some value and hexadecimal and if you read from this register you should always get 3 - 3 D feed and that way I can use this to make sure that my program is talking to the right device now if I'm talking from reading from say slave write one what I want to be able to do is have that maybe be the switches and so I need to be able to see the value coming in on the switches so to do that what I'm going to do is I'm going to go back to the top of the file and where it says user ports added here I'm going to have an input wire that is seven bits long and that's going to be acquitted and I'm going to have an output wire that so I 8/5 wide and that's going to be led out all right so now if I go down to the bottom of the file again this is where we were reading from slave reg one instead of reading from slave reg one I want to read 24 bits of zeros followed by switches N and so whatever 8-bit values are connected to those incoming signals when I read from this register instead of getting the value that was previously stored there I'm going to get those eight bits by the same token register zero is going to hold the bottom eight bits that are going to be used to drive the LEDs and so if you write two slavering zero that's going to change the LEDs and to make that happen I want to just add somewhere an assignment statement say led tau is equal to play reg 0 good 7 through 0 so the lowest 8 bits of slave reg 0 will you be used to drive the LED ok so at this point we've made some changes to this module if we just kind of double check it check ourselves with connected LEDs out to the bottom eight bits of Greg zero we've connected switches in to the bottom eight bits of register one we are just using register two is a empty throwaway register you can read and write to it as much as you like register for you can write to it but if you read to it you're only ever going to get the magic value and that's actually what we call these we call these magic numbers so I always want to look for that magic just to make sure that I have the right values so now I've made these signals appear in this bottom device but remember it's a child of this top level device and so I need to modify the device here this blinker IP actually this thing and now I need to add the additional signals that we put in we can put them anywhere by using this dot medication and we had switches in correspond to push it in and we have LEDs out which will correspond to LEDs out now I need to actually have those wires and so I'm going to modify this parameter to have input wire 7 : 0 pitch it in and output yr7 : 0 I leave these out and that took care of the input and the output and now that we've made those changes I can close the vera log files the one last thing I've got to do is the IP the actual IP package information itself has some information that I need to update so for example the version number right now is 1.0 that's fine we can even if you really want you can put your name here and you can put information about it we can go in and anytime is there just an update it's going to change from that green checkmark to this edit box and I'm going to say merge from the changes and here's our customers parameters merge those changes it's giving me a warning about a clock there's nothing we can do about that at this point so I'm just going to ignore that I want to make sure here switches in is listed as in and led doubt it lifted it out so now it's found the new ports that we've created we haven't changed anything here I haven't changed anything there and at this point we can generate the package and so create and package new IP actually I don't think we need to do that we just want to update the one thing we want to do before we leave here is just make sure we go through consensus if there's a syntax error in our code we don't want to find it later on that the tools don't give to a good job of reporting when there's been an error so I'm going to go ahead and let this synthesize and we will come back when that's done okay so it always took about 30 seconds since this is completed successfully node syntax errors in the file at this point I'm going to go ahead and close out of the blinker IP project remember this is a Vivaro window that was open for me to edit this IP and I'm going to go ahead and close it and now I'm back to the first of Auto window our project to with our processing system in it and at this point I'm going to get rid of the IP that I've just added and I'm going to go back to the IP catalog and I'm going to look at the blinker IP here and if I notice that it says everything has been updated I'm going to go ahead and add this back my design again and this time when I add it we actually see the new ports and so we know that we have the right version and so now I'm going to run the connection automation and take the default and sure enough let's see we can make this whole diagram be one big window we have created an ACCI bus and we've created the connections between the processor and the active bus and here we have the blinker created and it's connected to this active bus but the LEDs those external ports that are not connected and so now what I need to do is add external ports so if I right click I can do create port and we're going to call it LEDs and this is going to be output and it's going to be a vector it's going to be zero for those eight bits and now I'm going to right click and I'm going to do we're going track rate another port and this one's going to be pushing and this is going to be input and it's going to be another vector and that's going to be seven zero and now what I can do is I can just drag and drop so the switches can get connected to there and the LEDs get connected to there and I'll save this file and now I'm ready to actually generate and synthesize this design so let's make this smaller and to do that what I need to do is navigate through this design file and go to sources and this click on the block design so design 1bd right click on it and say create HDL wrapper and what this is going to do is it's going to generate the HDL wrapper it's going to look like a Verilog module but it's really going to be implemented by this complicated block design that Movado is going to maintain for us I would get a little suspicious when Xilinx claims that they're going to maintain things for us but we'll see how it does so at this point now we're ready to go ahead and run the synthesis and we'll let it build and see if there's any errors so I'll hit pause here and I'll come back when this is done ok so we've gotten through the synthesis and now we're ready to do actually looks like it's still running one thing we you will notice is this will take some more time than it has before it's got a lot more to do to route all of this stuff together so we'll give it a few more minutes okay it took about five minutes this time that I've finally finished I'm going to go ahead and do the run implementation and just as we've done before once this is done the implementation I'm not going to go on to generate I'm going to what let this finish so I can open up the design and assign the LEDs and switches to their ports on the board alright so implementation finished again that took just about four or five minutes we'll go ahead and open okay so I am in the implement the design and I'm ready to do our I hope planning and place different parts and if I use that master constraint that we've used in the previous video switch 7 is on m15 switch 6 is on 817 switch 5 is on H 15 switch 4 is on 19 switch 3 is on s 21 switch to is on H 22 switch one is on g 22 switches 0 is on f-22 and according to the datasheet those are all LV CMOS 1.8 I can repeat the process for the LEDs build a different spot in the file so LED 7 is a new 15 LED 6 w 19 LED 5 is on BB 2 LED 4 is on z22 LED 3 is on you 21 led to is on you point to LED 1 and on a plea 21 and LED 0 3:22 and again according to the datasheet all of the LEDs on the 3.3 volts so go ahead and save the constraint file and we can close out of the design I'm going to go back and verify here that they're all set looks like they're all set and so now I'm going to go and rerun the implementation which is also going to rerun the synthesis okay so I've actually skipped a step here all on and on through the implementation I've generated the bitstream and we're now ready to program the board and so at this point we're going to connect to the board download the program and unlike before remember before when we program the board with the blinking light project the white star blink we may or may not see that in this case but I see the blue light comes on that indicates the board has been programmed but I don't see any indication and anything else has happened I don't expect it to our module was set to not do anything we have to now go to the next step the whole reason we're doing this is I need to write some key code in that C code needs to [Music] interface with the part so what I need to do now is go to file and I'm going to export the hardware I want to include the bit stream and it's going to create a folder called project to SDK in my Xilinx project and now that has exported that definition I can now launch the SDK this is essentially Eclipse but it's been repackaged for violence this is the interface between C language and well this is how we're going to program in C language and get our C program loaded into the board all right so we come up here and we actually see that we have the hardware assigned look there's our blinker IP zero and this is the hardware platform I want to make a new dialing project don't be fooled into running just a regular C project you need to run a dialing application project it's going to come up with this wizard we're going to call it junker and we're going to create a new board Support Package everything here is is good to go and if we'll even have a hello world as our default and when this is all done I should have a hello world C file and in here is where we do our hello C file what I want to do is I'm going to basically get a pointer in memory to where my hardware is and if we remember back to the setting it had a hardware address of 4 3 T 0 0 0 0 0 that's the first byte of memory that will correspond to my device and so I want to get a pointer to that because I'm going to do a volatile unsigned int pointer and we're going to call that blinker and I'm going to assign it directly to a pointer this is one of the very very few times in C language where we can just 4 3 2 0 0 0 0 where I can know that some random memory address is actually the right value for a pointer like you normally would never do this but because we're right on top of the hardware I can go directly at the memory address of my banker and we can actually program it I can even verify and a flanker of three does not equal zero X let's see whatever that value was 2 2 3 3 P 1 % sure that was we have the magic number or not so I'm just going to pretend that it is and I'm going to do we have normally done a microcontroller here and we're going to read from the switches now if you remember the switches were at slave reg 0 and I want to have a fresh flavor at 1 and I'm going to make the blends of LEDs follow the switches so in this case blinker 0 is equal to 0 and 1 and so if I were to go ahead and compile and run this program I'm going to be able to launch right on to the hardware and it's going to connect to the hardware and it's going to send my C code over to the the board and you look over at your board you should actually see as you toggle the switches look at that I can make the switches follow the board I know it's really great camera work here but kind of play with the switches and get the lights to follow and that's actually happening in the C code this is not the vera log directly but it's only because the C language is reading from one memory address and writing to another memory address and my Vera log code has managed to connect those memory addresses to the actual hardware that we've managed to memory map our hardware into application space now this has been a really fast tutorial we're going to do some more later on but just get you a good idea as to how to connect the Vera log all the way through the ARM processor and into your C language program and be able to interact with them together thanks a lot hope it helped us with
Info
Channel: BOPV
Views: 16,079
Rating: 4.9471364 out of 5
Keywords: vivado, sdk, xilinx, ip generator, memory mapped I/O
Id: MbteffkRi8Y
Channel Id: undefined
Length: 26min 15sec (1575 seconds)
Published: Fri Mar 03 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.