cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sebastianro
Participant
Participant
3,924 Views
Registered: ‎10-22-2010

Register read/write access

Jump to solution

Hi,

In my code I have a register that is written with data read from SPI (register is 32bit and loaded after all the 32 bits have been read from SPI in a temp register). On the other side the register is read via PCIe interface. My question is: do I have to worry that the data can be metastable at the time of the read, because its just being written? Should I use something like read on posedege, write on negedge? If not why? The register, I guess, would be implemented as a set of flipflops so the new data would be loaded in parallel.... 

Thanks

0 Kudos
1 Solution

Accepted Solutions
eteam00
Professor
Professor
4,869 Views
Registered: ‎07-21-2009

No, the clock domain is the same, this should mean that I don't have anything to worry about, right?

Correct, there is no risk of metastable condition.

Because I store the serially read data from the SPI in a buffer and place it in the register only after the 32 bits have been read I'm guessing all the read bits would be new. Is my assumption incorrect?

If register read logic and register write logic are both in the same clock domain, your assumption is correct.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.

View solution in original post

3 Replies
eteam00
Professor
Professor
3,920 Views
Registered: ‎07-21-2009

If the PCIe port can be reading data from a register while the register is being written, then indeed you need a mechanism for metastable avoidance.  If you design your system so that the PCIe port will only read data when the data is stable, then you do not need to worry about metastability.

 

Can you guarantee the data being read is stable?  If not, you'll run the risk of reading garbage, even if you insert ranks of registers to avoid "metastable" states.  You won't be able to guarantee that all 32 bits being read are either "old" data or "new" data.

 

I'm assuming from your description that the SPI logic which writes the data has a different clock than the PCIe port which reads the data.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.
0 Kudos
sebastianro
Participant
Participant
3,917 Views
Registered: ‎10-22-2010

I'm assuming from your description that the SPI logic which writes the data has a different clock than the PCIe port which reads the data.

 

No, the clock domain is the same, this should mean that I don't have anything to worry about, right?

 

Can you guarantee the data being read is stable?  If not, you'll run the risk of reading garbage, even if you insert ranks of registers to avoid "metastable" states.  You won't be able to guarantee that all 32 bits being read are either "old" data or "new" data.

 

Because I store the serially read data from the SPI in a buffer and place it in the register only after the 32 bits have been read I'm guessing all the read bits would be new. Is my assumption incorrect?

0 Kudos
eteam00
Professor
Professor
4,870 Views
Registered: ‎07-21-2009

No, the clock domain is the same, this should mean that I don't have anything to worry about, right?

Correct, there is no risk of metastable condition.

Because I store the serially read data from the SPI in a buffer and place it in the register only after the 32 bits have been read I'm guessing all the read bits would be new. Is my assumption incorrect?

If register read logic and register write logic are both in the same clock domain, your assumption is correct.

 

-- Bob Elkind

SIGNATURE:
README for newbies is here: http://forums.xilinx.com/t5/New-Users-Forum/README-first-Help-for-new-users/td-p/219369

Summary:
1. Read the manual or user guide. Have you read the manual? Can you find the manual?
2. Search the forums (and search the web) for similar topics.
3. Do not post the same question on multiple forums.
4. Do not post a new topic or question on someone else's thread, start a new thread!
5. Students: Copying code is not the same as learning to design.
6 "It does not work" is not a question which can be answered. Provide useful details (with webpage, datasheet links, please).
7. You are not charged extra fees for comments in your code.
8. I am not paid for forum posts. If I write a good post, then I have been good for nothing.

View solution in original post