Jump to content

Register Model value change


lopeztel

Recommended Posts

I have recently modeled registers as simple unions to represent bitfields, for example:

typedef union
{
	struct
	{
		uint32_t ADDRESS:5;
		uint32_t RESERVED:26;
		uint32_t ENABLE:1;
	} b;
	uint32_t w;
} register_type;

which facilitates the access to either the complete word or a bitfield. 

The interesting part comes when I try to check if the register value has changed, is there a more elegant way of doing this than polling in if or while statements for each register's value? I need to do this for a lot of them so I was wondering if modeling this using sc_bv provides a built-in event I could use in a SC_METHOD sensitivity list?

example:

typedef union
{
	struct
	{
		sc_bv<5> ADDRESS;
		sc_bv<26> RESERVED;
		sc_bv<1> ENABLE;
	} b;
	uint32_t w;
} register_type;

and then do something like:

register_type Reg;
...
SC_METHOD(some_method);
sensitive << Reg.b.ENABLE;
...
some_method(){
...
}

Any pointers or ideas are greatly appreciated

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...