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.

[SOLVED] Are my solutions correct?

Status
Not open for further replies.

Ohman

Newbie level 3
Newbie level 3
Joined
May 27, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
Hello, im practicing on my exam to come, and im trying an old exam, i did answer two questions but im very unsure wether they are correct or not, since it was a long time since i wrote VHDL. I would appreciate if someone could check those answers and tell me if something is wrong :).

a) using VHDL, implement a component for a full adder, using A,B and Cin as inputs, R and Cout as outputs
solution:

Code:
entity FullAdder is
 Port(A,B,Cin: in std_logic;
        R,Cout: out std_logic);
end FullAdder;

architecture Behavorial of FullAdder is

begin
Cout <= (A and B) or (A and Cin) or (B and Cin);
R <= A xor B xor Cin;
end Behavorial;

b) using VHDL, implement a 4 bit adder using the full adder
solution:

Code:
entity FourBitAdder is
  Port(X,Y: in std_logic_vector(3 downto 0);
         [B]Ci: in std_logic;[/B]
         S: out std_logic_vector(3 downto 0);
         [B]Co: out std_logic);[/B]
end FourBitAdder;

architecture Behavorial of FourBitAdder is
  signal c : std_logic_vector (2 downto 0):="000";
  component FullAdder
    Port(A,B,Cin: in std_logic;
    R, Cout: out std_logic);
  end component;

begin

bit1: FullAdder port map (A=>X(0), B=>Y(0), R=>S(0), [B]Cin=>Ci[/B], Cout=>c(0));
bit2: FullAdder port map (A=>X(1), B=>Y(1), R=>S(1), Cin=>c(0), Cout=>c(1));
bit3: FullAdder port map (A=>X(2), B=>Y(2), R=>S(2), Cin=>c(1), Cout=>c(2));
bit4: FullAdder port map (A=>X(3), B=>Y(3), R=>S(3), Cin=>c(2), [B]Cout=>Co)[/B];

end Behavorial;

//ohman
 
Last edited:

where is Carryin for first stage in entity declaration?
 
  • Like
Reactions: Ohman

    Ohman

    Points: 2
    Helpful Answer Positive Rating
declare carryin and carryout in the four bit adder entity.
 
  • Like
Reactions: Ohman

    Ohman

    Points: 2
    Helpful Answer Positive Rating
Thanks for the help!, i added carryin and carryout for the entity, but im not sure if i used them correctly in the behavorial. Changed code is in bold font!
 

Oh yes forgot to change that, does it look OK except for that?
thanks
 

yup rest look ok

just simulate it for sure
 
  • Like
Reactions: Ohman

    Ohman

    Points: 2
    Helpful Answer Positive Rating
hello,
no need for specifying dat way, jst call it with dis command... this works fine
bit1: FullAdder port map (X(0), Y(0), S(0), Ci, c(0)); i mean no need for => signs and mentionin the var name of the component...
 
  • Like
Reactions: Ohman

    Ohman

    Points: 2
    Helpful Answer Positive Rating
Ok but then i assume i would have to change the order, dependent on the order i wrote the ports, so this would be correct:

Code:
bit1: FullAdder port map(X(0),Y(0),Ci,S(0),c(0));

am i right?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top