05.07.2013 Views

Xilinx Synthesis Technology User Guide

Xilinx Synthesis Technology User Guide

Xilinx Synthesis Technology User Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

HDL Coding Techniques<br />

Verilog<br />

Following is the Verilog code for an unsigned 8-bit adder with carry<br />

in.<br />

module adder(A, B, CI, SUM);<br />

input [7:0] A;<br />

input [7:0] B;<br />

input CI;<br />

output [7:0] SUM;<br />

assign SUM = A + B + CI;<br />

endmodule<br />

Unsigned 8-bit Adder with Carry Out<br />

This section contains VHDL and Verilog descriptions of an unsigned<br />

8-bit adder with carry out.<br />

If you use VHDL, then before writing a "+" operation with carry out,<br />

please examine the arithmetic package you are going to use. For<br />

example, "std_logic_unsigned" does not allow you to write "+" in the<br />

following form to obtain Carry Out:<br />

Res(9-bit) = A(8-bit) + B(8-bit)<br />

The reason is that the size of the result for "+" in this package is equal<br />

to the size of the longest argument, that is, 8 bit.<br />

• One solution, for the example, is to adjust the size of operands A<br />

and B to 9-bit using concatenation.<br />

Res

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

Saved successfully!

Ooh no, something went wrong!