我有各种在带有微控制器的并行总线上使用 FPGA 的设计。对于每个设计,我都有一个测试平台,我使用模拟 MCU 时序的程序来模拟总线上的多个读/写操作。
我想知道一种将这些程序放在一个包中以便于重用的好方法。现在,程序已定义并作用于测试台实体范围内的信号。我宁愿有这样的东西。
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.mcu_sim.all; -- contains MCU component and procedures for bus R/W operations
entity tb is
end tb;
architecture a of tb is
-- DUT
component fpga is
port (
clk, rst: in std_logic;
Data: inout std_logic_vector(7 downto 0);
Addr: in std_logic_vector(15 downto 0);
wr: in std_logic;
rd: in std_logic);
end component;
signal clk, rst: std_logic;
-- Bus signals
signal Data: std_logic_vector(7 downto 0);
signal Addr: std_logic_vector(15 downto 0);
signal rd: std_logic;
signal wr: std_logic;
begin
dut: fpga
port map (
clk => clk,
rst => rst,
Data => Data,
Addr => Addr,
wr => wr,
rd => rd
);
mcu1: mcu
port map (
clk => clk,
rst => rst,
Data => Data,
Addr => Addr,
wr => wr,
rd => rd
);
process
begin
clk <= '0';
wait for 0.5 us;
clk <= '1';
wait for 0.5 us;
end process;
stimulus: process
begin
rst <= '1', '0' after 1 us;
-- A list of nice, easy-to-read procedure calls to control the MCU
-- Defined in package mcu_sim: procedure buswrite(data: in std_logic_vector(7 downto 0); addr: in std_logic_vector(15 downto 0));
buswrite(X"01", X"0000"); -- Command for mcu to take control of bus and do a write operation to the fpga
buswrite(X"02", X"0001"); -- Command for mcu to take control of bus and do a write operation to the fpga
wait;
end process;
end a;
mcu_sim 包将包含模拟 MCU 总线操作所需的一切,我可以使用过程调用轻松地定制我的刺激程序。我意识到它需要程序来控制 mcu1 内部发生的事情。是否有可能做到这一点?
如果不是,您将如何为测试刺激制定可重复使用的程序?