Help code VHDL

Discussion in 'VHDL' started by Ayoub, May 13, 2014.

  1. Ayoub

    Ayoub Guest

    hi everybody !

    I want to convert 0 to -1 and 1 to 1 after that I would like to add CD with data

    and the result would be S .

    Can you help me correcting this code :

    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;

    entity Premier is
    port(
    clk:in std_logic ;
    rst:in std_logic ;
    data:in std_logic ;
    CD :in std_logic_vector(3 downto 0);
    S :eek:ut std_logic );
    end entity ;

    architecture beh of Premier is

    signal i :integer range 0 to 3;
    signal iCD :std_logic_vector(3 downto 0);
    signal idata:std_logic ;

    begin

    code:process(clk,rst)
    begin
    if(rst='1') then
    S<='0';
    i<=0;
    idata<=data ;
    iCD <=CD ;
    else
    if(clk'event and clk='1')then

    if(CD(0)='0')then
    iCD(3 downto 0)<="1111";
    else
    iCD(3 downto 0)<="0001";
    end if ;

    if(CD(1)='0') then
    iCD(3 downto 0)<="1111";
    else
    iCD(3 downto 0)<="0001";
    end if ;

    if(CD(2)='0') then
    iCD(3 downto 0)<="1111";
    else
    iCD(3 downto 0)<="0001";

    end if ;

    if(CD(3)='0') then
    iCD(3 downto 0)<="1111";
    else
    iCD(3 downto 0)<="0001";
    end if ;

    S<=not(iCD(i) xor (idata));
    i<= i+1;

    if i=3 then
    idata<= data ;
    end if ;
    end if ;
    end if ;
    end process ;

    end architecture ;

    Thank you !
    Ayoub, May 13, 2014
    #1
    1. Advertising

  2. Ayoub

    John Speth Guest

    On 5/13/2014 6:09 AM, Ayoub wrote:
    > I want to convert 0 to -1 and 1 to 1 after that I would like to add CD with data
    > and the result would be S .


    According to my interpretation of the stated requirements, this pseudo
    code should work:

    func([in] CD, [in] data, [out] S)
    if CD == 0
    S = -1
    else if CD == 1
    S = 1
    else
    S = CD + data
    func end

    No registers or clocking are needed. It is basic combinatorial logic.

    JJS
    John Speth, May 13, 2014
    #2
    1. Advertising

  3. Ayoub

    Ayoub Guest

    On Tuesday, May 13, 2014 5:28:12 PM UTC+2, John Speth wrote:
    > On 5/13/2014 6:09 AM, Ayoub wrote:
    >
    > > I want to convert 0 to -1 and 1 to 1 after that I would like to add CD with data

    >
    > > and the result would be S .

    >
    >
    >
    > According to my interpretation of the stated requirements, this pseudo
    >
    > code should work:
    >
    >
    >
    > func([in] CD, [in] data, [out] S)
    >
    > if CD == 0
    >
    > S = -1
    >
    > else if CD == 1
    >
    > S = 1
    >
    > else
    >
    > S = CD + data
    >
    > func end
    >
    >
    >
    > No registers or clocking are needed. It is basic combinatorial logic.
    >
    >
    >
    > JJS


    Thank you very much ^^
    Ayoub, May 14, 2014
    #3
    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. walala
    Replies:
    3
    Views:
    4,783
    walala
    Sep 18, 2003
  2. Replies:
    2
    Views:
    8,622
    Jim Lewis
    Mar 21, 2006
  3. dude

    VHDL 2002 vs VHDL 1993

    dude, Mar 23, 2006, in forum: VHDL
    Replies:
    1
    Views:
    1,254
    Nicolas Matringe
    Mar 23, 2006
  4. afd
    Replies:
    1
    Views:
    8,258
    Colin Paul Gloster
    Mar 23, 2007
  5. Wing Chun
    Replies:
    7
    Views:
    794
Loading...

Share This Page