Solved

bitwise XOR with bitmask

Posted on 2004-10-14
2
1,073 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

739 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