Question

In: Electrical Engineering

Write a VHDL code for a 4-bit comparator which takes two 4-bit input values and (0.5)...

Write a VHDL code for a 4-bit comparator which takes two 4-bit input values and (0.5) determines whether the numbers are equal. 2. 2. Write a structural VHDL code to implement the circuit of Fig. 2, using the components (0.5) developed in 1.3 and 2.1. 2. 3. Write a VHDL test bench for the above and verify by simulation. (0.5) 2. 4. Implement the design in an FPGA (Note: You may need a `clock manager' to reduce (1.0) the clock frequency).

Solutions

Expert Solution

Vhdl code for the comparing two 4 bit values is

library IEEE;

use IEEE.std_logic_1164.all;

entity compare is

port ( inp1 :in std_logic_vector(3 downto 0);

inp2 :in std_logic_vector(3 downto 0);

output :out std_logic);

end compare;

architecture comp of compare is

signal s : std_logic_vector(3 downto 0);

begin

s <= not ( inp1 xor inp2);

output <= s(0) and s(1) and s(2) and s(3);

end comp;

VHDL TESTBENCH FOR THE ABOVE VHDL IS

library ieee;

use ieee.std_logic_1164.all;

use ieee.numeric_std.all;

-- entity declaration for your testbench.

--Notice that the entity port list is empty here.

entity tb_compare is

end tb_compare;

architecture behavior of tb_compare is

-- component declaration for the unit under test (uut)

component compare is

port ( inp1 :in std_logic_vector(3 downto 0);

inp2 :in std_logic_vector(3 downto 0);

output :out std_logic);

end component;

--declare inputs and initialize them to zero.

signal inp1 : std_logic_vector(3 downto 0) := "0000";

signal inp2 : std_logic_vector(3 downto 0) := "0000";

--declare outputs

signal output : std_logic;

begin

uut : compare port map (

inp1 => inp1,

inp2 => inp2,

output => output

);   

  

inp1 <= "0001" after 5 ns,

"0010" after 10 ns,

"0000" after 25 ns;

end;

The simulation wave form is

when they are equal the output would be 1 else zero


Related Solutions

Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code...
Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code of 4-bit modulo-9 counter in ModelSim, and capture the screenshot of your simulated waveform. Assume clock period Tclk=100ns, initially, the counter is reset to Q3Q2Q1Q0=0000 you need to simulate a complete counting cycle plus one more additional clock period after it is reset to “0000” state.
4. Use generate statement to write VHDL code for a 16 bit adder assuming the only...
4. Use generate statement to write VHDL code for a 16 bit adder assuming the only available building block is a full adder. Thank
Write a VHDL code for a 8x8 bit multiplier. use structural approach. write the design code...
Write a VHDL code for a 8x8 bit multiplier. use structural approach. write the design code and testbench. Use for-generate if possible
I am trying to write the code for an 8 bit adder in VHDL so that...
I am trying to write the code for an 8 bit adder in VHDL so that I can program it onto my Elbert V2 Spartan 3A FPGA Development Board, but I keep getting errors. Any ideas what I am doing wrong? library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity adder8bit is Port ( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); cin : in STD_LOGIC; o : out STD_LOGIC_VECTOR(7 downto 0); cout : out STD_LOGIC); end adder8bit; architecture Behavioral...
Write a VHDL code to implement a Finite State Machine that with an 8 bit sequence...
Write a VHDL code to implement a Finite State Machine that with an 8 bit sequence input (can be any sequence, but lets say it is 11001000), determine how many states there are as well; so if the input sequence is correct it will show the number 1 in a 7 segment display, otherwise it will be 0 in the same 7 segment display. If the input sequence is incorrect, start from the beginning.
You are to design an 4 bit counter that takes as input a clock and a...
You are to design an 4 bit counter that takes as input a clock and a reset signal and outputs a 4-bit count When the clock is asserted and the reset is high, the clock increments. When it increments at 1111,it resets to 0000 Create a schematic diagram of your design using either Xilinx ISE or a drawing tool of your choice or a neatly hand-drawn diagram Create a Verilog module within Xilinx. Verify your design is syntactically correct. Create...
design a 4 bit comparator that compares two numbers of 4 bits. the output should be...
design a 4 bit comparator that compares two numbers of 4 bits. the output should be < > or =. however you're only limited to using multiplexers or full adders. any help on how to draw this will be appreciated
Create a VHDL code of a 4 bit Counter using D flip flop and a Frequency...
Create a VHDL code of a 4 bit Counter using D flip flop and a Frequency Divider that provides the clock signal input for counter
Code in Java Write a recursive method smallestNumber which takes an ArrayList of Integers as input...
Code in Java Write a recursive method smallestNumber which takes an ArrayList of Integers as input and returns the smallest number in the array. You can use a helper method if needed. Write a main method that asks the user for a series of numbers, until the user enters a period. Main should create an ArrayList of these Integers and call smallestNumber to find the smallest number and print it. Input Format A series of integers Constraints None Output Format...
Design a logic circuit that takes 2-bit input A and 2-bit input B and subtracts the...
Design a logic circuit that takes 2-bit input A and 2-bit input B and subtracts the two numbers using full adders and inverters with full adders diagram, which input is subtracted dos not matter.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT