G
G Iveco
Guest
Hello all,
I am studying VHDL and came across this problem..
Basically my idea is to write signal "filt" into a file and compare with
reference data.
It worked in RTL but failed in gate-level netlists.
Thank you!
-- Here is declaration part of RTL code.
entity coms_fir is
generic(DATA_WIDTH : integer :=10);
port (
clk_in : in std_logic;
rstn_in : in std_logic;
adc_ena_in : in std_logic;
adc_in : in signed(DATA_WIDTH-1 downto 0);
agc_gain_in : in signed(2 downto 0); -- gain up of 1, 2, 4, 8, ... 128
filt_rdy_out : out std_logic;
filt_out : out signed(DATA_WIDTH-1 downto 0)
);
end coms_fir;
-- Here is declaration of synthesized netlist out of Xilinx.
-- In RTL design, agc_gain_in, adc_in and filt_out are Signed.
-- which are changed to std_logic_vector.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
library SIMPRIM;
use SIMPRIM.VCOMPONENTS.ALL;
use SIMPRIM.VPACKAGE.ALL;
entity coms_fir is
port (
clk_in : in STD_LOGIC := 'X';
adc_ena_in : in STD_LOGIC := 'X';
rstn_in : in STD_LOGIC := 'X';
filt_rdy_out : out STD_LOGIC;
agc_gain_in : in STD_LOGIC_VECTOR ( 2 downto 0 );
adc_in : in STD_LOGIC_VECTOR ( 9 downto 0 );
filt_out : out STD_LOGIC_VECTOR ( 9 downto 0 )
);
end coms_fir;
-- Here is my testbench file.
-- I used To_StdLogicVector() to convert agc_gain_in and adc_in..
-- Now the "write" statement can't accept signal "filt"..
library IEEE;
LIBRARY std_developerskit;
use IEEE.std_logic_1164.all;
use IEEE.numeric_bit.all;
use std.textio.all;
-- use ieee.math_real.uniform;
USE std_developerskit.std_iopak.all;
entity coms_fir_sim is
end coms_fir_sim;
architecture a of coms_fir_sim is
constant DATA_WIDTH : INTEGER :=10;
CONSTANT CLOCK_PERIOD : TIME := 10 ns;
signal clk, rstn : std_logic;
signal adc_ena : std_logic;
signal adc : bit_vector(DATA_WIDTH-1 downto 0);
signal agc_gain : bit_vector(2 downto 0); -- gain up of 1, 2, 4, 8, ...
128
signal filt_rdy : std_logic;
signal filt : std_logic_vector(DATA_WIDTH-1 downto 0);
signal sum_of_prod : bit_vector(DATA_WIDTH+8 downto 0); -- 19-bit
signal sim_status : bit_vector(3 downto 0);
--subtype filt_op is string(1 to 3):=(others=>'0');
--type hex_file is file of filt_op;
--file file_filt_out : hex_file;
-- FILE file_filt_out : hex_file;
-- VARIABLE hex_str : string(1 to 3):=(others=>'0');
file log : text open write_mode is "filt_out.dat";
begin
i_coms_fir: entity work.coms_fir(filt)
-- generic map(DATA_WIDTH)
port map(
clk_in => clk ,
rstn_in => rstn ,
adc_ena_in => adc_ena ,
adc_in => To_StdLogicVector(adc) ,
agc_gain_in => To_StdLogicVector(agc_gain) ,
filt_rdy_out => filt_rdy ,
filt_out => filt
);
feed_data: process is
variable i : integer;
-- FILE file_fir_o : ASCII_TEXT IS "../DAT/fir_out_7.DAT";
variable var_tmp : string(1 to 3);
variable var_tmp_bv : bit_vector (11 downto 0);
variable data_length : bit_vector (11 downto 0);
procedure rcv_data( file_in: in string(1 to 19);
file_out: in string(1 to 25)
) is
FILE file_adc_i : ASCII_TEXT IS file_in;
begin
sim_status <= x"0";
adc_ena <= '0';
-- file_open(file_filt_out, file_out, write_mode);
for i in 1 to 10 loop
wait until clk = '1';
end loop;
fscan (file_adc_i, "%x", var_tmp);
var_tmp_bv := From_HexString(var_tmp);
agc_gain <= var_tmp_bv(2 downto 0);
wait until clk = '1';
fscan (file_adc_i, "%x", var_tmp);
var_tmp_bv := From_HexString(var_tmp);
data_length := var_tmp_bv;
wait until clk = '1';
while NOT endfile(file_adc_i) loop
fscan (file_adc_i, "%x", var_tmp);
var_tmp_bv := From_HexString(var_tmp);
adc <= var_tmp_bv(DATA_WIDTH-1 downto 0);
adc_ena <= '1';
wait until clk = '1';
end loop;
sim_status <= x"1";
for i in 1 to 10 loop
wait until clk = '1';
end loop;
-- file_close(file_filt_out);
sim_status <= x"2";
for i in 1 to 10 loop
wait until clk = '1';
end loop;
sim_status <= x"3";
end procedure rcv_data;
begin
rcv_data("../DAT/adc_in_0.dat", "../DAT/filt_out_sim_0.dat");
rcv_data("../DAT/adc_in_1.dat", "../DAT/filt_out_sim_1.dat");
rcv_data("../DAT/adc_in_2.dat", "../DAT/filt_out_sim_2.dat");
rcv_data("../DAT/adc_in_3.dat", "../DAT/filt_out_sim_3.dat");
rcv_data("../DAT/adc_in_4.dat", "../DAT/filt_out_sim_4.dat");
rcv_data("../DAT/adc_in_5.dat", "../DAT/filt_out_sim_5.dat");
rcv_data("../DAT/adc_in_6.dat", "../DAT/filt_out_sim_6.dat");
rcv_data("../DAT/adc_in_7.dat", "../DAT/filt_out_sim_7.dat");
report "Simulation completed now! "
severity FAILURE;
sim_status <= x"3";
end process feed_data;
process(clk)
variable trace_line : line;
begin
if rising_edge(clk) then
if filt_rdy = '1' then
-- hex_str := To_string(filt,"%3x");
-- fprint(file_filt_out,"%s\n", hex_str);
write(trace_line, to_integer(filt)); -- Modelsim Error Here!
writeline(log, trace_line);
end if;
end if;
end process;
process(clk, rstn)
begin
if rstn = '0' then
sum_of_prod <= (others=>'0');
elsif rising_edge(clk) then
sum_of_prod <=
b"0000_0000_0000_0000_000"; --to_bitvector(i_coms_fir(filt).sum_of_prod);
end if;
end process;
--------------------------------------------------------------------
-- clock and reset stuff
--------------------------------------------------------------------
clock : process
begin
clk <= '1' ;
wait for CLOCK_PERIOD/2;
clk <= '0' ;
wait for CLOCK_PERIOD/2;
end process clock;
reset : process
begin
rstn<='0';
wait for 5*CLOCK_PERIOD;
rstn<='1';
wait;
end process reset;
end a;
I am studying VHDL and came across this problem..
Basically my idea is to write signal "filt" into a file and compare with
reference data.
It worked in RTL but failed in gate-level netlists.
Thank you!
-- Here is declaration part of RTL code.
entity coms_fir is
generic(DATA_WIDTH : integer :=10);
port (
clk_in : in std_logic;
rstn_in : in std_logic;
adc_ena_in : in std_logic;
adc_in : in signed(DATA_WIDTH-1 downto 0);
agc_gain_in : in signed(2 downto 0); -- gain up of 1, 2, 4, 8, ... 128
filt_rdy_out : out std_logic;
filt_out : out signed(DATA_WIDTH-1 downto 0)
);
end coms_fir;
-- Here is declaration of synthesized netlist out of Xilinx.
-- In RTL design, agc_gain_in, adc_in and filt_out are Signed.
-- which are changed to std_logic_vector.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
library SIMPRIM;
use SIMPRIM.VCOMPONENTS.ALL;
use SIMPRIM.VPACKAGE.ALL;
entity coms_fir is
port (
clk_in : in STD_LOGIC := 'X';
adc_ena_in : in STD_LOGIC := 'X';
rstn_in : in STD_LOGIC := 'X';
filt_rdy_out : out STD_LOGIC;
agc_gain_in : in STD_LOGIC_VECTOR ( 2 downto 0 );
adc_in : in STD_LOGIC_VECTOR ( 9 downto 0 );
filt_out : out STD_LOGIC_VECTOR ( 9 downto 0 )
);
end coms_fir;
-- Here is my testbench file.
-- I used To_StdLogicVector() to convert agc_gain_in and adc_in..
-- Now the "write" statement can't accept signal "filt"..
library IEEE;
LIBRARY std_developerskit;
use IEEE.std_logic_1164.all;
use IEEE.numeric_bit.all;
use std.textio.all;
-- use ieee.math_real.uniform;
USE std_developerskit.std_iopak.all;
entity coms_fir_sim is
end coms_fir_sim;
architecture a of coms_fir_sim is
constant DATA_WIDTH : INTEGER :=10;
CONSTANT CLOCK_PERIOD : TIME := 10 ns;
signal clk, rstn : std_logic;
signal adc_ena : std_logic;
signal adc : bit_vector(DATA_WIDTH-1 downto 0);
signal agc_gain : bit_vector(2 downto 0); -- gain up of 1, 2, 4, 8, ...
128
signal filt_rdy : std_logic;
signal filt : std_logic_vector(DATA_WIDTH-1 downto 0);
signal sum_of_prod : bit_vector(DATA_WIDTH+8 downto 0); -- 19-bit
signal sim_status : bit_vector(3 downto 0);
--subtype filt_op is string(1 to 3):=(others=>'0');
--type hex_file is file of filt_op;
--file file_filt_out : hex_file;
-- FILE file_filt_out : hex_file;
-- VARIABLE hex_str : string(1 to 3):=(others=>'0');
file log : text open write_mode is "filt_out.dat";
begin
i_coms_fir: entity work.coms_fir(filt)
-- generic map(DATA_WIDTH)
port map(
clk_in => clk ,
rstn_in => rstn ,
adc_ena_in => adc_ena ,
adc_in => To_StdLogicVector(adc) ,
agc_gain_in => To_StdLogicVector(agc_gain) ,
filt_rdy_out => filt_rdy ,
filt_out => filt
);
feed_data: process is
variable i : integer;
-- FILE file_fir_o : ASCII_TEXT IS "../DAT/fir_out_7.DAT";
variable var_tmp : string(1 to 3);
variable var_tmp_bv : bit_vector (11 downto 0);
variable data_length : bit_vector (11 downto 0);
procedure rcv_data( file_in: in string(1 to 19);
file_out: in string(1 to 25)
) is
FILE file_adc_i : ASCII_TEXT IS file_in;
begin
sim_status <= x"0";
adc_ena <= '0';
-- file_open(file_filt_out, file_out, write_mode);
for i in 1 to 10 loop
wait until clk = '1';
end loop;
fscan (file_adc_i, "%x", var_tmp);
var_tmp_bv := From_HexString(var_tmp);
agc_gain <= var_tmp_bv(2 downto 0);
wait until clk = '1';
fscan (file_adc_i, "%x", var_tmp);
var_tmp_bv := From_HexString(var_tmp);
data_length := var_tmp_bv;
wait until clk = '1';
while NOT endfile(file_adc_i) loop
fscan (file_adc_i, "%x", var_tmp);
var_tmp_bv := From_HexString(var_tmp);
adc <= var_tmp_bv(DATA_WIDTH-1 downto 0);
adc_ena <= '1';
wait until clk = '1';
end loop;
sim_status <= x"1";
for i in 1 to 10 loop
wait until clk = '1';
end loop;
-- file_close(file_filt_out);
sim_status <= x"2";
for i in 1 to 10 loop
wait until clk = '1';
end loop;
sim_status <= x"3";
end procedure rcv_data;
begin
rcv_data("../DAT/adc_in_0.dat", "../DAT/filt_out_sim_0.dat");
rcv_data("../DAT/adc_in_1.dat", "../DAT/filt_out_sim_1.dat");
rcv_data("../DAT/adc_in_2.dat", "../DAT/filt_out_sim_2.dat");
rcv_data("../DAT/adc_in_3.dat", "../DAT/filt_out_sim_3.dat");
rcv_data("../DAT/adc_in_4.dat", "../DAT/filt_out_sim_4.dat");
rcv_data("../DAT/adc_in_5.dat", "../DAT/filt_out_sim_5.dat");
rcv_data("../DAT/adc_in_6.dat", "../DAT/filt_out_sim_6.dat");
rcv_data("../DAT/adc_in_7.dat", "../DAT/filt_out_sim_7.dat");
report "Simulation completed now! "
severity FAILURE;
sim_status <= x"3";
end process feed_data;
process(clk)
variable trace_line : line;
begin
if rising_edge(clk) then
if filt_rdy = '1' then
-- hex_str := To_string(filt,"%3x");
-- fprint(file_filt_out,"%s\n", hex_str);
write(trace_line, to_integer(filt)); -- Modelsim Error Here!
writeline(log, trace_line);
end if;
end if;
end process;
process(clk, rstn)
begin
if rstn = '0' then
sum_of_prod <= (others=>'0');
elsif rising_edge(clk) then
sum_of_prod <=
b"0000_0000_0000_0000_000"; --to_bitvector(i_coms_fir(filt).sum_of_prod);
end if;
end process;
--------------------------------------------------------------------
-- clock and reset stuff
--------------------------------------------------------------------
clock : process
begin
clk <= '1' ;
wait for CLOCK_PERIOD/2;
clk <= '0' ;
wait for CLOCK_PERIOD/2;
end process clock;
reset : process
begin
rstn<='0';
wait for 5*CLOCK_PERIOD;
rstn<='1';
wait;
end process reset;
end a;