--- Quote Start ---
(Beau: )
I have been thinking in the meanwhile - you have really helped me with these discussions - now I have invested some months of work and also serious money in hiring a vhdl engineer to work on the state machine for this code, so I can not make this a habit, but would you like a (personal) copy of my interface firmware for the MorphicII or the FT2232H mini modules ? I will have to do some documentation.
--- Quote End ---
--- Quote Start ---
(Dave: )
Sure, if you don't mind me critiquing the code :)
--- Quote End ---
Oh I like that, helps me improve things :)
--- Quote Start ---
(Dave: )
Here's how I coded an FTDI asynchronous interface;
1) Created a bus functional model of the FTDI interface
2) Created an Avalon-ST interface to the FTDI device, i.e., an FTDI-to-Avalon-ST bridge.
3) Created an Avalon-ST to Avalon-MM master component
4) Wired them together as an FTDI-to-Avalon-MM master.
Using that interface, I can open a com port and write to an address via
w 0 12345678
or read and receive a response
r 0
12345678
I need to document that code too :)
I've also implemented a UART-to-Avalon-ST bridge, which can then be connected to the Avalon-ST to Avalon-MM master, to enable RS232 command access. Again, its in need of documentation :)
--- Quote End ---
Cool, sounds useful. I have not experimented much with Avalon yet, but need to ....
What I have done works somewhat similarly, but does not use Avalon. It is intended for interfacing to instruments :
https://www.alteraforum.com/forum/attachment.php?attachmentid=5812 The FTDI 2232H connects to the USB bus and interfaces to an fpga via the A-side octal register and 4 handshake lines (up to you if you use the B-side for programming, as in the MorphicII, but it does also go like the wind).
The first block "USB to Addressed Bus Interface" handles the protocol below, and transfers the info to three byte-wide busses : "Bank", "Address", "Data".
There can be multiple "Banks" of instruments.
Each "Instrument" within the fpga has a block of up to 256 byte-wide interface registers (that can of course be be used in groups to build wide-word registers - I have used up to 128bit words), plus the streaming byte-wide data-pipe fed at full USB2 rate. The interface registers are used for instrument configuration, control, status and low-rate data transfer.
So one can read or write single or multi-byte words to a particular instrument register/register group, in a similar way to your interface, just one has to also give an 8-bit "Bank" address as well as the register address - if one omits "Bank" the software defaults to the 1st bank.
I use Apl for talking to the firmware - it is interactive which means rapid development but the functions run fast as you can see in the YouTube videos. It talks directly to the .dll for the FTDI D2XX direct drivers, so one has full control over the USB data transfers and configuration. But you can use this firmware with any software that can talk to the .dlls ....
The "word" read/write commands are :
BnkAddrNb ezww Data ⍝ (Data as Nb byte range integers)
Res←HndlBnk ezrw AddressRange ⍝ (or list) (interprets Res as N byte word)
The data-pipe is read/write and normally would go to a memory, but in my second YouTube example it feeds a peripheral with a specific block of code that is able to eat the bytes at full USB2 rate :
BnkAddr morphic_vector_write DataVector
DataVector ←BnkAddr morphic_vector_read N ⍝ (reads N byte vector)
Where Addr is normally the block start address.
For those reading this that have missed the earlier reference to the link of the videos of this code running :
http://www.youtube.com/user/labtoolsinstruments