是否可以使用Verilog测试Bench VHDL设计
我正在尝试在Verilog中测试VHDL设计。我正在使用QuestA,但我不确定如何将信号从VHDL设计导入到Verilog TestBench中。到目前为止,这是我的代码。我还应该提到我知道signal_spy(),但是我无法使用它,因为这取决于可能在项目中改变的特定变量的路径。
Verilog TestBench:
`include "tb_zb01.vh"
`timescale 1 ns / 1 ns
module tb_zb01;
//***************************************************************************
// test bench signals
//***************************************************************************
reg clk100;
reg rst_sync_100;
//***************************************************************************
// clock generation, 100 MHz
//***************************************************************************
initial begin
clk100=0;
forever begin
#5; clk100 = ~clk100;
end
end
//***************************************************************************
// generate a reset in the all domains
//***************************************************************************
initial begin
rst_sync_100<=0;
repeat (10) @(posedge clk100);
@(posedge clk100) rst_sync_100 <= 1;
repeat (21) @(posedge clk100);
@(posedge clk100) rst_sync_100 <= 0;
end
//***************************************************************************
// this is the DUT
//***************************************************************************
zb01_top dut(
// misc
.i_clk100 ( clk100 ),
.i_rst_sync_100 (rst_sync_100)
);
endmodule // tb_zb01
VHDL设计:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.epack.all;
entity zb01_top is
generic(
SUPER_SECRET_RUN_FAST : integer := 1
);
port(
-- Outputs
o_led_drv_01 : out std_logic;
-- Inputs
i_clk100 : in std_logic;
i_rst_sync_100 : in std_logic
);
end entity;
architecture rtl of zb01_top is
signal counter: natural range 0 to 100000000 := 0;
signal alive : std_logic := ZERO;
begin
process(i_clk100)
begin
if (i_clk100'event and i_clk100 = ONE) then
if (i_rst_sync_100 = ONE) then
counter <= 0;
alive <= ZERO;
else
if (counter = (HALF_CYCLE - 1)) then
alive <= not alive;
counter <= 0;
else
counter <= counter + 1;
end if;
end if;
end if;
end process;
o_led_drv_01 <= alive;
end architecture;
I am trying to testbench a VHDL Design in Verilog. I am using Questa but I am unsure how to import the signals from the VHDL Design into the Verilog testbench if that is possible. Here is my code so far. I also should mention I am aware of signal_spy() but I am unable to use this because this relies on the path of specific variables which might change in my project.
Verilog testbench:
`include "tb_zb01.vh"
`timescale 1 ns / 1 ns
module tb_zb01;
//***************************************************************************
// test bench signals
//***************************************************************************
reg clk100;
reg rst_sync_100;
//***************************************************************************
// clock generation, 100 MHz
//***************************************************************************
initial begin
clk100=0;
forever begin
#5; clk100 = ~clk100;
end
end
//***************************************************************************
// generate a reset in the all domains
//***************************************************************************
initial begin
rst_sync_100<=0;
repeat (10) @(posedge clk100);
@(posedge clk100) rst_sync_100 <= 1;
repeat (21) @(posedge clk100);
@(posedge clk100) rst_sync_100 <= 0;
end
//***************************************************************************
// this is the DUT
//***************************************************************************
zb01_top dut(
// misc
.i_clk100 ( clk100 ),
.i_rst_sync_100 (rst_sync_100)
);
endmodule // tb_zb01
VHDL Design:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.epack.all;
entity zb01_top is
generic(
SUPER_SECRET_RUN_FAST : integer := 1
);
port(
-- Outputs
o_led_drv_01 : out std_logic;
-- Inputs
i_clk100 : in std_logic;
i_rst_sync_100 : in std_logic
);
end entity;
architecture rtl of zb01_top is
signal counter: natural range 0 to 100000000 := 0;
signal alive : std_logic := ZERO;
begin
process(i_clk100)
begin
if (i_clk100'event and i_clk100 = ONE) then
if (i_rst_sync_100 = ONE) then
counter <= 0;
alive <= ZERO;
else
if (counter = (HALF_CYCLE - 1)) then
alive <= not alive;
counter <= 0;
else
counter <= counter + 1;
end if;
end if;
end if;
end process;
o_led_drv_01 <= alive;
end architecture;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论