Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to write VHDL code for 2 inputs A and B and 1 output Q(14:0)?

Status
Not open for further replies.

voho

Full Member level 2
Joined
Feb 24, 2004
Messages
121
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Nador City
Activity points
852
Hi all,

I have 2 inputs A and B and 1 output Q(14:0);
I want to do this in vhdl:

If a=5 and B=10 then Q=000001111111111

Thank's in advance

regards
voho
 

Re: how to do in vhdl

Here is how to do it!!

Code:
library ieee;
use ieee.std_logic_1164.all;

entity my_logic is
  
  port (
    A : in  std_logic_vector(14 downto 0);
    B : in  std_logic_vector(14 downto 0);
    Q : out std_logic_vector(14 downto 0));

end my_logic;

architecture behave of my_logic is

begin  -- behave
process (A,B)
begin  -- process
if (a="000000000000101" and B = "000000000001010") then
  Q <= "000001111111111";
else
  Q <= "000000000000000";
end if;
end process;


end behave;
 

Re: how to do in vhdl

OR SO

library ieee;
use ieee.std_logic_1164.all;

entity my_logic is

port (
A : in std_logic_vector(14 downto 0);
B : in std_logic_vector(14 downto 0);
Q : out std_logic_vector(14 downto 0));

end my_logic;

architecture behave of my_logic is
begin

Q <= "000001111111111" WHEN (a="000000000000101" and B = "000000000001010") ELSE "000000000000000";

end behave;
 

Re: how to do in vhdl

In my opinion, your code needs to be corrected this way:

...
A : in std_logic_vector(2 downto 0);
B : in std_logic_vector(3 downto 0);

...
Q <= "000001111111111" WHEN (a="101" and B = "1010") ELSE
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top