VHDL Quick Guide
VHDL Quick Guide
189
Appendix E
Signal Values
Numbers and Bit Strings Generic statement generic map Signals and Variables Types
35 (default decimal) 16#C# = 1100 X3C = B00111100 O234 = B010011100 generic ( N:integer := 8);
Program structure
library IEEE; use IEEE.STD_LOGIC_1164.all; entity Dff port( clk clr D : q : end Dff; is : in STD_LOGIC; : in STD_LOGIC; in STD_LOGIC; out STD_LOGIC );
Logic operators
architecture Dff of Dff is begin process(clk, clr) begin if(clr = '1') then q <= '0'; elsif(rising_edge(clk))then q <= D; end if; end process; end Dff; z <= not y; c <= a and b; z <= x or y; w <= u nand v; r <= s nor t; z <= x xor y; d <= a xnor b;
190
Appendix E
Arithmetic operators
VHDL Quick Reference Guide (cont.) count <= count + 1; + (addition) q <= q 1; - (subtraction) * (multiplication) / (division) (not synthesizable rem (remainder) if a <= b then =, /=, >, <, >=, <= if clr = 1 then c = shl(a,3); shl (arg,count) c = shr(a,4); shr (arg,count) process (a) [<id>] process(<sensitivity list>) variable j: integer; {{process declaration}} begin begin j := conv_integer(a); for i in 0 to 7 loop {{sequential statement}} if(i = j) then end process [<id>]
y(i) <= '1'; else y(i) <= '0'; end if; end loop; end process;
if statement
case statement
for loop
if(expression1) then {{statement;}} {{elsif (expression2) then {{statement;}} }} [[else {{statement;}} ]] end if; case expression is (( when choices => {sequential statement;}} )) {{ }} when others => {sequential statement;}} end case; for identifier in range loop {{sequential statement} end loop; := (variable) <= (signal) instance_name component_name map (port_association_list);
if(clr = '1') then q <= '0'; elsif(clk'event and clk = '1') then q <= D; end if;
case s is when "00" when "01" when "10" when "11" when others end case;
z z z z z