Pachet valuta
package Myp isRegistru de deplasare
type Valuta is range 0 to INTEGER'HIGH
units ban;
RON=100 ban;
USD=324 ban;
EUR=440 ban;
GBP=569 ban;
end units;
end Myp;
-- Folosim package Myp pentru architecture
use Myp.all;
entity E is
port(S: out Valuta);
end E;
-- architecture
architecture A of E is
signal X,Y,Z:Valuta;
begin
X<=10 RON;
Y<=10 USD;
Z<=X+Y;
end A;
entity Registru isRegistru M3rin cu 2 clock-uri
port(CLK : in bit;
SIN : in bit;
Q: out bit_vector(3 downto 0));
end Registru;
-- Arhitectura registru de deplasare
architecture Deplasare of Registru is
begin
process
variable a:bit_vector(3 downto 0):= "0000";
begin
if (CLK='1' and CLK'EVENT) then
a:=a sll 1;
a(0):= SIN;
Q<=a;
end if;
wait on CLK;
end process;
end Deplasare;
entity Registru isRegistru stânga-dreapta în funcţie de un semnal j
port(SIN:in bit;
CLKR:in bit;
CLKL:in bit;
Q: out bit_vector (3 downto 0));
end Registru;
architecture Gunners of Registru is
begin
process
variable a:bit_vector (3 downto 0):="0000";
begin
if (CLKL='1'and CLKL'EVENT) then
a:=a srl 1;
a(3):=SIN;
Q<=a;
end if;
if (CLKR='1'and CLKR'EVENT) then
a:=a sll 1;
a(0):=SIN;
Q<=a;
end if;
wait on CLKL,CLKR;
end process;
end Gunners;
entity Registru isUnitate aritmetico-logică
port(CLK : in bit;
SIN : in bit;
j : in bit;
Q: out bit_vector(3 downto 0));
end Registru;
architecture Deplasare of Registru is
begin
process
variable a:bit_vector(3 downto 0):= "0000";
begin
if (CLK='1' and (CLK'EVENT and j='1')) then
a:=a srl 1;
a(3):= SIN;
Q<=a;
end if;
if (CLK='1' and (CLK'EVENT and j='0')) then
a:=a sll 1;
a(0):= SIN;
Q<=a;
end if;
wait on CLK;
end process;
end Deplasare;
library ieee;
use ieee.std_logic_1164.all;
entity UAL is
port(A,B:in bit_vector(3 downto 0);
S:in bit_vector(2 downto 0);
REZ:out bit_vector(3 downto 0));
end UAL;
library ieee;
use ieee.std_logic_1164.all;
architecture MUX of UAL is
begin
process
begin
case S is
--when "000" => REZ<=std_logic_vector(integer(A)+integer(B));
--when "001" => REZ<=A-B;
when "010" => REZ<=A and B;
when "011" => REZ<=A or B;
when "100" => REZ<=not A;
when "101" => REZ<=A srl 1;
--REZ<=AA;
when others => null;
end case;
wait on A,B;
end process;
end MUX;
--library ieee;
--use ieee.std_logic_1164.all;
--entity MUX_8_1 is
-- port(
--S:in bit_vector(2 downto 1);
--I1:in bit_vector(3 downto 0);
--I2:in bit_vector(3 downto 0);
--I3:in bit_vector(3 downto 0);
-- I4:in bit_vector(3 downto 0);
--I5:in bit_vector(3 downto 0);
--I6:in bit_vector(3 downto 0);
--REZ:out bit_vector(3 downto 0));
--end MUX_8_1;