Question

In: Electrical Engineering

Using the following VHDL code for an 8 bit adder, make the sum be displayed on...

Using the following VHDL code for an 8 bit adder, make the sum be displayed on the seven segment display of an Elbert V2 Spartan 3A FPGA Board.

VHDL:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity state_bit_adder is

Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
           D : in STD_LOGIC;
           Enable : out STD_LOGIC_vector (2 downto 0);
           input: in std_logic_vector(7 downto 0);
           SUM: out std_logic_vector(8 downto 0));
          
end state_bit_adder;

architecture Behavioral of state_bit_adder is
type statetype is (start, secondstate);
signal state, nextstate: statetype;

signal tempsum1, tempsum: STD_LOGIC_VECTOR (8 downto 0);

begin
Enable <= "110";
process(clk, reset)
begin
if(reset ='0') then
state <= start;
elsif rising_edge(clk) then
state <= nextstate;
end if;
end process;

process(state, input, D)
begin
case (state) is
when start =>
tempsum1 <= ('0'&input);
if (D = '0') then
nextstate <= secondstate;
end if;

when secondstate =>
tempsum <= ('0'&input);
if (D = '0') then
nextstate <= start;
end if;
end case;
end process;

SUM <= tempsum1 + tempsum;

End Behavioral;

Constraint File:

###Clock
NET "clk" LOC = P129 | IOSTANDARD = LVTTL | PERIOD = 12 MHz;
NET "D" CLOCK_DEDICATED_ROUTE = FALSE;
############Input push buttons
NET "reset" LOC = P80 | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = FAST | PULLUP;
NET "D" LOC = P79 | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = FAST | PULLUP;


###########output LED
NET "SUM[7]" LOC = P46 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET "SUM[6]" LOC = P47 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET "SUM[5]" LOC = P48 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET "SUM[4]" LOC = P49 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET "SUM[3]" LOC = P50 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET "SUM[2]" LOC = P51 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET "SUM[1]" LOC = P54 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET "SUM[0]" LOC = P55 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
     
   NET "SUM[8]" LOC = P117 | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 12;
     
   NET "Enable[0]" LOC = P120 | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 12;
   NET "Enable[1]" LOC = P121 | IOSTANDARD = LVTTL | DRIVE = 8;
   NET "Enable[2]" LOC = P124 | IOSTANDARD = LVTTL | DRIVE = 8;

     
     
#####################################################################################################
## DP Switches
#####################################################################################################

NET "input[0]" LOC = P70 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[1]" LOC = P69 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[2]" LOC = P68 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[3]" LOC = P64 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[4]" LOC = P63 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[5]" LOC = P60 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[6]" LOC = P59 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[7]" LOC = P58 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;

Solutions

Expert Solution

The VHDL code will changed as given below to include the seven segment display. Here, the output SUM is displaye in the seven segment display as hexadecimal.

VHDL Code:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity state_bit_adder is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
           D : in STD_LOGIC;

input: in std_logic_vector(7 downto 0);
           Enable : out STD_LOGIC_vector (2 downto 0);
           Seven_Segment_Display : out STD_LOGIC_VECTOR (7 downto 0));
end state_bit_adder;

architecture Behavioral of state_bit_adder is
type statetype is (start, secondstate);
signal state, nextstate: statetype;

signal tempsum1, tempsum,SUM: STD_LOGIC_VECTOR (8 downto 0);

signal bcd0,bcd1,bcd2: STD_LOGIC_VECTOR (3 downto 0);

variable Seven_Segment_Display_output : std_logic_vector (7 downto 0) := (others => '1');

begin
Enable <= "110";
process(clk, reset)
begin
if(reset ='0') then
state <= start;
elsif rising_edge(clk) then
state <= nextstate;
end if;
end process;

process(state, input, D)

begin
case (state) is
when start =>
tempsum1 <= ('0'&input);
if (D = '0') then
nextstate <= secondstate;
end if;

when secondstate =>
tempsum <= ('0'&input);
if (D = '0') then
nextstate <= start;
end if;
end case;
end process;

SUM <= tempsum1 + tempsum;

process(SUM)

begin

--display 1st digit (LSD)

bcd0<=SUM(3 downto 0);

Enable <= "110";

case bcd0 is
  when 0 => Seven_Segment_Display_output(7 downto 0) := B"00000010";
when 1 => Seven_Segment_Display_output(7 downto 0) := B"10011110";
when 2 => Seven_Segment_Display_output(7 downto 0) := B"00100100";
when 3 => Seven_Segment_Display_output(7 downto 0) := B"00001100";
when 4 => Seven_Segment_Display_output(7 downto 0) := B"10011000";
when 5 => Seven_Segment_Display_output(7 downto 0) := B"01001000";
when 6 => Seven_Segment_Display_output(7 downto 0) := B"01000000";
when 7 => Seven_Segment_Display_output(7 downto 0) := B"00011110";
when 8 => Seven_Segment_Display_output(7 downto 0) := B"00000000";
when 9 => Seven_Segment_Display_output(7 downto 0) := B"00011000";

when 10 => Seven_Segment_Display_output(7 downto 0) := B"00010000";
when 11 => Seven_Segment_Display_output(7 downto 0) := B"11000000";
when 12 => Seven_Segment_Display_output(7 downto 0) := B"01100010";
when 13 => Seven_Segment_Display_output(7 downto 0) := B"01000010";
when 14 => Seven_Segment_Display_output(7 downto 0) := B"00001100";
when 15 => Seven_Segment_Display_output(7 downto 0) := B"00011100";
when others => Seven_Segment_Display_output(7 downto 0) := B"11111111";
end case;

Seven_Segment_Display(7 downto 0) <= Seven_Segment_Display_output(7 downto 0);

--display 2nd digit

Enable <= "101";

bcd1<=SUM(7 downto 4);

case bcd1 is
  when 0 => Seven_Segment_Display_output(7 downto 0) := B"00000010";
when 1 => Seven_Segment_Display_output(7 downto 0) := B"10011110";
when 2 => Seven_Segment_Display_output(7 downto 0) := B"00100100";
when 3 => Seven_Segment_Display_output(7 downto 0) := B"00001100";
when 4 => Seven_Segment_Display_output(7 downto 0) := B"10011000";
when 5 => Seven_Segment_Display_output(7 downto 0) := B"01001000";
when 6 => Seven_Segment_Display_output(7 downto 0) := B"01000000";
when 7 => Seven_Segment_Display_output(7 downto 0) := B"00011110";
when 8 => Seven_Segment_Display_output(7 downto 0) := B"00000000";
when 9 => Seven_Segment_Display_output(7 downto 0) := B"00011000";

when 10 => Seven_Segment_Display_output(7 downto 0) := B"00010000";
when 11 => Seven_Segment_Display_output(7 downto 0) := B"11000000";
when 12 => Seven_Segment_Display_output(7 downto 0) := B"01100010";
when 13 => Seven_Segment_Display_output(7 downto 0) := B"01000010";
when 14 => Seven_Segment_Display_output(7 downto 0) := B"00001100";
when 15 => Seven_Segment_Display_output(7 downto 0) := B"00011100";
when others => Seven_Segment_Display_output(7 downto 0) := B"11111111";
end case;

Seven_Segment_Display(7 downto 0) <= Seven_Segment_Display_output(7 downto 0);

--display 3rd digit (MSD)

Enable <= "011";

bcd2<=SUM(9 downto 8);

case bcd2 is
  when 0 => Seven_Segment_Display_output(7 downto 0) := B"00000010";
when 1 => Seven_Segment_Display_output(7 downto 0) := B"10011110";
when 2 => Seven_Segment_Display_output(7 downto 0) := B"00100100";
when 3 => Seven_Segment_Display_output(7 downto 0) := B"00001100";
when 4 => Seven_Segment_Display_output(7 downto 0) := B"10011000";
when 5 => Seven_Segment_Display_output(7 downto 0) := B"01001000";
when 6 => Seven_Segment_Display_output(7 downto 0) := B"01000000";
when 7 => Seven_Segment_Display_output(7 downto 0) := B"00011110";
when 8 => Seven_Segment_Display_output(7 downto 0) := B"00000000";
when 9 => Seven_Segment_Display_output(7 downto 0) := B"00011000";

when 10 => Seven_Segment_Display_output(7 downto 0) := B"00010000";
when 11 => Seven_Segment_Display_output(7 downto 0) := B"11000000";
when 12 => Seven_Segment_Display_output(7 downto 0) := B"01100010";
when 13 => Seven_Segment_Display_output(7 downto 0) := B"01000010";
when 14 => Seven_Segment_Display_output(7 downto 0) := B"00001100";
when 15 => Seven_Segment_Display_output(7 downto 0) := B"00011100";
when others => Seven_Segment_Display_output(7 downto 0) := B"11111111";
end case;

​​​​​​​Seven_Segment_Display(7 downto 0) <= Seven_Segment_Display_output(7 downto 0); ​​​​​​​

end process;

End Behavioral;

Constraint File:

############Clock 12MHz

NET "clk" LOC=P129 | IOSTANDARD = LVTTL | PERIOD=12MHz;

NET "D" CLOCK_DEDICATED_ROUTE = FALSE;


############Input push buttons
NET "reset" LOC = P80 | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = FAST | PULLUP;
NET "D" LOC = P79 | IOSTANDARD = LVTTL | DRIVE = 8 | SLEW = FAST | PULLUP;


###########Output Seven Segment Display
NET " ​​​​​​​Seven_Segment_Display[7]" LOC = P117 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET " ​​​​​​​Seven_Segment_Display[6]" LOC = P116 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET " ​​​​​​​Seven_Segment_Display[5]" LOC = P115 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET " ​​​​​​​Seven_Segment_Display[4]" LOC = P113 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET " ​​​​​​​Seven_Segment_Display[3]" LOC = P112 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET " ​​​​​​​Seven_Segment_Display[2]" LOC = P111 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET " ​​​​​​​Seven_Segment_Display[1]" LOC = P110 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;
NET " ​​​​​​​Seven_Segment_Display[0]" LOC = P114 | IOSTANDARD = LVTTL | DRIVE = 8;#| SLEW = FAST;

###Seven Segment Display Enable
   NET "Enable[0]" LOC = P120 | IOSTANDARD = LVTTL | SLEW = SLOW | DRIVE = 12;
   NET "Enable[1]" LOC = P121 | IOSTANDARD = LVTTL | DRIVE = 8;
   NET "Enable[2]" LOC = P124 | IOSTANDARD = LVTTL | DRIVE = 8;     


###########DP Switches

NET "input[0]" LOC = P70 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[1]" LOC = P69 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[2]" LOC = P68 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[3]" LOC = P64 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[4]" LOC = P63 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[5]" LOC = P60 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[6]" LOC = P59 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;
NET "input[7]" LOC = P58 | PULLUP | IOSTANDARD = LVTTL | SLEW = FAST | DRIVE = 8;


Related Solutions

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...
Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 32 bit adder using a single 4 bit adder using verilog code
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using...
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using full adder that is coded using data flow model. Use test bench to test 8-bit adder and consider at least five different test vectors to test it.
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
Design an 8-bit adder. Show Verilog code and testbench.
Design an 8-bit adder. Show Verilog code and testbench.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
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.
Provide the VHDL specification of a hybrid 32-bit adder that cascades 2 12 bit carry look...
Provide the VHDL specification of a hybrid 32-bit adder that cascades 2 12 bit carry look ahead adders and one 10 bit carry look ahead adder. a) Compare your adder with a full 32-bit carry-look ahead in performance and cost. b) Compare your adder with a full combinational adder in performance and cost c) Compare your adder with a ripple-carry adder in performance and cost. d) Compare your adder to a bit serial (sequential) adder in performance and cost. e)...
Create a 4-bit full adder design using VHDL in vivado 2017.2. Project description: You need to...
Create a 4-bit full adder design using VHDL in vivado 2017.2. Project description: You need to create a vhd file for the four-bit full adder. Note: Instead of using bit, please use std_logic; instead of using bit_vector, please use std_logic_vector. One simulation source is required, i.e. testbench Please don't write out on paper. Code written out in text or screen shots would be very much apprecitated.
Write code using the Arduino IDE that compiles with no errors. 2-bit adder: The code must...
Write code using the Arduino IDE that compiles with no errors. 2-bit adder: The code must read two digital input signals and turn on two LEDS as needed to show the sum of the inputs. e.g. 0 + 1 = 01.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT