Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

library IEEE; use ieee.std _ logic _ 1 1 6 4 . all; use IEEE.numeric _ std . all; use work.subccts.all; entity bitbreaker is port

"library IEEE;
use ieee.std_logic_1164.all;
use IEEE.numeric_std.all;
use work.subccts.all;
entity bitbreaker is
port( SW : in std_logic_vector(9 downto 0);
KEY : in std_logic_vector(0 to 2);
HEX0 : out std_logic_vector(0 to 6);
HEX1 : out std_logic_vector(0 to 6);
HEX2 : out std_logic_vector(0 to 6);
HEX3 : out std_logic_vector(0 to 6);
LED : out std_logic_vector(9 downto 0));
end bitbreaker;
architecture mixed of bitbreaker is
-- signals associated with ports as illustrated in Figure 1
signal ledCntrl, reset, start, load, clk : std_logic;
signal guess, guessChk : std_logic_vector(7 downto 0);
signal targetLo : std_logic_vector(0 to 6);
signal targetHi : std_logic_vector(0 to 6);
signal guessLeft : std_logic_vector(0 to 6);
signal bitsCorrect : std_logic_vector(0 to 6);
-- ADD YOUR SIGNALS AS NEEDED BELOW THIS LINE
TYPE state_t is (init, display, saved, gameEnd);
signal curr_s, next_s: state_t;
begin
-- associate ports with player signals as illustrated in Figure 1
start <= not KEY(0);
load <= not KEY(1);
clk <= KEY(2);
guess <= SW(7 downto 0) ;
reset <= SW(8);
ledCntrl <= SW(9);
HEX0<= targetLo;
HEX1<= targetHi;
HEX2<= guessLeft;
HEX3<= bitsCorrect;
WITH ledCntrl SELECT
LED(9 DOWNTO 0)<="00" & guessChk WHEN '0',
"000000" & reset & clk & load & start WHEN OTHERS;
-- ADD YOUR CONTROL PATH BELOW
--targetLo <= SW(3 downto 0);
--targetHi <= SW(7 downto 4);
-- Include your FSM transitions
--TYPE state_t IS (init, display, saved, gameEnd);
--signal next_s: state_t;
-- Include your FSM output signals
process(curr_s, next_s, reset, start, load)
begin
CASE curr_s IS
when init =>
if start ='0' then
next_s <= init;
else
guessLeft <="8";
bitsCorrect <=(others =>'0');
guessChk <=(others =>'0');
targetHi <= SW(7 downto 4);
targetLo <= SW(3 downto 0);
next_s <= display;
end if;
when display =>
--correct bits
seg7_port: seg7 PORT MAP(bitsCorrect, HEX3);
--guesses left
seg7_port: seg7 port map(guessLeft, HEX2);
--guess hi
seg7_port: seg7 port map(targetHi, HEX1);
--guess lo
seg7_port: seg7 port map(targetLo, HEX0);
--if loaded
if load ='0' then
next_s <= display;
else
next_s <= saved;
end if;
--else stay here
when saved =>
--change guess hi and lo
targetHi <= SW(7 downto 4);
targetLo <= SW(3 downto 0);
--find correct bits
bitsCorrect <= match8 port map(SW(7 downto 0), guessChk, bitsCorrect);
--guesses left --;
if guessLeft >'0' then
guessLeft <= guessLeft -1;
else
guessLeft :='0';
end if;
--game end or display
if guessLeft ='0' then
next_s <= gameEnd;
elsif bitsCorrect ='8' then
next_s <= gameEnd;
else
next_s <= display;
end if;
when gameEnd =>
--correct bits
seg7 port map(bitsCorrect, HEX3);
--guesses left
seg7 port map(guessLeft, HEX2);
--guess hi
seg7 port map(targetHi, HEX1);
--guess lo
seg7 port map(targetLo, HEX0);
END CASE;
end process;
process(clk, reset)
begin
if reset ='0' then
curr_s <= init;
elsif(clk'event and clk ='1') then
curr_s <= next_s;
end if;
end process;
end architecture;" "--
-- seg7: drives a 7-segment display with a 4-bit binary value
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY seg7 IS
PORT ( bin : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
segments : OUT STD_LOGIC_VECTOR(0 TO 6)) ;
END seg7 ;
ARCHITECTURE Behavior OF seg7 IS
BEGIN
PROCESS ( bin )
BEGIN
CASE bin IS --0123456
WHEN "0000"=> segments <="0000001" ;
WHEN "0001"=> segments <="1001111" ;
WHEN "0010"=> segments <="0010010" ;
WHEN "0011"=> segments <="0000110" ;
WHEN "0100"=> segments <="1001100" ;
WHEN "0101"=> segments <="0100100" ;
WHEN "0110"=> segments <="0100000" ;
WHEN "0111"=> segments <="0001111" ;
WHEN "1000"=> segments <="0000000" ;
WHEN "1001"=> segments <="0000100" ;
WHEN "1010"=> segments <="0001000" ;
WHEN "1011"=> segments <="1100000" ;
WHEN "1100"=> segments <="0110001" ;
WHEN "1101"=> segments <="1000010" ;
WHEN "1110"=> segments <="0110000" ;
WHEN "1111"=> segments <="0111000" ;
WHEN OTHERS => segments <="-------" ;
END CASE ;
END PROCESS ;
END Behavior ;" "Error (10500): VHDL syntax error at bitbreaker.vhd(102) near text "entity"; expecting "(", or an identifier ("entity" is a reserved keyword), or a sequential statement
Error (10500): VHDL syntax error at bitbreaker.vhd(102) near text "PORT"; expecting "(", or "'", or "."
Error (10500): VHDL syntax error at bitbreaker.vhd(102) near text ";"; expecting ":=", or "<="
Error (10500): VHDL syntax error at bitbreaker.vhd(104) near text "port"; expecting "(", or "'", or "."
Error (10500):"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago