Solved

bitwise XOR with bitmask

Posted on 2004-10-14
2
1,064 Views
Last Modified: 2012-08-14
hi .

I have 3 strings : $reg_reply , $reg_expected , $reg_mask :

register read reply       = "abcd0123" , the reply from the device
expected replied data = "abcd0023" , the expected data to be replied from the device .
reg_mask   = "ffff00ff" , the bits that should match .(the other bits are ignored in the comparison)

in verilog/vhdl I could do this ,in this way : (reply BITWISE_XOR expected) AND (mask) == 0
if TRUE : good reply
if FALSE : bad reply .

this perl code I used :

if (($reg_reply ^ $reg_data) && ($reg_mask) == 0) {
    print "REG_REPLY correct ,reply= 0x$reg_reply ,expected= 0x$reg_data ,mask= 0x$reg_mask\n";
} else {
    print "REG_REPLY ERROR wrong value,reply= 0x$reg_reply ,expected= 0x$reg_data ,mask= 0x$reg_mask\n";
}

example :

Argument "ffff000c" isn't numeric in eq at ctrl_sim.pm line 126.
REG_REPLY correct ,reply= 0xabcd0008 ,expected= 0xabcb0008 ,mask= 0xffff000c
 this should be ERROR (abcd != abcb)

and in addition , I need to remove the WARNING (Argument "ffff000c" isn't numer ...)

thanks ,

tal
0
Comment
Question by:Talmash
2 Comments
 
LVL 12

Accepted Solution

by:
stefan73 earned 50 total points
ID: 12307075
Hi Talmash,
> if (($reg_reply ^ $reg_data) && ($reg_mask) == 0) {
Are you sure you want to use logical and? Try this instead:

if ((($reg_reply ^ $reg_data) & ($reg_mask)) == 0) {

Convert your hex strings to a numeric value with the hex() function first.
Cheers!

Stefan
0
 
LVL 6

Author Comment

by:Talmash
ID: 12308204
excellent and on time .

thanks , stefan .

tal
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now