Solved

bitwise XOR with bitmask

Posted on 2004-10-14
2
1,062 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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 …
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

15 Experts available now in Live!

Get 1:1 Help Now