Hi,
I'm designing an "On Chip Network" System consisting of one network master and several network interfaces. Every interface is connected to a prozessor (picoblaze) which can transmit and receive data onto/from the network. Now I'd like to have two completely independent clocks on the network and on the prozessor bus site. In the network interface I use two fifos (rx and tx) implemented in a signle bram to exchange data between network and prozessor site. So I think an asynchronous fifo should solve the problem. But I'm not sure how to implement such a fifo exactly. I found several sites recommending gray coded read and write pointer, but I couldn't find infos how to implement a gray code to binary code converter to address the block ram and how to increase the gray coded pointers.
Also my fifo is a little bit special:
I've implemented two fifos in a single bram but I don't think that is relevant here because read and write pointers are present for each fifo. The final bram address is calculated for each site (network/prozessor) from the read or write pointer depending on which fifo is addressed (= if the site is reading or writing).
The second point is the read and write pointers points to a block base address. Each block is 18 bytes long. Each site can random access the
18 bytes in the active block by an address input: ram_address = read/writepointer * 18 + local_address (local_address < 18) Because I want to avoid the *18 multiplication I increase the read/write pointers by 18 with any block_release or block_store command. The release command is synchron to the reading site, the store command is synchron to the writing site. Both are active for on clock period.The fifo empty and full signals are generated by comparing write and read pointer: empty: write = read full: (write+1) = read I know that I waste one fifo entry in this way, but that is acceptable.
My problem is now:
- How do I implement gray code pointers and how do I convert them to a binary coded pointer that can act as base for the local_address addition?
- Is there any way to add 18 instead of 1 to a gray code pointer without losing his "hamming distance 1" characteristic to avoid a *18 multiplication?
I'v added the address logic from my fifo here, perhaps it helps.
Thanks, Michael
----------------------------------------------------------------------------------------------------------------------------------
function inc_block(arg: std_logic_vector) return std_logic_vector is begin if arg < "1111011110" then -- increase arg by 1 in a loop from 0 - 55 return arg + "0000010010"; else return "0000000000"; end if; end;
-- calculate fifo a/b, in/out addresses: addr_ram_in_a