Re: change with sums and shifts

Discussion in 'VHDL' started by Tricky, Oct 14, 2010.

  1. Tricky

    Tricky Guest

    On Oct 14, 8:16 am, tommy <> wrote:
    > hello guys!
    >
    > I 've a question how can i change this istructions in my structural with
    > simple sums and shifts operations?
    >
    > pOut <= CONV_STD_LOGIC_VECTOR((2* CONV_INTEGER(pIn) + 1), bitWidth/2 + 1);
    >
    > pOut <= CONV_STD_LOGIC_VECTOR((2* CONV_INTEGER(pIn)), bitWidth/2 + 1);
    >
    > thank you in advance


    for 2*

    pOut <= pIn & '0';

    for 2* + 1;

    pOut <= pIn & '1';

    I see you're using std_logic_unsigned/arith. Stop doing this NOW, and
    replace it all with numeric_std. It is a real standard.
    std_logic_unsigned is a fake standard that some weirdos made up 20
    years ago.
    Tricky, Oct 14, 2010
    #1
    1. Advertising

  2. Tricky

    Hyuma

    Joined:
    Oct 14, 2010
    Messages:
    3
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    use IEEE.STD_LOGIC_ARITH.ALL;
    use IEEE.STD_LOGIC_UNSIGNED.ALL;

    entity BombUnit is
    generic

    (
    bitWidth : integer range 1 to 128 := 16
    );

    port
    (
    input : in std_logic_vector(bitWidth-1 downto 0);
    output : out std_logic;
    nOut : out std_logic_vector(bitWidth-1 downto 0);
    pIn : in std_logic_vector( bitWidth/2 downto 0);
    pOut : out std_logic_vector( bitWidth/2 downto 0)
    );

    end BombUnit;

    architecture Behavioral of BombUnit is

    begin

    main : process (input, pIn)

    variable to_comp : std_logic_vector(bitWidth/2 downto 0);
    begin

    to_comp := SHL(pIn, "10");
    to_comp := to_comp + 1;

    if (input >= to_comp) then
    output <= '1';
    nOut <= input - to_comp;
    pOut <= CONV_STD_LOGIC_VECTOR((2* CONV_INTEGER(pIn) + 1), bitWidth/2 + 1);

    else

    output <= '0';
    nOut <= input;
    pOut <= CONV_STD_LOGIC_VECTOR((2* CONV_INTEGER(pIn)), bitWidth/2 + 1);

    end if;

    end process main;

    end Behavioral;


    sorry i don't understood, this is my code, how can I must modify it with your tips?
    thank you in advance
    Hyuma, Oct 14, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric Lilja
    Replies:
    9
    Views:
    362
    Old Wolf
    May 26, 2005
  2. jacksu
    Replies:
    7
    Views:
    1,186
    Scott Ellsworth
    Jun 23, 2006
  3. kj

    partial sums problem

    kj, Sep 28, 2010, in forum: Python
    Replies:
    12
    Views:
    788
    Dennis Lee Bieber
    Sep 30, 2010
  4. Hyuma

    replace with sums and shifs

    Hyuma, Oct 14, 2010, in forum: VHDL
    Replies:
    0
    Views:
    580
    Hyuma
    Oct 14, 2010
  5. Martin Thompson

    Re: change with sums and shifts

    Martin Thompson, Oct 14, 2010, in forum: VHDL
    Replies:
    4
    Views:
    672
Loading...

Share This Page