Question

In: Electrical Engineering

Write VHDL code for the following: Use HEX-to-seven segment display converters to display the inputs and...

Write VHDL code for the following:

Use HEX-to-seven segment display converters to display the inputs and results for a 4-bit adder. The inputs are unsigned 4-bit binary numbers. The outcome is a 4-bit binary adder with LED display.

First you need to create a symbol for the HEX-to-seven segment display converter. Then implement a 4-bit adder using VHDL. Finally, connect three HEX-to-seven segment display converters to display input X, input Y, and sum S.

Solutions

Expert Solution


-- design file

library ieee;
use ieee.std_logic_1164.all;

entity seven_segment is
port (
   hex_in : in std_logic_vector(3 downto 0);
   hex_out : out std_logic_vector (6 downto 0)
);
end seven_segment;

architecture behave of seven_segment is
--signal temp1 : std_logic_vector(6 downto 0);
begin

   hex_out <= "1111110" when hex_in = "0000" else
              "0110000" when hex_in = "0001" else
              "1101101" when hex_in = "0010" else
              "1111001" when hex_in = "0011" else
              "0110011" when hex_in = "0100" else
              "1011011" when hex_in = "0101" else
              "1011111" when hex_in = "0110" else
              "1110000" when hex_in = "0111" else
              "1111111" when hex_in = "1000" else
              "1111011" when hex_in = "1001" else
              "1111110" ;
    
end behave;


library ieee;
use ieee.std_logic_1164.all;

entity fulladder is
port (
   A    : in std_logic;
   B    : in std_logic;
   Cin : in std_logic;
   Sum : out std_logic;
   Cout : out std_logic
);
end fulladder;

architecture behave_fa of fulladder is
begin
   Sum <= (A xor B xor Cin);
   Cout <= (A and B) or (A and Cin) or (B and Cin);
end behave_fa;


library ieee;
use ieee.std_logic_1164.all;

entity fulladder_4bit is
port (
   A    : in std_logic_vector(3 downto 0);
   B    : in std_logic_vector(3 downto 0);
   Cin : in std_logic;
   Sum : out std_logic_vector(3 downto 0);
   Cout : out std_logic
);
end fulladder_4bit;

architecture behave_fa_4bit of fulladder_4bit is
component fulladder
port (
   A    : in std_logic_vector (3 downto 0);
   B    : in std_logic_vector (3 downto 0);
   Cin : in std_logic;
   Sum : out std_logic_vector (3 downto 0);
   Cout : out std_logic
);
end component;

signal temp : std_logic_vector(3 downto 0);
begin
U0 : fulladder port map (A(0), B(0), Cin    , Sum(0), temp(0));
U1 : fulladder port map (A(1), B(1), temp(0), Sum(1), temp(1));
U2 : fulladder port map (A(2), B(2), temp(1), Sum(2), temp(2));
U3 : fulladder port map (A(3), B(3), temp(2), Sum(3), temp(3));
Cout <= temp(3);
end behave_fa_4bit;


library ieee;
use ieee.std_logic_1164.all;

entity top_level is
port (
A    : in std_logic_vector (3 downto 0);
B    : in std_logic_vector (3 downto 0);
Cin : in std_logic;
Sum : in std_logic_vector (3 downto 0);
Out1, Out2, Out3 : out std_logic_vector (6 downto 0)
);

architecture behave_top of top_level is
component fulladder_4bit is
port (
   A    : in std_logic_vector (3 downto 0);
   B    : in std_logic_vector (3 downto 0);
   Cin : in std_logic;
   Cout : out std_logic
);
end component;

component seven_segment is
port (
   hex_in : in std_logic_vector (3 downto 0);
   hex_out : out std_logic_vector (6 downto 0)
);
end component;
signal Sum : std_logic_vector (3 downto 0);
signal Cout : std_logic;
begin

DUT1 : fulladder_4bit (A => A, B => B, Cin => Cin, Sum => Sum, Cout => Cout);
DUT2 : seven_segment (hex_in => A, hex_out => Out1);
DUT3 : seven_segment (hex_in => B, hex_out => Out2);
DUT4 : seven_segment (hex_in => Sum, hex_out => Out3);

end behave_top;


Related Solutions

Write a verilog code for digital clock and display it’s seven segment using fpga?
Write a verilog code for digital clock and display it’s seven segment using fpga?
Design a digital circuit for output ‘e’ for the seven segment display for all possible inputs....
Design a digital circuit for output ‘e’ for the seven segment display for all possible inputs. Inputs: ABCD a f b g    e c d A) Derive a truth table B) Design using K-Map technique, a minimum AND-OR gate network for this system. Draw the resulting digital circuit diagram
Seven Segment display is applicable for alphanumeric display both . Suppose you are appointed as an...
Seven Segment display is applicable for alphanumeric display both . Suppose you are appointed as an engineer in company, which deals in same area (Seven Segment display unit) As per customer demand, you need to design a basic logic gate circuit diagram (Combinational circuit), which having output 1 (HIGH) when a 4-bit BCD code translated to a number that uses the upper ngt segment of a single seven segment display unit
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
In a seven-segment LED display, a square pattern can be created by enabling the a, b,...
In a seven-segment LED display, a square pattern can be created by enabling the a, b, f, and g segments or the c, d, e, and g segments. We want to design a circuit that circulates the square patterns in the four-digit seven-segment LED display. The circuit should have an input, en, which enables the circulation, and an input, cw, which specifies the direction (i.e., clockwise or counterclockwise) of the circulation. Write in verilog please.
write the code of 4 digit 7-segment display using arduino uno in assembly language by using...
write the code of 4 digit 7-segment display using arduino uno in assembly language by using software AVR STUDIO 5.1?
Write a VHDL code to use two ultrasonic sensors as detectors, placed one at entrance and...
Write a VHDL code to use two ultrasonic sensors as detectors, placed one at entrance and other at exit of a parking space. When the ultrasonic detects a car, use a counter to count the cars entering and decrement when a car exits. There is an RGB led place at each gate (entry &exit) which is used to indicate opening and closing of gates. Entry gate LED turns green when car detected and space available. LED stays red when no...
a) i) The following VHDL code contains erroneous syntax. Re write the code in its corrected...
a) i) The following VHDL code contains erroneous syntax. Re write the code in its corrected format onto your answer sheet. You may assume that din is a 16-bit vector and that the ld, lr and cl inputs are 1-bit wide. lp: process(clk) signal reg : std_logic_vector(15 downt begin if cl=’1’ then reg := (others:=’0’); else if clk=’1’ and clkevent then if ld=’1’ reg <= din; end if; if lr=’1’ then reg := reg(14 downto 0) & “0 else reg...
I need the vhdl code to display the binary number specified by an 8 input dip...
I need the vhdl code to display the binary number specified by an 8 input dip switch on a 7 segment display.
Write assembly code for the following machine code. Assume that the segment is placed starting at...
Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual memory addresses represented by such labels. 0010 1010 0000 1000 0000 0000 0000 1010 0001 0001 0000 0000 0000 0000 0000 0010 0000 0010 0001 0001 1000 0000 0010 0000 0000 1000 0000 0000 0100 1110 0010 0101 0000 0010 0001 0010 1000 0000 0010 0000
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT