- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I'm trying to read the output of an ADC and I think the expansion header is the best way to do this. (Using an Altera DE2 by the way). However while it would be easy enough in vhdl to just do it in hardware, I need to use NIOS for other work. does anyone have a verilog file for GPIO that I could add to my system and import into the SPOC Builder so it's in there and I can use NIOS to access the port?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the PIO peripheral, its in SOPC Builder under: Peripherals, Microcontrol Peripherals, PIO.
You of course understand that this will just read the ADC value on the pins at the instant you perform the read operation. If the SOPC Builder clock is not the same as the ADC clock, then this could lead to metastability. If you expect your ADC value to be static, then this might be ok. However, I'd recommend some form of synchronization, eg., in the ADC clock domain a data register, a toggle register, and a toggle synchronizer, and in the SOPC clock domain a data register, a toggle register, and a toggle synchronizer. At power-on, the ADC interface loads the ADC data into the ADC data register and toggles the toggle signal. In the SOPC builder clock domain, the toggle synchronizer synchronizes the toggle from the ADC clock domain into the SOPC builder clock domain, and generates a load pulse to load the SOPC builder register with the data contained in the ADC data register, and to generate a toggle a handshake back to the ADC domain via its toggle register. The ADC toggle synchronizer synchronizes the SOPC clock domain toggle to the ADC clock domain, generates a load pulse to load the ADC data register, and toggles the toggle signal to the SOPC clock domain. And the whole process repeats. This way, the register in the SOPC domain is always updated when the data in the ADC domain is stable, and reads of the register in the SOPC domain will always see valid (although a few clocks old) data. The register in the SOPC domain can be read using the PIO component, so there is no need to integrate the synchronization logic into an SOPC builder component. Cheers, Dave- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
maybe you can do it by defining your own peripherial

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page