Mudanças entre as edições de "Códigos VDHL - DLP"
Ir para navegação
Ir para pesquisar
Linha 45: | Linha 45: | ||
begin | begin | ||
− | y <= "00" when x="00" else "01" when x="01" else "10" when x="10" else "--"; | + | -- y <= x when x /= "11" else "--"; |
+ | -- y <= "--" when x = "11" else x; | ||
+ | -- QUAL É O CIRCUITO QUE DEVERIA SER GERADO? | ||
+ | y <= "00" when x="00" else | ||
+ | "01" when x="01" else | ||
+ | "10" when x="10" else | ||
+ | "--"; | ||
end architecture; | end architecture; | ||
+ | |||
------------------------------------------------ | ------------------------------------------------ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
=Circuito somador e multiplicador com dado do tipo [UN]SIGNED= | =Circuito somador e multiplicador com dado do tipo [UN]SIGNED= |
Edição atual tal como às 11h20min de 26 de agosto de 2014
Circuito de buffer tri-state
------------------------------------------------
--Inserir a biblioteca necessária para uso do tipo de dados std_logic, pois é necessário o 'Z' tri-state.
library __________;
use __________;
------------------------------------------------
entity tri_state is
port
(
-- Portas (sinais) de entrada
input: in std_logic;
enable : in std_logic;
-- Portas (sinais) de saída
output : out std_logic
);
end entity ;
------------------------------------------------
architecture tri_state of tri_state is
begin
output <= input when enable='1' ELSE 'Z';
end architecture;
------------------------------------------------
Circuito com saída 'dont care'
------------------------------------------------
--Inserir a biblioteca necessária para uso do tipo de dados STD_LOGIC.
library __________;
use __________;
------------------------------------------------
entity _______ is
port
(
-- Portas (sinais) de entrada
x: in std_logic(1 downto 0);
-- Portas (sinais) de saída
y: out std_logic(1 downto 0)
);
end entity ________ ;
------------------------------------------------
architecture _______of circuito is
begin
-- y <= x when x /= "11" else "--";
-- y <= "--" when x = "11" else x;
-- QUAL É O CIRCUITO QUE DEVERIA SER GERADO?
y <= "00" when x="00" else
"01" when x="01" else
"10" when x="10" else
"--";
end architecture;
------------------------------------------------
Circuito somador e multiplicador com dado do tipo [UN]SIGNED
------------------------------------------------
--Inserir a biblioteca necessária para uso do tipo de dados [un]signed.
library __________;
use __________;
------------------------------------------------
entity mult_add_signed is
port
(
a, b: in [un]signed(3 downto 0);
x: out [un]signed(4 downto 0) -- a soma tem n_bits(max(a,b)) + 1 bits
y: out [un]signed(7 downto 0) -- O produto tem n_bits(a) + n_bits(b) bits
);
end;
------------------------------------------------
architecture _______of mult_add_signed is
begin
x <= a + b;
y <= a * b;
end architecture;
------------------------------------------------
Circuito somador e multiplicador com dado do tipo STD_LOGIC
------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_[un]signed.all;
------------------------------------------------
entity mult_add_std_logic is
port
(
a, b: in std_logic_vector(3 downto 0);
x: out std_logic_vector(4 downto 0) -- a soma tem n_bits(max(a,b)) + 1 bits
y: out std_logic_vector(7 downto 0) -- O produto tem n_bits(a) + n_bits(b) bits
);
end;
------------------------------------------------
architecture _______of mult_add_std_logic is
begin
x <= a + b;
y <= a * b;
end architecture;
------------------------------------------------
Circuito somador e multiplicador com dado do tipo SFIXED
------------------------------------------------
library __________;
use __________;
------------------------------------------------
entity mult_add_fix is
port
(
a, b : in sfixed(3 downto -3); -- 3 casas depois da virgula
x : out sfixed(4 downto -3);
y : out sfixed(7 downto -6);
);
end;
------------------------------------------------
architecture _______of mult_add_fix is
begin
x <= a + b;
y <= a * b;
end architecture;
------------------------------------------------
Circuito somador e multiplicador com dado do tipo FLOAT
------------------------------------------------
library __________;
use __________;
------------------------------------------------
entity mult_add_float is
port
(
a, b : in sfixed(3 downto -3); -- 3 casas depois da virgula
x : out sfixed(4 downto -3);
y : out sfixed(7 downto -6);
);
end;
------------------------------------------------
architecture _______of mult_add_float is
begin
x <= a + b;
y <= a * b;
end architecture;
------------------------------------------------