|
|
@@ -1,68 +1,57 @@
|
|
|
library ieee;
|
|
|
use ieee.std_logic_1164.all;
|
|
|
+use ieee.numeric_std.all;
|
|
|
|
|
|
entity tb is
|
|
|
end entity;
|
|
|
|
|
|
architecture beh of tb is
|
|
|
- component generic_counter is
|
|
|
- generic (
|
|
|
- counter_bits : integer
|
|
|
- );
|
|
|
- port
|
|
|
- (
|
|
|
- clk : in std_logic;
|
|
|
- res : in std_logic;
|
|
|
- en : in std_logic;
|
|
|
- cnt : out std_logic_vector (counter_bits -1 downto 0)
|
|
|
- );
|
|
|
- end component;
|
|
|
-
|
|
|
- signal clock, enable_counter, reset : std_logic;
|
|
|
-
|
|
|
- signal counter_value : std_logic_vector(7 downto 0)
|
|
|
+ component generic_counter is
|
|
|
+ generic (
|
|
|
+ counter_bits : integer
|
|
|
+ );
|
|
|
+ port(
|
|
|
+ clk : in std_logic;
|
|
|
+ rst : in std_logic;
|
|
|
+ en : in std_logic;
|
|
|
+ cnt : out unsigned (counter_bits -1 downto 0)
|
|
|
+ );
|
|
|
+ end component;
|
|
|
+
|
|
|
+ signal clock : std_logic := '0';
|
|
|
+ signal enable_counter : std_logic;
|
|
|
+ signal reset : std_logic;
|
|
|
+
|
|
|
+ signal counter_value : unsigned(7 downto 0);
|
|
|
+
|
|
|
+ signal running : boolean := true;
|
|
|
begin
|
|
|
+ running <= true, false after 400 us;
|
|
|
+
|
|
|
+ reset <= '0', '1' after 20 us, '0' after 40 us, '1' after 300 us, '0' after 320 us;
|
|
|
+
|
|
|
+ enable_counter <= '0', '1' after 60 us, '0' after 200 us, '1' after 240 us;
|
|
|
+
|
|
|
+ process is
|
|
|
+ begin
|
|
|
+ if running then
|
|
|
+ wait for 10 us;
|
|
|
+ clock <= not clock;
|
|
|
+ else
|
|
|
+ report "End of simulation!";
|
|
|
+ wait;
|
|
|
+ end if;
|
|
|
+ end process;
|
|
|
+
|
|
|
+ cnt_i1 : generic_counter
|
|
|
+ generic map(
|
|
|
+ counter_bits => 8
|
|
|
+ )
|
|
|
+ port map(
|
|
|
+ clk => clock,
|
|
|
+ rst => reset,
|
|
|
+ en => enable_counter,
|
|
|
+ cnt => counter_value
|
|
|
+ );
|
|
|
|
|
|
- --ha_instance : ha port map (q => a, w => b, e => o, r => c);
|
|
|
- --ha_instance : ha port map (a => q, b => w, o => e, c => r);
|
|
|
- --ha_instance : ha port map (q, w, e, r);
|
|
|
- cnt_i1 :
|
|
|
- generic map(
|
|
|
- counter_bits => 8
|
|
|
- )
|
|
|
- port map(
|
|
|
- clk => clock,
|
|
|
- rst => reset,
|
|
|
- en => enable_counter,
|
|
|
- cnt => counter_value
|
|
|
- );
|
|
|
-
|
|
|
- process is
|
|
|
- begin
|
|
|
- clk <= not clk;
|
|
|
- wait for 10 ns;
|
|
|
-
|
|
|
- assert false report "end of simulation";
|
|
|
-
|
|
|
- wait;
|
|
|
- end process;
|
|
|
-
|
|
|
- process is
|
|
|
- begin
|
|
|
- report "Shit!";
|
|
|
- wait until r = '1';
|
|
|
- report "It happened!";
|
|
|
-
|
|
|
- for i in 3 to 6 loop
|
|
|
- report "Currently at " & integer'image(i);
|
|
|
- wait for 1 ns;
|
|
|
- end loop;
|
|
|
-
|
|
|
- report "At end of test process!";
|
|
|
- wait;
|
|
|
- end process;
|
|
|
-
|
|
|
- -- Invalid report in concurrent statement
|
|
|
- --report "when is this?";
|
|
|
-
|
|
|
end architecture;
|