Question: these are the 3 codes that i wrote implement Digital Stopwatch Design a stopwatch that can measure time in seconds and milliseconds. Include start, stop,

these are the 3codes that i wrote implement Digital Stopwatch
Design a stopwatch that can measure time in seconds and milliseconds. Include start, stop, and reset functionalities. ### plz let me know it there's any modification to let them work properly on the seven segment desplay on the fpga de10-lite board.Projects must include a graphical representation of the design, such as a State Machine (SM)chart or a State Graph.
1 library ieee;
use ieee.std_logic_1164.a11;
use ieee.numeric_std.a11;
entity stopwatch_top is
port (
clk : in std_logic;
reset : in std_logic;
start_stop : in std_logic;
clear : in std_logic;
seg7_display : out std_logic_vector(6 downto 0);
anode_enable : out std_logic_vector(4 downto 0)'--5-bit vector for 5 displays
);
end stopwatch_top;
garchitecture rtl of stopwatch_top is
signal enable : std_logic;
signal state_led : std_logic_vector(1 downto 0);
signal ms_counter : unsigned(9 downto 0) :=(others =>'0'); --10-bit counter for milliseconds (0-999)
signal sec_counter : unsigned(5 downto 0) :=(others =>'0');
signal min_counter : unsigned(5 downto 0) :=(others =>'0');
signal sec_ones, sec_tens, min_ones, min_tens, ms_ones, ms_tens : unsigned(3 downto 0);
signal current_display : unsigned(3 downto 0);
signal mux_select : unsigned(2 downto 0) :=(others =>'0'); -- Update for 5 displays
signal clk_div : unsigned(19 downto 0) :=(others =>'0');
signal mux_clk : std_logic;
@begin
-- Instantiate the FSM
fsm_inst : entity work.stopwatch_fsm
port map (
clk => clk,
reset => reset,
start_stop => start_stop,
clear => clear,
enable => enab1e,
state_led => state_led
);
-- Milliseconds counter process
process (clk. reset)
```
86- end process;
mux_clk = clk_div(19); -- Adjust based on your clock frequency
-- Multiplexing control
process (mux_clk, reset)
begin
if reset ='1' then
mux_select =(others =>'0');
elsif rising_edge(mux_clk) then
mux_select = mux_select +1;
end if;
end process;
-- Current display value selection
process (mux_select, sec_ones, sec_tens, min_ones, min_tens, ms_ones, ms_tens)
begin
case mux_select is
when "000"=> current_display = ms_ones; -- Milliseconds, ones place
when "001"=> current_display = ms_tens; -- Milliseconds, tens place
when "010"=> current_display = sec_ones; -- Seconds, ones place
when "011"=> current_display = sec_tens; -- Seconds, tens place
when "100"=> current_display = min_ones; -- Minutes, ones place
when "101"=> current_display = min_tens; -- Minutes, tens place
when others => current_display =(others =>'0');
end case;
end process;
-- Instantiate the 7-segment display module
seg7_inst : entity work.seg7
port map (
a => std_logic_vector(current_display),
en =>'1',
);
q => seg7_display
-- Anode enable for multiplexing 5 displays
anode_enable ="11110" when mux_select ="000" else -- For display 1(ms ones)
"11101" when mux_select ="001" else -- For display 2(ms tens)
"11011" when mux_select ="010" else -- For display 3(sec ones)
"10111", when mux_select ="011" else -- For display 4(sec tens)
"01111"; -- For display 5(min ones, assuming 5th display)
end rtl;
``````
library ieee;
use ieee.std_logic_1164.al1;
use ieee.numeric_std.ali;
-- Entity
gentity seg7 is
port (
a : in std_logic_vector (3 downto 0);
en : in st\overline{d_logic;}
(end );
-- Architecture
@architecture rtl of seg7 is
type rom is array (0 to 9) of std_logic_vector (6 downto 0);
constant seg_table : rom :=(
"0000001",--0
"1001111",--1
"0010010",--2
"0000110",--3
"1001100",--4
"0100100",--5
"0100000",--6
"0001111",--7
"0000000",'--8
"0000100"--9
);
@begin
process (a, en)
begin
if en ='1' then
if a ="1010" then
else
q ="1111111";
q = seg_table(to_integer(unsigned(a)));
end if;
else
q="1111111";
end if;
end process;
end rtl;
```
```
File Edit View Project Processing Tools Window Help
```
```
library ieee;
use ieee.std_logic_1164.a11;
use ieee.numeric_std.a11;
entity stopwatch_fsm is
port (
clk : in std_logic;
reset : in std_logic;
start_stop : in std_logic; -- Input to toggle start/stop
clear : in std_logic; -- Input to reset the stopwatch
enable: out std_logic; -- Output to enable the counters
state_led : out std_logic_vector(1 downto 0)-- State indicator (optiona1)
-end stopwatch_fsm;
@architecture behavioral of stopwatch_fsm is
-- Define the states
type state_type is (IDLE, RUNNING, PAUSED);
signa1 current_state, next_state : state_type;
-- Internal signals
signal start_stop_edge : std_logic :='0';
signal last_start_stop : std_logic :='0';
begin
-- State LED output (optional, for debugging)
state_led = std_logic_vector'(to_unsigned(state_type'pos(current_state),2));
-- Edge detection for the start/stop button
process (clk)
begin
if rising_edge(clk) then
start_stop_edge = start_stop and not last_start_stop;
last_start_stop = start_stop;
end if;
end process;
-- State t
these are the 3 codes that i wrote implement

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!