<!DOCTYPE html> 
<html lang="en">
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Expressions</title>
    <link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>

<h2>Expressions</h2>

<p>Many fields within Kactus2 accept expresions as their input value for easy
and fast configuration. The function sign <em>f(x)</em> is used to identify
these fields. The input should conform to the SystemVerilog
syntax to be acceptable.
</p>

<h3>Constant values</h3>
<p>
Constant numeric values can be given as decimal values (e.g. 15) or by explicitly
defining the base (e.g. 'h0F for 15 in hexadecimal). The possible bases are
<strong>'b</strong> (binary), <strong>'o</strong> (octal), 
<strong>'d</strong> (decimal) and <strong>'h</strong> (hexadecimal).
Also fractional numbers (e.g. 0.25) can be used where applicable.
Other numeric formats, e.g. 0x000F and 0b0010, will not be accepted.
</p>

<p>
String values must be given within double quotes e.g. "This is a string value".
</p>

<p>
Boolean true and false are accepted and will be interpret as 1 and 0, respectively.
</p>
	
<h3>Operations</h3>
<p>Kactus2 supports the following operations:</p>    
<table border="1">
	<tr>
	  <th>Operator(s)</th>
	  <th>Description</th>
	  <th>Example</th>	  
	</tr>
	<tr>
	  <td>+,-,*,/</td>
	  <td>Basic arithmetic operations</td>
	  <td>2*4 (8)</td>
	</tr>
	<tr>
	  <td>&&,||</td>
	  <td>Basic logical operations: AND,OR</td>
	  <td>1 || 0 (true)</td>
	</tr>
	<tr>
	  <td>&,|,^,~</td>
	  <td>Bitwise logical operations: AND,OR,XOR,NOT</td>
	  <td>4'b0011 & 4'b0110 (2)</td>
	</tr>
	<tr>
	  <td>&lt;&lt;,&gt;&gt;</td>
	  <td>Shift operations</td>
	  <td>4'b0011 &lt;&lt; 1 (6)</td>
	</tr>
	<tr>
	  <td>**</td>
	  <td>Power operation</td>
	  <td>2**4 (16)</td>
	</tr>
	<tr>
	  <td>&lt;,&gt;,&lt;=,&gt;=,==,!=</td>
	  <td>Comparison of two values</td>
	  <td>4 &gt;= 2 (true)</td>
	</tr>
	<tr>
	  <td>==,!=</td>
	  <td>Comparison of string values</td>
	  <td>"abc" != "bcd" (true)</td>
	</tr>
	<tr>
	  <td>$clog2()</td>
	  <td>Ceiling of logarithm of base 2</td>
	  <td>$clog(9) (4)</td>
	</tr>
        <tr>
          <td>$exp()</td>
          <td>Exponential function</td>
          <td>$exp(2) (0.135335)</td>
        </tr>
        <tr>
          <td>$pow()</td>
          <td>Power function</td>
          <td>$pow(2, 4) (16)</td>
        </tr>
        <tr>
          <td>$sqrt()</td>
          <td>Square root</td>
          <td>$sqrt(9) (3)</td>
        </tr>
		<tr>
	<td>?:</td>
	  <td>Conditional (ternary) operator</td>
	  <td>1?2:0 (2)</td>
	</tr>
</table>

<p></p>

</body>
</html>
