15.01.2013 Views

U. Glaeser

U. Glaeser

U. Glaeser

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.

FIGURE 12.7<br />

until the next clock. In the second block of code in each model, a VHDL WITH SELECT concurrent<br />

statement and a Verilog ALWAYS block assigns the output signal based on the current state (i.e., a Moore<br />

state machine). This generates gates or combinational logic only with no flip-flops since there is no sensitivity<br />

to the clock edge.<br />

In the second example seen in Fig. 12.7, the hardware to be synthesized consists of a 16-bit registered<br />

ALU. The ALU supports four operations, add, subtract, bitwise AND, and bitwise OR. The operation is<br />

selected with the high two bits of ALU_control. After the ALU operation, an optional shift left operation<br />

is performed. The shift operation is controlled by the low-bit of ALU_control. The output from the shift<br />

operation is then loaded in a 16-bit register on the positive edge of the clock.<br />

At the start of each of the VHDL and Verilog ALU models, the input and output signals are declared<br />

specifying the number of bits in each signal. The top-level I/O signals would normally be assigned to<br />

I/O pins on the FPGA. An internal signal, ALU_output, is declared and used for the output of the ALU.<br />

Next, the CASE statements in both models synthesize a 4-to-1 multiplexer that selects one of the four<br />

ALU functions. The + , −,<br />

AND (&), and OR (|) operators in each model automatically synthesize a<br />

16-bit adder/subtractor with fast carry logic, a bitwise AND, and a bitwise OR circuit. In most synthesis<br />

© 2002 by CRC Press LLC<br />

VHDL Model of ALU Verilog Model of ALU<br />

entity ALU is<br />

port(ALU_control : in std_logic_vector(2 downto 0);<br />

Ainput, Binput: in std_logic_vector(15 downto 0);<br />

Clock : in std_logic;<br />

Shift_output: out std_logic_vector(15 downto 0));<br />

end ALU;<br />

architecture RTL of ALU is<br />

signal ALU_output: std_logic_vector(15 downto 0);<br />

begin<br />

process (ALU_Control, Ainput, Binput)<br />

begin<br />

case ALU_Control(2 downto 1) is<br />

when "00" => ALU_output ALU_output ALU_output ALU_output ALU_output

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

Saved successfully!

Ooh no, something went wrong!