Professional Documents
Culture Documents
B
L3
0
1
0
1
S
M5
1
0
1
0
1. Passo 1 Sintetizar
2. Passo 2 Implementar
Comportamental Behavioral
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity funcao00 is
port (A : in
std_logic;
B : in
std_logic;
S : out std_logic);
end funcao00;
--architecture data_flow of funcao00 is
-- begin
-- S <= (not(A) and not(B)) or (A and not(B));
--end architecture;
architecture behavioral of funcao00 is
begin
func : process(a,b)
begin
if (a='0' and b='0') then
S <= '1';
elsif (a='0' and b='1') then
S <= '0';
elsif (a='1' and b='0') then
S <= '1';
else
S <= '0';
end if;
end process func;
end architecture behavioral;
Diagrama em Blocos
Simulao
Exemplos de Cdigo
http://www.quicknet.se/hdc/hdl/educaton/mux4_1/
--
=============================================================================
-- file name is: mux4_1.vhd
(mux=multiplexer)
-- Author:
Kim Petersen
-- Created:
00.04.10
last modified: 00.04.13
-- =============================================================================
-- It is a 4 input multiplexer with the function as:
-sel
Input => output
comments
-MSB LSB
-0
0
in0 => output
-0
1
in1 => output
-1
0
in2 => output
-1
1
in3 => output
---------IF
and CASE can only be used inside a process.
-WHEN and WITH can only be used outside a process.
--IF
corresponds to WHEN
-CASE correpsonds to WITH
-- =============================================================================
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY mux4_1 IS
PORT (s0
s1
in0
in1
in2
in3
output
);
END mux4_1;
:
:
:
:
:
:
:
IN
IN
IN
IN
IN
IN
OUT
-- =============================================================================
ARCHITECTURE if_example OF mux4_1 IS
BEGIN
mux:PROCESS(s0, s1, in0, in1, in2, in3)
BEGIN
IF
=>
=>
=>
=>
=>
output
output
output
output
output
<=
<=
<=
<=
<=
in0;
in1;
in2;
in3;
'X';
sel
BEGIN
sel <= s1 & s0; -- concatenate s1 and s0
WITH sel SELECT
output <= in0 WHEN "00",
in1 WHEN "01",
in2 WHEN "10",
in3 WHEN "11",
'X' WHEN OTHERS;
END with_example;
-- =============================================================================
ARCHITECTURE when_example OF mux4_1 IS
BEGIN
output <= in0 WHEN
in1 WHEN
in2 WHEN
in3 WHEN
'X';
END when_example;
(s1
(s1
(s1
(s1
&
&
&
&
s0)="00"
s0)="01"
s0)="10"
s0)="11"
ELSE
ELSE
ELSE
ELSE