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.

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

Verilog Code<br />

Following is the Verilog code for a 4-to-1 1-bit MUX using an If<br />

Statement.<br />

module mux (a, b, c, d, s, o);<br />

input a,b,c,d;<br />

input [1:0] s;<br />

output o;<br />

reg o;<br />

always @(a or b or c or d or s)<br />

begin<br />

if (s == 2'b00) o = a;<br />

else if (s == 2'b01) o = b;<br />

else if (s == 2'b10) o = c;<br />

else o = d;<br />

end<br />

endmodule<br />

4-to-1 MUX Using CASE Statement<br />

The following table shows pin definitions for a 4-to-1 1-bit MUX<br />

using a Case statement.<br />

IO Pins Description<br />

a, b, c, d Data Inputs<br />

s[1:0] MUX selector<br />

o Data Output<br />

VHDL Code<br />

Following is the VHDL code for a 4-to-1 1-bit MUX using a Case<br />

statement.<br />

library ieee;<br />

use ieee.std_logic_1164.all;<br />

2-78 <strong>Xilinx</strong> Development System

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

Saved successfully!

Ooh no, something went wrong!