bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using SyncReg for interfacing two cloclk domains

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ...
View previous topic :: View next topic  
Author Message
gagan



Joined: 21 Aug 2014
Posts: 17

PostPosted: Thu Apr 16, 2015 11:42 pm    Post subject: Using SyncReg for interfacing two cloclk domains Reply with quote

I want to design a module , which interface two different clock domains,kind of bridge
So to start with, I wrote two modules , one just updates the synch reg and the other reads from the synch reg.
There is another module, TOP module, which instantiate the above two modules (with differennt clocks) ,

However i am getting error saying reference across clock domains.
please guide me where i am doing wrong.I have attached the files.



Cruncher.bsv
 Description:

Download
 Filename:  Cruncher.bsv
 Filesize:  381 Bytes
 Downloaded:  377 Time(s)


Reader.bsv
 Description:

Download
 Filename:  Reader.bsv
 Filesize:  308 Bytes
 Downloaded:  386 Time(s)


APB_Bridge.bsv
 Description:

Download
 Filename:  APB_Bridge.bsv
 Filesize:  787 Bytes
 Downloaded:  385 Time(s)

Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Fri Apr 17, 2015 1:08 pm    Post subject: Re: Using SyncReg for interfacing two cloclk domains Reply with quote

The problem is this rule:
Code:
rule readword;
  wordSync <= myreadReg.word_out;
  $display("The value of wordSync updated to %b",wordSync);
endrule

This rule is on the "write" side of the "wordSync" register. But in the display statement, you are reading the value of "wordSync", which is in the other clock domain. All the actions inside a rule must be in the same clock domain -- the rule will execute on the rising edge of that clock. BSC is giving you an error because one statement is in one domain and one statement is in the other.

Also, note that the actions inside a rule don't happen in sequence, they happen in parallel. So your display statement isn't doing what you think it is (even if this were an ordinary register, not crossing clock domains). The display statement doesn't happen after the write statement, so referring to "wordSync" won't read the updated value. All of the statements will happen together, so the display statement is referring to the old value of the register, not the new value (which won't be visible until after the whole rule has executed, together).

If you want to display the value being written, try this:
Code:
rule readword;
  let val = myreadReg.word_out;
  wordSync <= val;
  $display("The value of wordSync updated to %b", val);
endrule
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ... All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP