1 ------------------------------------------------------------------------------- 3 --! @brief DRV8711 SPI test bench 4 ------------------------------------------------------------------------------- 9 --! Using IEEE standard logic components 10 USE ieee.std_logic_1164.
ALL;
12 --! @brief DRV8711 SPI test bench 14 END ENTITY drv8711_spi_tb;
16 --! Architecture tb of drv8711_spi_tb entity 19 --! Test bench clock period 22 --! Stimulus record type 24 name : (1 TO 30);
--! Stimulus name 25 data_wr : (15 DOWNTO 0);
--! Write data to gpio_device 26 data_rd : (15 DOWNTO 0);
--! Expected read data from gpio_device 29 --! Stimulus array type 53 SIGNAL clk : ;
--! Clock input to uut 54 SIGNAL rst : ;
--! Reset input to uut 60 SIGNAL spi_scs : ;
--! SPI chip-select line 65 -- Signals to transfer clock 68 --! Function to create string from std_logic_vector 73 VARIABLE v_str : (1 TO vector'length);
77 FOR i IN vector'range LOOP 78 v_str(i + 1) := 'image(vector(i))(2);
83 END FUNCTION to_string;
87 --! Instantiate DRV8711 SPI as uut 103 --! Instantiate clk_div_n for transfer clock 117 --! @brief Clock generator process 119 --! This generates the clk signal and the adv signal 120 pr_clock :
PROCESS IS 129 END PROCESS pr_clock;
131 --! @brief Stimulus process to drive PWM unit under test 132 pr_stimulus :
PROCESS IS 135 -- Initialize entity inputs 145 -- Loop over stimulus 148 -- Log start of stimulus 151 -- Perform write to device 154 -- Pulse transfer-start 167 REPORT "Finished" SEVERITY note;
169 -- Finish the simulation 172 END PROCESS pr_stimulus;
out div_pls_outstd_logic
Divider pulse flag.
std_logic spi_scs
SPI chip-select line.
out spi_mosi_outstd_logic
SPI mosi.
string to_stringvector,
Function to create string from std_logic_vector.
std_logic spi_mosi
SPI mosi line.
out div_end_outstd_logic
Divider end flag.
std_logic xfer_adv
Transfer advance pulse.
in clk_instd_logic
Clock.
std_logic_vector( 15 DOWNTO 0) data_send
Data to send.
in spi_miso_instd_logic
SPI miso.
in xfer_start_instd_logic
Transfer start flag.
std_logic_vector( 15 DOWNTO 0) data_recv
Data received.
std_logic rst
Reset input to uut.
t_stimulus_array :=((name => "Transfer ",data_wr => X"A501",data_rd => X"0000"),(name => "Transfer ",data_wr => X"AAAA",data_rd => X"0000"),(name => "Transfer ",data_wr => X"5555",data_rd => X"0000")) c_stimulus
Test stimulus.
in div_adv_instd_logic
Divider advance flag.
clk_divinteger range 2 TO integer'high:= 4
Divider amount.
in xfer_adv_instd_logic
Transfer advance flag.
std_logic xfer_start
Transfer start flag.
in data_send_instd_logic_vector( 15 DOWNTO 0)
Data to send.
std_logic spi_miso
SPI miso line.
in div_clr_instd_logic
Divider clear flag.
out spi_sclk_outstd_logic
SPI clock.
std_logic spi_sclk
SPI clock line.
t_stimulus
Stimulus record type.
std_logic clk
Clock input to uut.
in rst_instd_logic
Asynchronous reset.
time := 10 ns c_clk_period
Test bench clock period.
out data_recv_outstd_logic_vector( 15 DOWNTO 0)
Data received.
std_logic xfer_clk_rst
Reset transfer clock.
string( 1 TO 30) name
Stimulus name.
_library_ ieeeieee
Using IEEE library.
std_logic_vector( 15 DOWNTO 0) data_rd
Expected read data from gpio_device.
out xfer_done_outstd_logic
Transfer done flag.
std_logic_vector( 15 DOWNTO 0) data_wr
Write data to gpio_device.
std_logic xfer_done
Transfer done pulse.
out spi_scs_outstd_logic
SPI chip-select.
in rst_instd_logic
Asynchronous reset.
array(natural range <> ) of t_stimulus t_stimulus_array
Stimulus array type.
in clk_instd_logic
Clock.