Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
krame505 committed Jan 10, 2025
1 parent 0c7cab2 commit a6a5a3e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
7 changes: 4 additions & 3 deletions doc/BSV_ref_guide/BSV_lang.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3972,14 +3972,15 @@ \subsection{Type synonyms}

\index{Alias}
\index{NumAlias}
\index{StrAlias}

The \te{typedef} statement must always be at the top level of a
package, not within a module. To introduce a local name within a
module, use \te{Alias} or \te{NumAlias} (see \LibRefGuide). Since
module, use \te{Alias}, \te{NumAlias} or \te{StrAlias} (see \LibRefGuide). Since
these introduce new names which are type variables as opposed to
types, the new names must begin with lower case letters.
\te{NumAlias} is used to give new names to numeric types, while
\te{Alias} is used for types which can be the types of variables.
\te{Alias} is used for types which can be the types of variables,
while \te{NumAlias} and \te{StrAlias} are used to give new names to numeric and string types.
Example:

\begin{verbatim}
Expand Down
57 changes: 55 additions & 2 deletions doc/libraries_ref_guide/LibDoc/Prelude.tex
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ \subsection{Type classes}
\hline
\te{NumAlias} & Types which give a new name to a numeric type.\\
\hline
\te{StrAlias} & Types which give a new name to a string type.\\
\hline
\te{FShow} & Types which can convert a value to a \te{Fmt}
representation for use with \te{\$display} system tasks.\\
\hline
Expand Down Expand Up @@ -1457,8 +1459,10 @@ \subsubsection{Alias and NumAlias}
\label{sec-alias}
\index{Alias}
\index{NumAlias}
\index[typeclass]{NumAlias}
\index{StrAlias}
\index[typeclass]{Alias}
\index[typeclass]{NumAlias}
\index[typeclass]{StrAlias}

\te{Alias} specifies that two types can be used interchangeably,
providing a way to introduce local names for types within a module.
Expand All @@ -1480,6 +1484,15 @@ \subsubsection{Alias and NumAlias}
endtypeclass
\end{verbatim}

\te{StrAlias} is used to give a new name to a string type.

\begin{verbatim}
typeclass StrAlias#(string type a, string type b)
dependencies (a determines b,
b determines a);
endtypeclass
\end{verbatim}

{\bf Examples}
\begin{verbatim}
Alias#(fp, FixedPoint#(i,f));
Expand Down Expand Up @@ -4154,7 +4167,7 @@ \subsubsection{Rules}


%================================================================
\subsection{Operations on Numeric Types}
\subsection{Operations on Numeric and String Types}

\subsubsection{Size Relationship/Provisos}

Expand Down Expand Up @@ -4338,6 +4351,46 @@ \subsubsection{valueOf and SizeOf pseudo-functions}
Bit#(SizeOf#(any_type)) = pack(structIn);
\end{libverbatim}

% ================================================================
\subsubsection{String type pseudo-functions}
\index{stringOf@\texttt{valueOf} (pseudo-function of types)}
\index{TStrCat@\texttt{TStrCat} (pseudo-function on types)}
\index{TNumToStr@\texttt{TNumToStr} (pseudo-function on types)}
\index[function]{Prelude!stringOf}
\index[function]{Prelude!TStrCat}
\index[function]{Prelude!TNumToStr}

Prelude also provides similar pseudo-functions for string types.
The pseudo-function \te{stringOf} is used to convert a string type into a \te{String} value.
The type-level pseudo-function \te{TStrCat} is used to concatenate two string types,
and \te{TNumToStr} is used to convert a numeric type into a string type.

\begin{center}
\begin{tabular}{|p{1 in}|p{4.6 in}|}
\hline
& \\
\te{stringOf}&Converts a string type into its String value.\\
\cline{2-2}
&\begin{libverbatim}
function String valueOf (t) ;
\end{libverbatim}
\\
\hline
\end{tabular}
\end{center}

\begin{center}
\begin{tabular}{|p {1 in}|p{1.5 in}| p{2.0 in}|}
\hline
Type Function& Type Relationship& Description\\
\hline
\hline
\te{TStrCat}&\verb'TStrCat#(s1,s2)'&Concatenate $s1$ and $s2$\\
\hline
\te{TNumToStr}&\verb'TNumToStr#(n1)'&Convert numeric type $n$ to a string type\\
\hline
\end{tabular}
\end{center}

% ================================================================
\subsection{Registers and Wires}
Expand Down

0 comments on commit a6a5a3e

Please sign in to comment.