We can update you automatically when our Tip of the Month
changes.
To receive regular notification of updates to our Tip of the
Month section, click here.
This month were going to look at the synthesis of arithmetic circuitry. Suppose that the following circuit is to be realised using VHDL.
You might decide to write the VHDL code like this...
architecture synth of arithmetic is use IEEE.numeric_std.all; -- this package allows std_logic_vector + natural signal a, b : std_logic_vector (7 downto 0); signal c : std_logic; begin compare_add: process (a, b, c) variable s : std_logic_vector (7 downto 0); begin if (a > b) then s := s + 1; end if; if (c = '1') then s := s + 1; end if; ... end process; end synth;
Functionally this code is correct. Unfortunately, some synthesis tools will not give you the hardware architecture you are looking for. For example, one of the golden rules of RTL synthesis is:
So the architecture created by the synthesis tool is as follows:
... and theres no way to optimize the multiplexers away, or to merge the adders into the multiplexers as random logic with good results. Hmmm...
How do we write the code to create the multiplexer-less architecture we desire? The simple solution is to write the VHDL code without using if statements, as follows:
compare_add: process (a, b, c) use work.std_boolean.all; -- ">" overloaded to return std_logic variable compare : std_logic; variable c2 : std_logic_vector (1 downto 0); variable s : std_logic_vector (7 downto 0); begin compare := a > b; c2 := ('0' & c) + ('0' & compare); s := s + c2; ... end process;
Note that this has required the use of a std_logic_vector comparison operator which is overloaded to return a std_logic type rather than the conventional boolean type. In this case, it is the ">" operator which is overloaded.
So to create the desired architecture, code up the VHDL without using IF statements. Thats a tip!
Now, at the start of this months Tip, I said some synthesis tools follow the rules of RTL synthesis to the letter to give a multiplexer-oriented structure what about those that dont? Hmmm, sounds like next months Tip to me...
Comprehensive VHDL for FPGA / ASIC
Advanced VHDL for Synthesis
Copyright 1995-1997 Doulos
This page was last updated 24th January 1997.
We welcome your e-mail comments. Please contact us at: webmaste@doulos.co.uk