2020-12-02 11:09:36 +01:00
|
|
|
library ieee;
|
|
|
|
use ieee.std_logic_1164.all,
|
|
|
|
ieee.numeric_std.all;
|
|
|
|
|
|
|
|
entity top is
|
|
|
|
generic (
|
2021-12-01 13:31:07 +01:00
|
|
|
OUTPUT_WIDTH : positive;
|
2020-12-02 11:09:36 +01:00
|
|
|
STEP : natural range 1 to 2
|
|
|
|
);
|
|
|
|
port (
|
|
|
|
clk : in std_logic;
|
|
|
|
reset : in std_logic;
|
|
|
|
char : in character;
|
2021-12-01 13:31:07 +01:00
|
|
|
|
|
|
|
input_valid : in std_logic;
|
|
|
|
|
|
|
|
num_verified : out unsigned(OUTPUT_WIDTH-1 downto 0) := (others => '0');
|
|
|
|
output_valid : out std_logic
|
2020-12-02 11:09:36 +01:00
|
|
|
);
|
|
|
|
end entity;
|
|
|
|
|
|
|
|
architecture behaviour of top is
|
|
|
|
signal is_data : std_logic;
|
|
|
|
signal num1, num2 : natural range 0 to 99;
|
|
|
|
signal letter : character;
|
|
|
|
|
2021-12-01 13:31:07 +01:00
|
|
|
signal record_end : std_logic;
|
2020-12-02 11:09:36 +01:00
|
|
|
|
|
|
|
signal verified : std_logic;
|
|
|
|
begin
|
|
|
|
parser_inst: entity work.parser
|
|
|
|
port map (
|
|
|
|
clk => clk,
|
|
|
|
reset => reset,
|
2021-12-01 13:31:07 +01:00
|
|
|
|
|
|
|
record_end => record_end,
|
2020-12-02 11:09:36 +01:00
|
|
|
is_data => is_data,
|
2021-12-01 13:31:07 +01:00
|
|
|
|
2020-12-02 11:09:36 +01:00
|
|
|
char => char,
|
2021-12-01 13:31:07 +01:00
|
|
|
input_valid => input_valid,
|
2020-12-02 11:09:36 +01:00
|
|
|
|
|
|
|
num1 => num1,
|
|
|
|
num2 => num2,
|
|
|
|
letter => letter
|
|
|
|
);
|
|
|
|
|
|
|
|
generate_verifier: if step = 1 generate
|
|
|
|
verifier_inst: entity work.verifier(step1)
|
|
|
|
port map (
|
|
|
|
clk => clk,
|
2021-12-01 13:31:07 +01:00
|
|
|
reset => reset or record_end,
|
|
|
|
enable => is_data and input_valid,
|
2020-12-02 11:09:36 +01:00
|
|
|
num1 => num1,
|
|
|
|
num2 => num2,
|
|
|
|
letter => letter,
|
|
|
|
char => char,
|
|
|
|
verified => verified
|
|
|
|
);
|
|
|
|
elsif step = 2 generate
|
|
|
|
verifier_inst: entity work.verifier(step2)
|
|
|
|
port map (
|
|
|
|
clk => clk,
|
2021-12-01 13:31:07 +01:00
|
|
|
reset => reset or record_end,
|
|
|
|
enable => is_data and input_valid,
|
2020-12-02 11:09:36 +01:00
|
|
|
num1 => num1,
|
|
|
|
num2 => num2,
|
|
|
|
letter => letter,
|
|
|
|
char => char,
|
|
|
|
verified => verified
|
|
|
|
);
|
|
|
|
else generate
|
|
|
|
assert false report "Bad value for ""step""" severity failure;
|
|
|
|
end generate;
|
|
|
|
|
|
|
|
process(clk)
|
|
|
|
begin
|
|
|
|
if rising_edge(clk) then
|
|
|
|
if reset then
|
|
|
|
num_verified <= (others => '0');
|
2021-12-01 13:31:07 +01:00
|
|
|
elsif record_end and verified then
|
2020-12-02 11:09:36 +01:00
|
|
|
num_verified <= num_verified + 1;
|
|
|
|
end if;
|
|
|
|
end if;
|
|
|
|
end process;
|
2021-12-01 13:31:07 +01:00
|
|
|
|
|
|
|
output_valid <= '1';
|
2020-12-02 11:09:36 +01:00
|
|
|
end architecture;
|