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; - - any package with overloaded

library IEEE;
use ieee.std_logic_1164.ALL;
use IEEE.numeric_std.all; -- any package with overloaded add and subtract
entity Scoreboard is
port (
clk, rst, inc, dec: in std_logic;
-- bcd1_out, bcd0_out : out unsigned(3 downto 0);
seg7disp1, seg7disp0: out unsigned(6 downto 0)
);
end Scoreboard;
architecture Behavioral of Scoreboard is
signal State: integer range 0 to 1;
signal BCD1, BCD0: unsigned(3 downto 0) :="0000"; -- unsigned std_logic vector
signal rstcnt: integer range 0 to 4 :=0;
type sevsegarray is array (0 to 9) of unsigned(6 downto 0);
constant seg7Rom: sevsegarray :=
("0111111","0000110","1011011","1001111","1100110",
"1101101","1111100",
"0000111","1111111","1100111"); -- active high with "gfedcba" order
signal count: integer :=1;
signal tmp: std_logic :='0';
signal clock_out: std_logic :='0';
begin
-- bcd1_out <= bcd1;
-- bcd0_out <= bcd0;
process (clk, tmp)
begin
if (clk'event and clk ='1') then
count <= count +1;
if (count =10000000) then
tmp <= NOT tmp;
count <=1;
end if;
end if;
clock_out <= tmp;
end process;
process (clock_out)
begin
if clock_out'event and clock_out ='1' then
case State is
when 0=>-- initial state
BCD1<="0000"; BCD0<="0000"; -- clear counter
rstcnt <=0; -- reset RESETCOUNT
State <=1;
when 1=>-- state in which the scoreboard waits for inc and dec
if rst ='1' then
if rstcnt =4 then -- checking whether 5th reset cycle
State <=0;
else rstcnt <= rstcnt +1;
end if;
elsif inc ='1' and dec ='0' then
rstcnt <=0;
if BCD0<"1001" then
BCD0<= BCD0+1; -- library with overloaded "+" required
elsif BCD1<"1001" then
BCD1<= BCD1+1;
BCD0<="0000";
end if;
elsif dec ='1' and inc ='0' then
rstcnt <=0;
if BCD0>"0000" then
BCD0<= BCD0-1; -- library with overloaded "-" required
elsif BCD1>"0000" then
BCD1<= BCD1-1;
BCD0<="1001";
end if;
elsif (inc ='1' and dec ='1') or (inc ='0' and dec ='0') then
rstcnt <=0;
end if;
end case;
end if;
end process;
-- seg7disp0<= seg7rom(to_integer(BCD0)); -- type conversion function from
seg7disp1<= seg7rom(to_integer(BCD1)); -- IEEE numeric_std_logic package used
end Behavioral;

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

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

Write short notes on Interviews.

Answered: 1 week ago

Question

Define induction and what are its objectives ?

Answered: 1 week ago