05.07.2013 Views

Xilinx Synthesis Technology User Guide

Xilinx Synthesis Technology User Guide

Xilinx Synthesis Technology User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

XST <strong>User</strong> <strong>Guide</strong><br />

Constants, Macros, Include Files and Comments<br />

This section discusses constants, macros, include files, and<br />

comments.<br />

Constants<br />

By default, constants in Verilog are assumed to be decimal integers.<br />

They can be specified explicitly in binary, octal, decimal, or<br />

hexadecimal by prefacing them with the appropriate syntax. For<br />

example, 4’b1010, 4’o12, 4’d10 and 4’ha all represent the same value.<br />

Macros<br />

Verilog provides a way to define macros as shown in the following<br />

example.<br />

`define TESTEQ1 4’b1101<br />

Later in the design code a reference to the defined macro is made as<br />

follows.<br />

if (request == `TESTEQ1)<br />

This is shown in the following example.<br />

`define myzero 0<br />

assign mysig = `myzero;<br />

Verilog provides the `ifdef and `endif constructs to determine<br />

whether a macro is defined or not. These constructs are used to define<br />

conditional compilation. If the macro called out by the `ifdef<br />

command has been defined, that code will be compiled. If not, the<br />

code following the `else command is compiled. The `else is not<br />

required, but the `endif must complete the conditional statement. The<br />

`ifdef and `endif constructs are shown in the following example.<br />

`ifdef MYVAR<br />

module if_MYVAR_is_declared;<br />

...<br />

endmodule<br />

`else<br />

module if_MYVAR_is_not_declared;<br />

...<br />

endmodule<br />

`endif<br />

7-26 <strong>Xilinx</strong> Development System

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!