Orar semigroup #2

Orar semigroup #2

Lucrările 4 şi 5 VHDL - Operatori. Tipuri de date (4), Atribute (5) (25 martie)

Pachet valuta

package Myp is
 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;
Registru de deplasare
entity  Registru is
    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;
Registru M3rin cu 2 clock-uri
entity Registru is
    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;
Registru stânga-dreapta în funcţie de un semnal j
entity  Registru is
    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;
Unitate aritmetico-logică
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;

luni, 31 martie 2014 by DlMuresan
Categories: , , , , , , , | Leave a comment

Leave a Reply