Solved

bitwise XOR with bitmask

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

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.…
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…
Six Sigma Control Plans

632 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