Update .gitignore and enhance README.md; add new VHDL files for KittCarPWM, ShiftRegisters, and PulseWidthModulator
This commit is contained in:
255
LAB0/sim/tb_PulseWidthModulator.vhd
Normal file
255
LAB0/sim/tb_PulseWidthModulator.vhd
Normal file
@@ -0,0 +1,255 @@
|
||||
----------------------------------------------------------------------------------
|
||||
-- Company:
|
||||
-- Engineer:
|
||||
--
|
||||
-- Create Date: 19.03.2019 18:55:36
|
||||
-- Design Name:
|
||||
-- Module Name: tb_PulseWidthModulator - Behavioral
|
||||
-- Project Name:
|
||||
-- Target Devices:
|
||||
-- Tool Versions:
|
||||
-- Description:
|
||||
--
|
||||
-- Dependencies:
|
||||
--
|
||||
-- Revision:
|
||||
-- Revision 0.01 - File Created
|
||||
-- Additional Comments:
|
||||
--
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
---------- DEFAULT LIBRARY ---------
|
||||
library IEEE;
|
||||
use IEEE.STD_LOGIC_1164.all;
|
||||
use IEEE.NUMERIC_STD.ALL;
|
||||
-- use IEEE.MATH_REAL.all;
|
||||
|
||||
-- use STD.textio.all;
|
||||
-- use ieee.std_logic_textio.all;
|
||||
|
||||
------------------------------------
|
||||
|
||||
|
||||
---------- OTHERS LIBRARY ----------
|
||||
-- NONE
|
||||
------------------------------------
|
||||
|
||||
entity tb_PulseWidthModulator is
|
||||
end tb_PulseWidthModulator;
|
||||
|
||||
architecture Behavioral of tb_PulseWidthModulator is
|
||||
|
||||
------------------ CONSTANT DECLARATION -------------------------
|
||||
|
||||
--------- Timing -----------
|
||||
constant CLK_PERIOD : TIME := 10 ns;
|
||||
constant RESET_WND : TIME := 10*CLK_PERIOD;
|
||||
|
||||
constant PWM_WND : TIME := 100 ns;
|
||||
----------------------------
|
||||
|
||||
--- TB Initialiazzations ---
|
||||
constant TB_CLK_INIT : STD_LOGIC := '0';
|
||||
constant TB_RESET_INIT : STD_LOGIC := '1';
|
||||
----------------------------
|
||||
|
||||
|
||||
------- DUT Generics -------
|
||||
constant DUT_BIT_LENGTH : INTEGER RANGE 1 TO 16 := 3; -- Leds used over the 16 in Basys3
|
||||
|
||||
constant DUT_T_ON_INIT : POSITIVE := 8; -- Init of Ton
|
||||
constant DUT_PERIOD_INIT : POSITIVE := 16; -- Init of Periof
|
||||
|
||||
constant DUT_PWM_INIT : STD_LOGIC := '1'; -- Init of PWM
|
||||
----------------------------
|
||||
|
||||
|
||||
-----------------------------------------------------------------
|
||||
|
||||
------ COMPONENT DECLARATION for the Device Under Test (DUT) ------
|
||||
|
||||
----------- DUT -----------
|
||||
component PulseWidthModulator
|
||||
Generic(
|
||||
|
||||
BIT_LENGTH : INTEGER RANGE 1 TO 16; -- Leds used over the 16 in Basys3
|
||||
|
||||
T_ON_INIT : POSITIVE; -- Init of Ton
|
||||
PERIOD_INIT : POSITIVE; -- Init of Periof
|
||||
|
||||
PWM_INIT : STD_LOGIC -- Init of PWM
|
||||
);
|
||||
Port (
|
||||
|
||||
------- Reset/Clock --------
|
||||
reset : IN STD_LOGIC;
|
||||
clk : IN STD_LOGIC;
|
||||
----------------------------
|
||||
|
||||
-------- Duty Cycle ----------
|
||||
Ton : IN STD_LOGIC_VECTOR(BIT_LENGTH-1 downto 0); -- clk at PWM = '1'
|
||||
Period : IN STD_LOGIC_VECTOR(BIT_LENGTH-1 downto 0); -- clk per period of PWM
|
||||
|
||||
PWM : OUT STD_LOGIC -- PWM signal
|
||||
----------------------------
|
||||
|
||||
);
|
||||
end component;
|
||||
|
||||
----------------------------
|
||||
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------- SIGNALS DECLARATION -----------------------
|
||||
|
||||
|
||||
------- Clock/Reset -------
|
||||
signal reset : STD_LOGIC := TB_RESET_INIT;
|
||||
signal clk : STD_LOGIC := TB_CLK_INIT;
|
||||
----------------------------
|
||||
|
||||
|
||||
|
||||
-------- Duty Cycle ----------
|
||||
signal dut_Ton : STD_LOGIC_VECTOR(DUT_BIT_LENGTH-1 downto 0); -- clk at PWM = '1'
|
||||
signal dut_Period : STD_LOGIC_VECTOR(DUT_BIT_LENGTH-1 downto 0); -- clk per period of PWM
|
||||
|
||||
signal dut_PWM : STD_LOGIC; -- PWM signal
|
||||
----------------------------
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
begin
|
||||
|
||||
|
||||
--------------------- COMPONENTS DUT WRAPPING --------------------
|
||||
|
||||
----------- DUT ------------
|
||||
dut_PulseWidthModulator : PulseWidthModulator
|
||||
Generic Map(
|
||||
|
||||
BIT_LENGTH => DUT_BIT_LENGTH,
|
||||
|
||||
T_ON_INIT => DUT_T_ON_INIT,
|
||||
PERIOD_INIT => DUT_PERIOD_INIT,
|
||||
|
||||
PWM_INIT => DUT_PWM_INIT
|
||||
|
||||
)
|
||||
Port Map(
|
||||
|
||||
------- Reset/Clock --------
|
||||
reset => reset,
|
||||
clk => clk,
|
||||
----------------------------
|
||||
|
||||
|
||||
-------- Duty Cycle ----------
|
||||
Ton => dut_Ton,
|
||||
Period => dut_Period,
|
||||
|
||||
PWM => dut_PWM
|
||||
----------------------------
|
||||
|
||||
);
|
||||
----------------------------
|
||||
|
||||
----------------------------
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
|
||||
--------------------- TEST BENCH DATA FLOW -----------------------
|
||||
|
||||
---------- clock ----------
|
||||
clk <= not clk after CLK_PERIOD/2;
|
||||
----------------------------
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
|
||||
---------------------- TEST BENCH PROCESS -------------------------
|
||||
|
||||
|
||||
---- Clock Process --------
|
||||
-- clk_wave :process
|
||||
-- begin
|
||||
-- clk <= CLK_PERIOD;
|
||||
-- wait for CLK_PERIOD/2;
|
||||
|
||||
-- clk <= not clk;
|
||||
-- wait for CLK_PERIOD/2;
|
||||
-- end process;
|
||||
--------------------------
|
||||
|
||||
|
||||
----- Reset Process --------
|
||||
reset_wave :process
|
||||
begin
|
||||
reset <= TB_RESET_INIT;
|
||||
wait for RESET_WND;
|
||||
|
||||
reset <= not reset;
|
||||
wait;
|
||||
end process;
|
||||
----------------------------
|
||||
|
||||
|
||||
------ Stimulus process -------
|
||||
|
||||
stim_proc: process
|
||||
begin
|
||||
|
||||
-- waiting the reset wave
|
||||
|
||||
dut_Ton <= std_logic_vector(to_unsigned(0,DUT_BIT_LENGTH));
|
||||
dut_Period <= std_logic_vector(to_unsigned(0,DUT_BIT_LENGTH));
|
||||
wait for RESET_WND;
|
||||
|
||||
|
||||
-- Start
|
||||
for I in 0 to 2**DUT_BIT_LENGTH-1 loop
|
||||
|
||||
dut_Period <= std_logic_vector(to_unsigned(I,DUT_BIT_LENGTH));
|
||||
|
||||
for J in 0 to 2**DUT_BIT_LENGTH-1 loop
|
||||
|
||||
dut_Ton <= std_logic_vector(to_unsigned(J,DUT_BIT_LENGTH));
|
||||
|
||||
|
||||
wait for PWM_WND;
|
||||
|
||||
end loop;
|
||||
end loop;
|
||||
|
||||
|
||||
dut_Ton <= std_logic_vector(to_unsigned(2**DUT_BIT_LENGTH-1,DUT_BIT_LENGTH));
|
||||
dut_Period <= std_logic_vector(to_unsigned(2**DUT_BIT_LENGTH-2,DUT_BIT_LENGTH));
|
||||
wait for PWM_WND;
|
||||
|
||||
-- Stop
|
||||
wait;
|
||||
|
||||
|
||||
--------------------------
|
||||
|
||||
wait;
|
||||
end process;
|
||||
----------------------------
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
end Behavioral;
|
||||
181
LAB0/sim/tb_ShiftRegister_v0.vhd
Normal file
181
LAB0/sim/tb_ShiftRegister_v0.vhd
Normal file
@@ -0,0 +1,181 @@
|
||||
----------------------------------------------------------------------------------
|
||||
-- Company:
|
||||
-- Engineer:
|
||||
--
|
||||
-- Create Date: 07.03.2019 12:46:18
|
||||
-- Design Name:
|
||||
-- Module Name: tb_ShiftRegister_v0 - Behavioral
|
||||
-- Project Name:
|
||||
-- Target Devices:
|
||||
-- Tool Versions:
|
||||
-- Description:
|
||||
--
|
||||
-- Dependencies:
|
||||
--
|
||||
-- Revision:
|
||||
-- Revision 0.01 - File Created
|
||||
-- Additional Comments:
|
||||
--
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.STD_LOGIC_1164.ALL;
|
||||
|
||||
-- Uncomment the following library declaration if using
|
||||
-- arithmetic functions with Signed or Unsigned values
|
||||
use IEEE.NUMERIC_STD.ALL;
|
||||
|
||||
-- Uncomment the following library declaration if instantiating
|
||||
-- any Xilinx leaf cells in this code.
|
||||
--library UNISIM;
|
||||
--use UNISIM.VComponents.all;
|
||||
|
||||
entity tb_ShiftRegister_v0 is
|
||||
end tb_ShiftRegister_v0;
|
||||
|
||||
architecture Behavioral of tb_ShiftRegister_v0 is
|
||||
|
||||
------------------------ Constant Declaration -------------------------
|
||||
|
||||
-- Constant For Test Bench (TB) --
|
||||
constant RESET_ON : STD_LOGIC := '1';
|
||||
|
||||
constant CLK_PERIOD : time := 10 ns;
|
||||
constant RESET_WND : time := 100 ns;
|
||||
----------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
----------------- Device Under Test (DUT) Declaration ----------------
|
||||
|
||||
------------ DUT v0 --------------
|
||||
COMPONENT ShiftRegister_v0
|
||||
Port (
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
reset : IN STD_LOGIC;
|
||||
clk : IN STD_LOGIC;
|
||||
---------------------------------
|
||||
|
||||
------------- Data --------------
|
||||
din : IN STD_LOGIC;
|
||||
dout : OUT STD_LOGIC
|
||||
---------------------------------
|
||||
|
||||
);
|
||||
END COMPONENT;
|
||||
----------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
------------------------- Signal Declaration -------------------------
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
signal reset : STD_LOGIC := RESET_ON;
|
||||
signal clk : STD_LOGIC := '1';
|
||||
---------------------------------
|
||||
|
||||
|
||||
-------- ShiftRegister_v0 -------
|
||||
signal dut0_din : STD_LOGIC := '0';
|
||||
signal dut0_dout : STD_LOGIC;
|
||||
---------------------------------
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
begin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
------------------- Device Under Test (DUT) Wrapper ------------------
|
||||
|
||||
------------ DUT v0 --------------
|
||||
dut0_ShiftRegister_v0 : ShiftRegister_v0
|
||||
Port Map(
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
reset => reset,
|
||||
clk => clk,
|
||||
---------------------------------
|
||||
|
||||
------------- Data --------------
|
||||
din => dut0_din,
|
||||
dout => dut0_dout
|
||||
---------------------------------
|
||||
|
||||
);
|
||||
----------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
-------------------------- Signals Generation -------------------------
|
||||
|
||||
|
||||
------ TB Clk Generation -------
|
||||
|
||||
clk <= not clk after CLK_PERIOD/2;
|
||||
---------------------------------
|
||||
|
||||
|
||||
----- TB Reset Generation ------
|
||||
reset_wave : process
|
||||
begin
|
||||
|
||||
reset <= '1';
|
||||
wait for RESET_WND;
|
||||
|
||||
reset <= '0';
|
||||
wait;
|
||||
|
||||
end process;
|
||||
---------------------------------
|
||||
|
||||
|
||||
|
||||
-- TB din pattern Generation ---
|
||||
dut0_din_pattern : process
|
||||
begin
|
||||
|
||||
-- wait the reset window
|
||||
dut0_din <= '0';
|
||||
wait for RESET_WND;
|
||||
|
||||
-- Start
|
||||
dut0_din <= '0';
|
||||
wait for CLK_PERIOD;
|
||||
|
||||
dut0_din <= '1';
|
||||
wait for 4*CLK_PERIOD;
|
||||
|
||||
dut0_din <= '0';
|
||||
wait for 8*CLK_PERIOD;
|
||||
|
||||
-- Etc...
|
||||
|
||||
-- Stop
|
||||
wait;
|
||||
|
||||
end process;
|
||||
---------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
end Behavioral;
|
||||
195
LAB0/sim/tb_ShiftRegister_v1.vhd
Normal file
195
LAB0/sim/tb_ShiftRegister_v1.vhd
Normal file
@@ -0,0 +1,195 @@
|
||||
----------------------------------------------------------------------------------
|
||||
-- Company:
|
||||
-- Engineer:
|
||||
--
|
||||
-- Create Date: 07.03.2019 13:27:59
|
||||
-- Design Name:
|
||||
-- Module Name: tb_ShiftRegister_v1 - Behavioral
|
||||
-- Project Name:
|
||||
-- Target Devices:
|
||||
-- Tool Versions:
|
||||
-- Description:
|
||||
--
|
||||
-- Dependencies:
|
||||
--
|
||||
-- Revision:
|
||||
-- Revision 0.01 - File Created
|
||||
-- Additional Comments:
|
||||
--
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.STD_LOGIC_1164.ALL;
|
||||
|
||||
-- Uncomment the following library declaration if using
|
||||
-- arithmetic functions with Signed or Unsigned values
|
||||
use IEEE.NUMERIC_STD.ALL;
|
||||
|
||||
-- Uncomment the following library declaration if instantiating
|
||||
-- any Xilinx leaf cells in this code.
|
||||
--library UNISIM;
|
||||
--use UNISIM.VComponents.all;
|
||||
|
||||
entity tb_ShiftRegister_v1 is
|
||||
end tb_ShiftRegister_v1;
|
||||
|
||||
architecture Behavioral of tb_ShiftRegister_v1 is
|
||||
|
||||
------------------------ Constant Declaration -------------------------
|
||||
|
||||
-- Constant For Test Bench (TB) --
|
||||
constant RESET_ON : STD_LOGIC := '1';
|
||||
|
||||
constant CLK_PERIOD : time := 10 ns;
|
||||
constant RESET_WND : time := 100 ns;
|
||||
----------------------------------
|
||||
|
||||
------ Constant For DUT v0 ------
|
||||
constant DUT1_SR_DEPTH : POSITIVE := 4;
|
||||
constant DUT1_SR_INIT : STD_LOGIC := '0';
|
||||
----------------------------------
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
----------------- Device Under Test (DUT) Declaration ----------------
|
||||
|
||||
------------ DUT v1 --------------
|
||||
COMPONENT ShiftRegister_v1
|
||||
Generic(
|
||||
SR_DEPTH : POSITIVE;
|
||||
SR_INIT : STD_LOGIC
|
||||
);
|
||||
Port (
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
reset : IN STD_LOGIC;
|
||||
clk : IN STD_LOGIC;
|
||||
---------------------------------
|
||||
|
||||
------------- Data --------------
|
||||
din : IN STD_LOGIC;
|
||||
dout : OUT STD_LOGIC
|
||||
---------------------------------
|
||||
|
||||
);
|
||||
END COMPONENT;
|
||||
----------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
------------------------- Signal Declaration -------------------------
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
signal reset : STD_LOGIC := RESET_ON;
|
||||
signal clk : STD_LOGIC := '1';
|
||||
---------------------------------
|
||||
|
||||
|
||||
-------- ShiftRegister_v1 -------
|
||||
signal dut1_din : STD_LOGIC := '0';
|
||||
signal dut1_dout : STD_LOGIC;
|
||||
---------------------------------
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
begin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
------------------- Device Under Test (DUT) Wrapper ------------------
|
||||
|
||||
------------ DUT v1 --------------
|
||||
dut1_ShiftRegister_v1 : ShiftRegister_v1
|
||||
|
||||
Generic Map(
|
||||
SR_DEPTH => DUT1_SR_DEPTH,
|
||||
SR_INIT => DUT1_SR_INIT
|
||||
)
|
||||
Port Map(
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
reset => reset,
|
||||
clk => clk,
|
||||
---------------------------------
|
||||
|
||||
------------- Data --------------
|
||||
din => dut1_din,
|
||||
dout => dut1_dout
|
||||
---------------------------------
|
||||
|
||||
);
|
||||
----------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
-------------------------- Signals Generation -------------------------
|
||||
|
||||
|
||||
------ TB Clk Generation -------
|
||||
|
||||
clk <= not clk after CLK_PERIOD/2;
|
||||
---------------------------------
|
||||
|
||||
|
||||
----- TB Reset Generation ------
|
||||
reset_wave : process
|
||||
begin
|
||||
|
||||
reset <= '1';
|
||||
wait for RESET_WND;
|
||||
|
||||
reset <= '0';
|
||||
wait;
|
||||
|
||||
end process;
|
||||
---------------------------------
|
||||
|
||||
|
||||
|
||||
-- TB din pattern Generation ---
|
||||
dut1_din_pattern : process
|
||||
begin
|
||||
|
||||
-- wait the reset window
|
||||
dut1_din <= '0';
|
||||
wait for RESET_WND;
|
||||
|
||||
|
||||
-- Start
|
||||
dut1_din <= '0';
|
||||
wait for CLK_PERIOD;
|
||||
|
||||
dut1_din <= '1';
|
||||
wait for 4*CLK_PERIOD;
|
||||
|
||||
dut1_din <= '0';
|
||||
wait for 8*CLK_PERIOD;
|
||||
|
||||
-- Etc...
|
||||
|
||||
-- Stop
|
||||
wait;
|
||||
|
||||
end process;
|
||||
---------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
end Behavioral;
|
||||
198
LAB0/sim/tb_ShiftRegister_v2.vhd
Normal file
198
LAB0/sim/tb_ShiftRegister_v2.vhd
Normal file
@@ -0,0 +1,198 @@
|
||||
----------------------------------------------------------------------------------
|
||||
-- Company:
|
||||
-- Engineer:
|
||||
--
|
||||
-- Create Date: 07.03.2019 16:39:28
|
||||
-- Design Name:
|
||||
-- Module Name: tb_ShiftRegister_v2 - Behavioral
|
||||
-- Project Name:
|
||||
-- Target Devices:
|
||||
-- Tool Versions:
|
||||
-- Description:
|
||||
--
|
||||
-- Dependencies:
|
||||
--
|
||||
-- Revision:
|
||||
-- Revision 0.01 - File Created
|
||||
-- Additional Comments:
|
||||
--
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
library IEEE;
|
||||
use IEEE.STD_LOGIC_1164.ALL;
|
||||
|
||||
-- Uncomment the following library declaration if using
|
||||
-- arithmetic functions with Signed or Unsigned values
|
||||
use IEEE.NUMERIC_STD.ALL;
|
||||
|
||||
-- Uncomment the following library declaration if instantiating
|
||||
-- any Xilinx leaf cells in this code.
|
||||
--library UNISIM;
|
||||
--use UNISIM.VComponents.all;
|
||||
|
||||
entity tb_ShiftRegister_v2 is
|
||||
end tb_ShiftRegister_v2;
|
||||
|
||||
architecture Behavioral of tb_ShiftRegister_v2 is
|
||||
|
||||
------------------------ Constant Declaration -------------------------
|
||||
|
||||
-- Constant For Test Bench (TB) --
|
||||
constant RESET_ON : STD_LOGIC := '1';
|
||||
|
||||
constant CLK_PERIOD : time := 10 ns;
|
||||
constant RESET_WND : time := 100 ns;
|
||||
----------------------------------
|
||||
|
||||
------ Constant For DUT v2 ------
|
||||
constant DUT2_SR_WIDTH : NATURAL := 8;
|
||||
constant DUT2_SR_DEPTH : POSITIVE := 4;
|
||||
constant DUT2_SR_INIT : STD_LOGIC := '0';
|
||||
----------------------------------
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
----------------- Device Under Test (DUT) Declaration ----------------
|
||||
|
||||
------------ DUT v2 --------------
|
||||
COMPONENT ShiftRegister_v2
|
||||
Generic(
|
||||
SR_WIDTH : NATURAL := 7;
|
||||
SR_DEPTH : POSITIVE := 4;
|
||||
SR_INIT : STD_LOGIC := '0'
|
||||
);
|
||||
Port (
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
reset : IN STD_LOGIC;
|
||||
clk : IN STD_LOGIC;
|
||||
---------------------------------
|
||||
|
||||
------------- Data --------------
|
||||
din : IN STD_LOGIC_VECTOR(SR_WIDTH-1 downto 0);
|
||||
dout : OUT STD_LOGIC_VECTOR(SR_WIDTH-1 downto 0)
|
||||
---------------------------------
|
||||
|
||||
);
|
||||
END COMPONENT;
|
||||
----------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
------------------------- Signal Declaration -------------------------
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
signal reset : STD_LOGIC := RESET_ON;
|
||||
signal clk : STD_LOGIC := '1';
|
||||
---------------------------------
|
||||
|
||||
|
||||
-------- ShiftRegister_v2 -------
|
||||
signal dut2_din : STD_LOGIC_VECTOR(DUT2_SR_WIDTH-1 downto 0) := (Others => '0');
|
||||
signal dut2_dout : STD_LOGIC_VECTOR(DUT2_SR_WIDTH-1 downto 0);
|
||||
---------------------------------
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
begin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
------------------- Device Under Test (DUT) Wrapper ------------------
|
||||
|
||||
------------ DUT v2 --------------
|
||||
dut2_ShiftRegister_v2 : ShiftRegister_v2
|
||||
|
||||
Generic Map(
|
||||
SR_WIDTH => DUT2_SR_WIDTH,
|
||||
SR_DEPTH => DUT2_SR_DEPTH,
|
||||
SR_INIT => DUT2_SR_INIT
|
||||
)
|
||||
Port Map(
|
||||
|
||||
---------- Reset/Clock ----------
|
||||
reset => reset,
|
||||
clk => clk,
|
||||
---------------------------------
|
||||
|
||||
------------- Data --------------
|
||||
din => dut2_din,
|
||||
dout => dut2_dout
|
||||
---------------------------------
|
||||
|
||||
);
|
||||
----------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
-------------------------- Signals Generation -------------------------
|
||||
|
||||
|
||||
------ TB Clk Generation -------
|
||||
|
||||
clk <= not clk after CLK_PERIOD/2;
|
||||
---------------------------------
|
||||
|
||||
|
||||
----- TB Reset Generation ------
|
||||
reset_wave : process
|
||||
begin
|
||||
|
||||
reset <= '1';
|
||||
wait for RESET_WND;
|
||||
|
||||
reset <= '0';
|
||||
wait;
|
||||
|
||||
end process;
|
||||
---------------------------------
|
||||
|
||||
|
||||
|
||||
-- TB din pattern Generation ---
|
||||
dut2_din_pattern : process
|
||||
begin
|
||||
|
||||
-- wait the reset window
|
||||
dut2_din <= (Others => '0');
|
||||
wait for RESET_WND;
|
||||
|
||||
-- Start
|
||||
dut2_din <= (Others => '0');
|
||||
wait for CLK_PERIOD;
|
||||
|
||||
dut2_din <= (Others => '1');
|
||||
wait for 4*CLK_PERIOD;
|
||||
|
||||
dut2_din <= (Others => '0');
|
||||
wait for 8*CLK_PERIOD;
|
||||
|
||||
-- Etc...
|
||||
|
||||
-- Stop
|
||||
wait;
|
||||
|
||||
end process;
|
||||
---------------------------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
end Behavioral;
|
||||
Reference in New Issue
Block a user