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.

Verilog Code<br />

HDL Coding Techniques<br />

Following is the Verilog Code for a 4-to-1 1-bit MUX using tristate<br />

buffers.<br />

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

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

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

output o;<br />

assign o = s[3] ? a :1'bz;<br />

assign o = s[2] ? b :1'bz;<br />

assign o = s[1] ? c :1'bz;<br />

assign o = s[0] ? d :1'bz;<br />

endmodule<br />

No 4-to-1 MUX<br />

The following example does not generate a 4-to-1 1-bit MUX, but 3to-1<br />

MUX with 1-bit latch. The reason is that not all selector values<br />

were described in the If statement. It is supposed that for the s=11<br />

case, "O" keeps its old value, and therefore a memory element is<br />

needed.<br />

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

a 1-bit latch.<br />

IO Pins Description<br />

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

s[1:0] Selector<br />

o Data Output<br />

XST <strong>User</strong> <strong>Guide</strong> 2-81

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

Saved successfully!

Ooh no, something went wrong!