Question

4. Write VHDL for the below logic circuit. Simulate it for 3 test cases {abcd, s0s1} = {01 10 11 11, 01}, {11 10 00 01, 10}, {10 11 00 00, 00}

a, b, c, d are 2-bit inputs. s0, s1 are 1-bit inputs. F is 3-bit includes carry and sum.

write VHDL for the below logic circuit. Simulate it for 3 test cases {abcd, s0s1}-{01 10 11 11, 013, 111 10 00 01, 10), 110 1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Truth Table of 2 bit Adder:

INPUTs

SUM

CARRY

X1

X0

Y1

Y0

S1

S0

C

0

0

0

0

0

0

0

0

0

0

1

0

1

0

0

0

1

0

1

0

0

0

0

1

1

1

1

0

0

1

0

0

0

1

0

0

1

0

1

1

0

0

0

1

1

0

1

1

0

0

1

1

1

0

0

1

1

0

0

0

1

0

0

1

0

0

1

1

1

0

1

0

1

0

0

0

1

1

0

1

1

0

1

1

1

1

0

0

1

1

0

1

1

0

1

0

0

1

1

1

1

0

0

1

1

1

1

1

1

1

0

1

00 ol 10 이 0 T Yo 이 lo I yo 01vhdl codes

----adder

library ieee;
use ieee.std_logic_1164.all;

entity add_2bit is
   port (   x    : in std_logic_vector(1 downto 0);
       y   : in std_logic_vector(1 downto 0);
       s   : out std_logic_vector(1 downto 0);
       c   : out std_logic
   );
end add_2bit;

architecture arch of add_2bit is

begin

s(1) <= ((x(1) xor y(1)) and (not x(0) or not y(0))) or ((x(0) and y(0)) and (x(1) xnor y(1)));
s(0) <= x(0) xor y(0);
c <= (x(1) and y(1)) or (x(1) and x(0) and y(0)) or (x(0) and y(1) and y(0));

end arch;

------------------------------------------------------------------------------------------------------------------------------------------

---Mux

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity mux2_1 is
Port ( x, y : in STD_LOGIC_VECTOR (1 downto 0);
s : in STD_LOGIC;
z : out STD_LOGIC_VECTOR (1 downto 0));
end mux2_1;

architecture Behavioral of mux2_1 is

begin

z <= x when (s = '0') else y when (s = '1') else "ZZ";

end Behavioral;

--------------------------------------------------------------------------------------------------------------------

----Top File

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity logic_circuit is
Port ( a, b, c, d : in STD_LOGIC_VECTOR (1 downto 0);
s : in STD_LOGIC_VECTOR (1 downto 0);
F : out STD_LOGIC_VECTOR (2 downto 0));
end logic_circuit;

architecture Behavioral of logic_circuit is

component add_2bit is
   port (   x    : in std_logic_vector(1 downto 0);
       y   : in std_logic_vector(1 downto 0);
       s   : out std_logic_vector(1 downto 0);
       c   : out std_logic
   );
end component;

component mux2_1 is
Port ( x, y : in STD_LOGIC_VECTOR (1 downto 0);
s : in STD_LOGIC;
z : out STD_LOGIC_VECTOR (1 downto 0));
end component;

signal reg : std_logic_vector(2 downto 0);
signal r0, r1, r2 : std_logic_vector(1 downto 0);
signal r3 : std_logic;

begin

U0: mux2_1 port map (a, b, s(0), r0);
U1: mux2_1 port map (c, d, s(1), r1);
U2: add_2bit port map (r0, r1, r2, r3);

F <= (r3 & r2);

end Behavioral;

-------------------------------------------------------------------------------------------------------------

---Test Bench

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

ENTITY tb_logic_circuit IS
END tb_logic_circuit;

ARCHITECTURE behavior OF tb_logic_circuit IS

-- Component Declaration for the Unit Under Test (UUT)

COMPONENT logic_circuit
PORT(
a : IN std_logic_vector(1 downto 0);
b : IN std_logic_vector(1 downto 0);
c : IN std_logic_vector(1 downto 0);
d : IN std_logic_vector(1 downto 0);
s : IN std_logic_vector(1 downto 0);
F : OUT std_logic_vector(2 downto 0)
);
END COMPONENT;
  

--Inputs
signal a : std_logic_vector(1 downto 0) := (others => '0');
signal b : std_logic_vector(1 downto 0) := (others => '0');
signal c : std_logic_vector(1 downto 0) := (others => '0');
signal d : std_logic_vector(1 downto 0) := (others => '0');
signal s : std_logic_vector(1 downto 0) := (others => '0');

    --Outputs
signal F : std_logic_vector(2 downto 0);


BEGIN

   -- Instantiate the Unit Under Test (UUT)
uut: logic_circuit PORT MAP (
a => a,
b => b,
c => c,
d => d,
s => s,
F => F
);

-- Stimulus process
stim_proc: process
begin      
-- hold reset state for 100 ns.
wait for 100 ns;  
       a <= "01";
       b <= "10";
       c <= "11";
       d <= "11";
       s <= "01";
       wait for 20 ns;
      
       a <= "11";
       b <= "10";
       c <= "00";
       d <= "01";
       s <= "10";
       wait for 20 ns;
      
       a <= "10";
       b <= "11";
       c <= "00";
       d <= "00";
       s <= "00";
       wait for 20 ns;
  

wait;
end process;

END;
----------------------------------------------------------------------------------------------------------------------------------------

----------------Simulation

isim (P.68d)-[Default.wcfg] File EditView Simulation Window Layout Help 1.00us Instance ++ 354 ns Smulation Ob Value 100 ns 1

Add a comment
Know the answer?
Add Answer to:
4. Write VHDL for the below logic circuit. Simulate it for 3 test cases {abcd, s0s1}...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Do Simulate a 4bit Ripple Carry adder in Simulink and generate the VHDL code to be...

    Do Simulate a 4bit Ripple Carry adder in Simulink and generate the VHDL code to be implemented on DE2 board. Submit the VHDL code generated by the HDL coder and also screen shots from the DE2 board/ Quartus environment. 4 Bit Ripple Carry Adder A(3) B(3) A(2) B(2) A(1) B(1) A(0) B(0) А B A B Cout C64) А в A B C(3) C(2) C(1) C(O) Co Ci Со Ci Co Co Ci Cin S S S S Sum(3) Sum...

  • 4. Design a 4-bit Adder / Subtractor. Follow the steps given below. (a) Write the VHDL...

    4. Design a 4-bit Adder / Subtractor. Follow the steps given below. (a) Write the VHDL code for a 1-bit Full Adder. The VHDL code must include an entity and an architecture. (b) Draw the circuit diagram for a 4-bit Adder / Subtractor. The circuit diagram may include the following logic elements: 1-bit Full Adders (shown as a block with inputs and outputs) Any 2-input logic gates Multiplexers Do not draw the logic circuit for the 1-bit Full Adder.

  • 8. For this problem, you are to design a simple combinational logic circuit and then use...

    8. For this problem, you are to design a simple combinational logic circuit and then use Logisim to simulate and test the circuit. The circuit is a 2- bit priority encoder with inputs X2 and X1 and outputs Y1 and Yo. The circuit behaves as follows: oIf X2X1 00, then Y1Yo 00 (no active input) If X2X1 01, then Y1Yo = 01 (low-priority input, X1, is active) If X2X1 1-, then Y1Y0 10 (high-priority input, X2, is active) Note that...

  • number 4 and 5 please! PROBLEM STATEMENT A logic circuit is needed to add multi-bit binary...

    number 4 and 5 please! PROBLEM STATEMENT A logic circuit is needed to add multi-bit binary numbers. A 2-level circuit that would add two four-bit numbers would have 9 inputs and five outputs. Although a 2-level SOP or POS circuit theoretically would be very fast, it has numerous drawbacks that make it impractical. The design would be very complex in terms of the number of logic gates. The number of inputs for each gate would challenge target technologies. Testing would...

  • FIRST ACTIVITY: (100/100) . SIMPLE 4-BIT ARITHMETIC LOGIC UNIT (ALU): This circuit selects between arithmetic (absolute...

    FIRST ACTIVITY: (100/100) . SIMPLE 4-BIT ARITHMETIC LOGIC UNIT (ALU): This circuit selects between arithmetic (absolute value, addition) and logical (XOR, AND) operations. Only one result (hexadecimal value) can be shown on the 7-segment display This is selected by the input sel (1..0) B A-BI A+B A xnor B A nand B Input EN: If EN-1result appears on the 7 segment display. If EN=0 → all LEDs in the 7 segment display are off Arithmetic operations: The 4-bit inputs A...

  • (20 pts)VHDL. Implement the logic circuit specified in the following truth table by using a 4:1 m...

    (20 pts)VHDL. Implement the logic circuit specified in the following truth table by using a 4:1 mulitiplexer ome regular logic gates. 11 Draw a schematic of your implementation. 2) Suppose that you are given the following VHDL code of a 4:1 multiplexer. Please write a VHDL code to describe your implementation by using structure modeling technique, by using the following 4:1 multiplexer asia your answer component in your structure modeling. Note that you do not need to re-write the following...

  • Design a combinational logic circuit which has one output Z and a 4-bit input ABCD representing...

    Design a combinational logic circuit which has one output Z and a 4-bit input ABCD representing a binary number. Z should be 1 iff the input is at least 5, but is no greater than 11. Use one OR gate (three inputs) and three AND gates (with no more than three inputs each). Using K-map, find min SOP and min POS form for the outputs W, X

  • Problem 7. Consider the 74x194 4-bit bidirectional universal shift register shown below Determine the operation of...

    Problem 7. Consider the 74x194 4-bit bidirectional universal shift register shown below Determine the operation of this circuit by filling out the table. Assume that the register is cleared initially as indicated by the first row in the table, and then connected to +5V (before time t), as shown in schematic. Also assume that t 'is that time at which a positive edge occurs in the input signal 'clock'. Si and S0 inputs (given) are used to switch between modes...

  • For this problem, you are to design a simple combinational logic circuit The circuit is a...

    For this problem, you are to design a simple combinational logic circuit The circuit is a 2- bit priority encoder with inputs I2 and I1 and outputs Z1 and Z0. The circuit behaves as follows:       • If I2I1 = 00, then Z1Z0 = 00 (no active input)      • If I2I1 = 01, then Z1Z0 = 01 (low-priority input, X1, is active)       • If I2I1 = 1-, then Z1Z0 = 10 (high-priority input, X2, is active) Note that...

  • in VHDL Show synthesizable VHDL code for a register unit that performs operations shown below. The unit has a 3-bit mod...

    in VHDL Show synthesizable VHDL code for a register unit that performs operations shown below. The unit has a 3-bit mode (md) input, an asynchronous reset (rs) input, a 1-bit output control (oc) input, and an 8-bit bi-directional io bus. The internal register drives the io bus when oc is ‘I, and md is not “11 1". Use std-logic. md-000: does nothing md-001: right shift the register md-010: left shift the register md 011: up count, binary md-100: down count,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT