<div dir="ltr"><div>Pradeep,</div>
<div>&nbsp;</div>
<div>Thanks. </div>
<div>&nbsp;</div>
<div>I am not aware&nbsp;if Python provides the feature of accessing the &nbsp;value by its bit poition:</div>
<div>Can we do&nbsp;&nbsp;&quot;if read_data[bit_pos] === poll_val:&quot; in Python? Can you please let me know little bit more about this line?</div>
<div>Whether Read_data will be declread as list() or dict()?</div>
<div>Thanks,</div>
<div>Deepak&nbsp;</div>
<div><br><br>&nbsp;</div>
<div class="gmail_quote">On Fri, Sep 19, 2008 at 5:44 PM, Pradeep Gowda <span dir="ltr">&lt;<a href="mailto:pradeep@btbytes.com">pradeep@btbytes.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">The syntax looks familiar, almost python like.<br>The equivalent python code would be*:<br><br>def poll_reg(bit_pos, poll_val, reg_offset):<br>
&nbsp; &nbsp;matched = 0<br>&nbsp; &nbsp; &nbsp; &nbsp;while matched != 1: 
<div class="Ih2E3d"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;read_data = read_reg(reg_offset)<br></div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if read_data[bit_pos] === poll_val:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;matched = 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;matched = 0<br>
&nbsp; &nbsp; &nbsp; &nbsp;return matched<br><br>* Implementing read_reg is left as an exercise to the developer :p<br><br>I&#39;m not aware of any python library methods which allow one to access registers. But, the read_reg() can be implmented in C and<br>
imported into Python.<br><br>Any low level operation like register access is usually delegated to .<br><br>HTH,<br>PG 
<div>
<div></div>
<div class="Wj3C7c"><br><br>On Sep 19, 2008, at 7:02 PM, Deepak Patel wrote:<br><br></div></div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="Wj3C7c">Hello all,<br><br>I want to a write a method in Python to poll a register for &#39;1&#39; or &#39;0&#39;. It is kind of very simple in verilog, but not sure if python provides flexibility or not.<br><br>
My algorithm (kind of Verilog syntax where I can access the bits without any extra processing) is as follows:<br><br>poll_reg ( input bit_pos, input poll_val, reg_offset)<br>{<br>// In this bit_pos is the position of bit in my register read which are being polled to become poll_val. Poll_val can be either 0 or 1.<br>
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;matched = 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while (matched != 1)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;read_data = read_reg(reg_offset);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (read_data[bit_pos] == poll_val)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;matched = 1;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matched = 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>}<br><br>Is there a way to do above in Python?<br>Thanks,<br>
Deepak<br><br><br><br><br></div></div>_______________________________________________<br>BangPypers mailing list<br><a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
</blockquote><br>Pradeep Kishore Gowda<br><a href="http://pradeepgowda.com/" target="_blank">http://pradeepgowda.com</a><br><a href="mailto:pradeep@btbytes.com" target="_blank">pradeep@btbytes.com</a><br>+1-317-564-4660 (Day Phone)<br>
<br>_______________________________________________<br>BangPypers mailing list<br><a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
</blockquote></div><br></div>