Beruflich Dokumente
Kultur Dokumente
using VHDL
Kalpana G. Bhat
Design entry with HDLs
Similar to computer program
Describes underlying hardware
Advantages:
Widely supported
Enables portability
Text based
Modular implementation possible
Concurrency, timing, clocking can all be
modeled
Entity declaration
defines the interface
Architecture body
defines functionality, allows different
implementations
Entity entity-name is
Port (signal-names :mode signal-type;
signal-names :mode signal-type;
…………….
signal-names :mode signal-type);
End entity-name;
¾ Mode- signal direction
¾ Identifier, reserve words- not case sensetive
¾ Signal_type- built in or user defined
¾ Signal name-
entity FullAdder is
port (a, b, cin : in bit;
sum, cout : out bit);
end FullAdder;
architecture FullAdder_eqns of FullAdder is
begin
sum <= a xor b xor cin; -- signal assignment
cout <= (a and b) or (a and cin) or (b and cin);
end FullAdder_eqns;
Dept. of E&C, NITK, DSD using FPGAs 10
Surathkal
Concurrent Signal Assignment
Statement
Syntax:
signal_name <= {expression};
Usage:
int1 <= A and not B; int1 <= A and not B;
int2 <= not A and B; z <= int1 or int2;
z <= int1 or int2; int2 <= not A and B;
pulse
30ns 50ns
10ns
.
(Using when…else construct) . Outbit
.
.
Signals
• used to interconnect components and
processes
• new value is assigned to signal when process
suspends
• driver present
[loop_label1:]iteration-scheme loop
sequential-statements
end loop [loop label];
4 to 1
Inbus(3:0)
2 to 1
Inbus(4:7)
x(0) Sel(2)
4 to 1
entity mux4 is
port(inbus:in std_logic_vector(3 downto 0);
sel:in std_logic_vector(1 downto 0);
outbit:out std_logic);
end mux4;
architecture Behavioral of mux4 is
begin
outbit<=inbus(0) when sel="00" else
inbus(1) when sel="01" else
inbus(2) when sel="10" else
inbus(3) when sel="11" else
‘-';
end Behavioral;
entity mux2 is
port(a:in std_logic_vector(1 downto 0);
sel:in std_logic;
y:out std_logic);
end mux2;
architecture Behavioral of mux2 is
begin
with sel select
y<=a(0) when '0',
a(1) when '1',
‘-' when others;
end Behavioral;
Dept. of E&C, NITK, DSD using FPGAs 57
Surathkal
(Code for 8:1 multiplexer using 4 to 1 and 2 to 1
multiplexers as component.)
entity mux8 is
port(inbus:in std_logic_vector(7 downto 0);
sel:in std_logic_vector(2 downto 0);
outbit:out std_logic);
end mux8;
architecture Behavioral of mux8 is
component mux4 is …….
end component;
component mux2 is……
end component;
signal x:std_logic_vector(1 downto 0);
begin
4 to 1
g1:for i in 0 to 1 generate
m1:mux4 port map
Inbus(3:0)
(inbus((4*i+3) downto
2 to 1
(4*i)),sel(1 downto 0),x(i));
end generate;
m2:mux2to1 port map Sel(1:0) x(1) Outbit
(x(1 downto 0),sel(2),outbit);
end Behavioral;
Inbus(4:7)
x(0) Sel(2)
4 to 1