<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>zXc developments &#187; ASM</title>
	<atom:link href="http://www.zxcdev.com/topics/asm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zxcdev.com</link>
	<description>Enveloped by Code</description>
	<lastBuildDate>Mon, 24 May 2010 22:41:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>One-Hot State Decoder</title>
		<link>http://www.zxcdev.com/2009/06/one-hot-state-decoder/</link>
		<comments>http://www.zxcdev.com/2009/06/one-hot-state-decoder/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 15:12:48 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[ASM]]></category>
		<category><![CDATA[MIPS32]]></category>

		<guid isPermaLink="false">http://zxcdev.com/?p=15</guid>
		<description><![CDATA[Here is a quick way for you to decode a one hot state value into a binary representation. This code is built for the MIPS32 architecture. /************************************* * One-Hot Decoder * Usage: Convert the lower nibble of a 32bit * one hot active low to a binary number * representing the bit position. * Input: [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick way for you to decode a one hot state value into a binary representation. This code is built for the MIPS32 architecture.<br />
<span id="more-15"></span></p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #339933;">/*************************************</span>
<span style="color: #339933;">*</span> One<span style="color: #339933;">-</span>Hot Decoder
<span style="color: #339933;">*</span>      Usage<span style="color: #339933;">:</span> Convert the lower nibble of a 32bit
<span style="color: #339933;">*</span>            one hot active <span style="color: #000000; font-weight: bold;">low</span> to a binary number
<span style="color: #339933;">*</span>            representing the bit position<span style="color: #339933;">.</span>
<span style="color: #339933;">*</span>      Input<span style="color: #339933;">:</span> $a0 <span style="color: #000000; font-weight: bold;">for</span> the hot value <span style="color: #009900; font-weight: bold;">&#40;</span>IE<span style="color: #339933;">:</span> 0b1101<span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #339933;">*</span>     Output<span style="color: #339933;">:</span> $v0 is the decoded value <span style="color: #009900; font-weight: bold;">&#40;</span>IE<span style="color: #339933;">:</span> <span style="color: #0000ff;">0x1</span><span style="color: #009900; font-weight: bold;">&#41;</span>
<span style="color: #339933;">*************************************/</span>
<span style="color: #339933;">.</span>ent one_hot_decode
one_hot_decode<span style="color: #339933;">:</span>
        <span style="color: #339933;">//</span>Invert the incoming <span style="color: #009900; font-weight: bold;">&#40;</span> Remove <span style="color: #000000; font-weight: bold;">if</span> Active <span style="color: #000000; font-weight: bold;">High</span> <span style="color: #009900; font-weight: bold;">&#41;</span>
        xori    $a0<span style="color: #339933;">,</span> $a0<span style="color: #339933;">,</span> <span style="color: #0000ff;">0xF</span>
&nbsp;
        <span style="color: #339933;">//</span>Count the number of leading zeros
        clz             $t1<span style="color: #339933;">,</span> $a0
&nbsp;
        <span style="color: #339933;">//</span>v0 = <span style="color: #0000ff;">31</span> <span style="color: #339933;">-</span> #zeros
        li              $t0<span style="color: #339933;">,</span> <span style="color: #0000ff;">31</span>
        subu    $v0<span style="color: #339933;">,</span> $t0<span style="color: #339933;">,</span> $t1
&nbsp;
        jr              $ra
        <span style="color: #00007f; font-weight: bold;">nop</span>
<span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">end</span> one_hot_decode</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zxcdev.com/2009/06/one-hot-state-decoder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
