logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

VHDL strukturalny opis funkcji XNOR 3 zmiennych z użyciem komponentu LUT4

p_kacper 18 Lut 2009 20:45 2049 4
REKLAMA
  • #1 6170250
    p_kacper
    Poziom 11  
    Posty: 22
    Pomógł: 1
    Witam,
    jestem studentem automatyki i w tym roku mamy coś takiego ja Język VHDL. Programowałem kiedyś w C, teraz na bierząco mikroklocki- FPGA jednak za Chiny do mnie nie może przemówić (chyba mnie niejasne wykłady i ćwiczenia zupełnie zniechęciły).
    W niedzielę mam ostatnie podejście do egzaminu, wiem, że będzie ten sam lub bardzo podobny. Rozwiązałem (SAM !! ;) )już wszytskie prawie zadanka, ale na ostanie nie mam już siły.
    Proszę Was o pomoc, oto treść zadania:

    7.Opisz strukturalnie funkcję XNOR dla 3 zmiennych. Wykorzystaj LUT4 o znanym interfejsie (I0 – najmniej znaczący bit)

    component LUT4
    generic (INIT: bit_vector: = x”0000”;
    port I0: out std_ulogic;
    I0: in std_ulogic;
    I1: in std_ulogic;
    I2: in std_ulogic;
    I3: in std_ulogic;
    end component


    Liczę na Waszą pomoc i krótki opis kodu (co w ogóle oznacza generic (INIT: bit_vector: = x”0000”; ??)


    Z góry dziękuję i pozdrawiam!
  • REKLAMA
  • Pomocny post
    #2 6171465
    _greis_
    Poziom 14  
    Posty: 70
    Pomógł: 9
    Ocena: 1
    witam
    parametr INIT jest wartością opisująca stan linii wyjściowej w postaci czterech liczb heksadecymalnych. opis poniżej
    Cytat:

    // The INIT parameter for the FPGA LUT primitive is what gives the LUT its
    // logical value. By default this value is zero thus driving the output to a
    // zero regardless of the input values (acting as a ground) however in most
    // cases an new INIT value must be determined in order to specify the logic
    // function for the LUT primitive. There are a few methods in which the LUT
    // value can be determined and two of those methods will be discussed here.
    //
    // The Truth Table Method
    // ----------------------
    //
    // A common method to determine the desired INIT value for a LUT is using a
    // truth table. To do so, simply create a binary truth table of all possible
    // inputs, specify the desired logic value of the output and then create the
    // INIT string from those output values. An example is shown below:
    //
    // Example of determining an XOR INIT equation for a LUT4:
    //
    // _________________
    // | I3 I2 I1 I0 | O |
    // |-----------------|
    // | 0 0 0 0 | 0 |\
    // | 0 0 0 1 | 1 | \ = 4'b0110 = 4'h6 ---------------+
    // | 0 0 1 0 | 1 | / |
    // | 0 0 1 1 | 0 |/ |
    // |-------------|---| |
    // | 0 1 0 0 | 1 |\ |
    // | 0 1 0 1 | 0 | \ = 4'b1001 = 4'h9 |
    // | 0 1 1 0 | 0 | / |
    // | 0 1 1 1 | 1 |/ |
    // |-------------|---| INIT = 16'h6996
    // | 1 0 0 0 | 1 |\ |
    // | 1 0 0 1 | 0 | \ = 4'b0110 = 4'h9 |
    // | 1 0 1 0 | 0 | / |
    // | 1 0 1 1 | 1 |/ |
    // |-------------|---| |
    // | 1 1 0 0 | 0 |\ |
    // | 1 1 0 1 | 1 | \ = 4'b1001 = 4'h6 ------------+
    // | 1 1 1 0 | 1 | /
    // | 1 1 1 1 | 0 |/
    // -------------------


    w kodzie natomiast użyjemy tego prymitywa w ten sposób
    Cytat:

    VHDL Instantiation Template for LUT4

    -- Component Declaration for LUT4 should be placed
    -- after architecture statement but before begin keyword
    component LUT4
    -- synthesis translate_off
    generic (
    INIT : bit_vector := X"16");
    -- synthesis translate_on
    port (O : out STD_ULOGIC;
    IO : in STD_ULOGIC;
    I1 : in STD_ULOGIC;
    I2 : in STD_ULOGIC;
    I3 : in STD_ULOGIC);
    end component;
    -- Component Attribute specification for LUT4
    -- should be placed after architecture declaration but
    -- before the begin keyword
    attribute INIT : string;
    attribute INIT of LUT4_instance_name : label is "16";
    -- values can be 0 through 16
    -- Component Instantiation for LUT4 should be placed
    -- in architecture after the begin keyword
    LUT4_INSTANCE_NAME : LUT4
    -- synthesis translate_off
    generic map (
    INIT => hex_value)
    -- synthesis translate_on
    port map (O => user_O,
    I0 => user_I0,
    I1 => user_I1,
    I2 => user_I2,
    I3 => user_I3);

    pozdrawiam
  • REKLAMA
  • #3 6180530
    p_kacper
    Poziom 11  
    Posty: 22
    Pomógł: 1
    Dziękuję za pomoc- sporo mi to rozjaśniło, ale chyba jeszcze nie wszystko zrozumiałem. Napisałem kod:

    library IEEE;
    use IEEE.STD_LOGIC_1164.all;

    entity lut4_entity is
    port
    (
    in0 : in std_ulogic;
    in1 : in std_ulogic;
    in2 : in std_ulogic;
    in3 : in std_ulogic;
    output : out std_ulogic
    );
    end lut4_entity;

    architecture lut4_xnor_arch of lut4_entity is

    component LUT4
    generic(
    INIT : bit_vector(15 downto 0) := x"0000" );
    port(
    I0 : in STD_ULOGIC;
    I1 : in STD_ULOGIC;
    I2 : in STD_ULOGIC;
    I3 : in STD_ULOGIC
    O : out STD_ULOGIC
    );
    end component;

    begin

    LUT4_lab : LUT4 generic map (INIT => x"f0f0")
    port map (
    I0 => in0,
    I1 => in1,
    I2 => in2,
    I3 => in3,
    O => output
    );
    end lut4_xnor_arch;


    proszę o podpowiedź, gdzie tkwi błąd w moim rozumowaniu. Kod się kompiluje, jednak na wyjściu "output" nic sie nie pojawia (stan U) mimo wielu kombinacji na wszystkich wejściach.

    Proszę o sposób jak to powinno być dokładnie napisane.

    Pozdrawiam, Przemek.

    p.s. oczywiście wartość INIT "f0f0" jest przypadkowa i nie odnosi sie do 4wejściowego xnora ;)
  • REKLAMA
  • Pomocny post
    #4 6182047
    JarekC
    Poziom 32  
    Posty: 1508
    Pomógł: 231
    Ocena: 397
    Witam,

    Brakuje ci deklaracji odpowiednich bibliotek.
    Musisz dodać:

    
    library unisim;
    use unisim.vcomponents.all;
    


    Możesz wtedy usunąć deklarację componentu gdyż jest zawarta w bibliotece.

    Teraz już będzie działać.

    Pozdrawiam
    JarekC
  • #5 6182209
    p_kacper
    Poziom 11  
    Posty: 22
    Pomógł: 1
    No teraz to taaak! ;)

    Dziękuję za pomoc !
REKLAMA