Pseudo code for the barcode algorithm
Explanation of variables used:
* "white_width" is the width of current white stripe, Initial value = 0.
* "black_width" is the width of current black stripe, Initial value = 0.
* "transitions" is the number of transitions (bl/wh or wh/bl) encountered
   in the code so far, Initial value = 0.
* "data" is the value to be written to memory if enable to memory is 1, at
   the address "address".

BEGIN
outer loop:
spin till (clk = 1 and start = 1);
loop one:
	spin till (clk = 1 and scan = 1);
	loop two:
		read the new video bit;
		if (new_bit = wh)
			wait till (clk = 1);
			++white_width;

			if (previous_bit = bl)
				++transitions;
				enable write to memory;
			else disable write to memory;
			end if;

			data = white_width;
			black_width = 0;
			previous_bit = wh;

		else 
			wait till (clk = 1);
			++black_width;

			if (previous_bit = wh)
				++transitions;
				enable write to memory;
			else disable write to memory;

			data = black_width;
			white_width = 0;
			previous_bit = bl;

		end if;
		mem_address = transitions;
		if (white_width = 255 or black_width = 255)
			exit loop two;
		end if;
	end of loop two;

	if (transitions = total_num and white = 255)
		exit loop one;
	end if;
end of loop one;

wait till start = 0;
end of outer loop;
END


<div align="center"><br /><script type="text/javascript"><!--
google_ad_client = "pub-7293844627074885";
//468x60, Created at 07. 11. 25
google_ad_slot = "8619794253";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />&nbsp;</div>