ch14.9.htm

来自「Verilog DHL教程」· HTM 代码 · 共 108 行

HTM
108
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML EXPERIMENTAL 970324//EN"><HTML><HEAD><META NAME="GENERATOR" CONTENT="Adobe FrameMaker 5.5/HTML Export Filter"><LINK REL="STYLESHEET" HREF="ch14.css"><TITLE> 14.9	Conversion functions for reals</TITLE></HEAD><BODY BGCOLOR="#ffffff"><DIV><HR><P><A HREF="ch14.htm">Chapter&nbsp;&nbsp;start</A>&nbsp;&nbsp;&nbsp;<A HREF="ch14.8.htm">Previous&nbsp;&nbsp;page</A>&nbsp;&nbsp;<A HREF="ch14.a.htm">Next&nbsp;&nbsp;page</A></P></DIV><H1 CLASS="Section"><A NAME="pgfId=796"> </A>14.9	Conversion <A NAME="85454"> </A>functions for <A NAME="marker=263"> </A>reals</H1><P CLASS="Body"><A NAME="pgfId=818"> </A>The following functions handle <B CLASS="Keyword">real</B> values:</P><DIV><H2 CLASS="Syntax"><A NAME="pgfId=1031"> </A></H2><PRE CLASS="CodeIndent"><A NAME="pgfId=1032"> </A><B CLASS="Keyword">integer</B>					<B CLASS="Keyword">$rtoi</B>(real_val) ;<B CLASS="Keyword">real</B>					<B CLASS="Keyword">$itor</B>(int_val) ;[63:0]					<B CLASS="Keyword">$realtobits</B>(real_val) ;<B CLASS="Keyword">real</B>					<B CLASS="Keyword">$bitstoreal</B>(bit_val) ;</PRE><P CLASS="Body"><A NAME="pgfId=1034"> </A><B CLASS="Keyword">$rtoi</B><A NAME="marker=264"> </A> converts real values to integers by truncating the real value (for example, 123.45 becomes 123)</P><P CLASS="Body"><A NAME="pgfId=1052"> </A><CODE CLASS="code"></CODE><A NAME="marker=265"> </A><B CLASS="Keyword">$itor</B> converts integers to real values (for example, 123 becomes 123.0)</P><P CLASS="Body"><A NAME="pgfId=1054"> </A><CODE CLASS="code"></CODE><A NAME="marker=266"> </A><B CLASS="Keyword">$realtobits</B> passes bit patterns across module ports; converts from a real number to the 64-bit representation (vector) of that real number</P><P CLASS="Body"><A NAME="pgfId=1055"> </A><CODE CLASS="code"></CODE><A NAME="marker=267"> </A><B CLASS="Keyword">$bitstoreal</B> is the reverse of <B CLASS="Keyword">$realtobits</B>; converts from the bit pattern to a real number. </P><P CLASS="Body"><A NAME="pgfId=1575"> </A>The real numbers accepted or generated by these functions shall conform to the IEEE 754 representation of the real number. The conversion shall round the result to the nearest valid representation.</P></DIV><DIV><H2 CLASS="Example"><A NAME="pgfId=1056"> </A></H2><P CLASS="Body"><A NAME="pgfId=1057"> </A>The following example shows how the <B CLASS="Keyword">$realtobits</B> and <B CLASS="Keyword">$bitstoreal</B><CODE CLASS="code"> </CODE>functions are used in port connections.</P><P CLASS="Body"><A NAME="pgfId=1059"> </A></P><DIV><IMG SRC="ch14-28.gif"></DIV></DIV><HR><P><A HREF="ch14.htm">Chapter&nbsp;&nbsp;start</A>&nbsp;&nbsp;&nbsp;<A HREF="ch14.8.htm">Previous&nbsp;&nbsp;page</A>&nbsp;&nbsp;<A HREF="ch14.a.htm">Next&nbsp;&nbsp;page</A></P></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?