Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Even or Odd parity check subroutine using PERL

Status
Not open for further replies.

dioblo0507

Newbie level 3
Joined
Oct 25, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,302
Even parity check subroutine using PERL

Hello, I'm writing a PERL program to implement the I/O module of our computer. One of the features of my I/O module is error detection for the data coming from or out to external devices. I'd to know how to program the even parity check of 10 bits word calculation then determine whether the data is in error or error-free. I need this very urgent...Please help. Thanks.
 

Problem solved. Thread closed...

---------- Post added at 06:11 ---------- Previous post was at 06:11 ----------

Below is my code...


#!/usr/bin/perl
#use strict;
use warnings;

@binary = (0,0,1,0,0,1,1,1,1,0);

for ($i = 0; $i < 10; $i++){
$bit = shift(@binary);
if ($bit == 1){
++$count;
}
}

$count %=2;
if ($count == 1){
print "Error bit detected!\n";
}

the @binary is juz a test data, the real data will be taken from external devices subroutines... Thanks for advices ^^
 

Code:
#!/usr/bin/perl

@bin=(0,1,0,0,0,0,0,1,0,1);

$par=0;
foreach $tmp (@bin){
  $par=$par^$tmp;
}

if($par){
  print "error";
}
 
wow~ ur program is much more advance than my simple and stupid program >.<
Thanks for sharing ur knowledge and most probably i will use ur program in my project...is it ok?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top