P
ppk.mymail
Hi, my friends,
I have a problem when I try to output a data from ROM every 20 clocks.
The code works fine in behavioral level simulation but not correct in
Post-Route simulation.
Please help me!
library ieee ;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity testDriver is
generic(
M_COUNTER : integer := 20;
M_DATASIZE : integer := 4 -- test bench ROM size
);
port( clk_in: in std_logic; -- system clock
en_in: in std_logic:= '1' ; -- enable signal
en_clr_in: in std_logic:= '0'; -- reset signal
clk_out: out std_logic; -- output system clock
en_out: out std_logic ; -- clock enable signal. Set it to '1'
en_clr_out: out std_logic ; -- reset signal. Set it to '0'
bin_data_out: out std_logic; -- Data from ROM
init_en_out: out std_logic; -- Set it to '1'
const_out: out std_logic -- Set it to '0'
);
end testDriver;
----------------------------------------------------
architecture behv_testDriver of testDriver is
--ROM. Save test data.
type ROM250by1 is array (0 to M_DATASIZE-1) of std_logic; --
totally 250
constant rom_data: ROM250by1 := ('1','0','1','0');
-- index of data in the ROM
signal nIndexBuf : integer := 0;
-- counter
signal nCounterBuf: integer := 0;
-- temp signal for input
signal clk_tmp : std_logic ;
signal en_tmp : std_logic ;
signal en_clr_tmp : std_logic;
signal out_tmp : std_logic := '0';
-- use as counter clear signal, index clear signal
signal clr_257 : std_logic := '0' ;
begin
clk_tmp <= clk_in;
en_tmp <= en_in;
en_clr_tmp <= en_clr_in;
out_tmp <= rom_data(nIndexBuf);
clk_out <= clk_tmp;
en_out <= en_tmp;
en_clr_out <= en_clr_tmp;
bin_data_out <= out_tmp;
const_out <= '1' ;
coun257_gen: process(clk_tmp)
begin
if clk_tmp'event and clk_tmp = '1' then
if (en_tmp = '1') then
if (en_clr_tmp = '1' or clr_257 = '1') then
nCounterBuf <= 0;
else
nCounterBuf <= nCounterBuf + 1;
end if; -- clear
end if; -- enable
end if; -- clock
end process;
clr257_gen: process(en_clr_tmp,nCounterBuf)
begin
if (en_clr_tmp = '1') then
clr_257 <= '1';
elsif nCounterBuf = M_COUNTER - 1 then
clr_257 <= '1';
else
clr_257 <= '0';
end if; -- clock
end process;
data_output: process(nCounterBuf, en_clr_tmp)
begin
if (en_clr_tmp = '1')then
nIndexBuf <= 0 ;
else
nIndexBuf <= (nIndexBuf+1) mod M_DATASIZE;
end if; -- clock
end process;
init_en_out <= '0';
end behv_testDriver;
I have a problem when I try to output a data from ROM every 20 clocks.
The code works fine in behavioral level simulation but not correct in
Post-Route simulation.
Please help me!
library ieee ;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity testDriver is
generic(
M_COUNTER : integer := 20;
M_DATASIZE : integer := 4 -- test bench ROM size
);
port( clk_in: in std_logic; -- system clock
en_in: in std_logic:= '1' ; -- enable signal
en_clr_in: in std_logic:= '0'; -- reset signal
clk_out: out std_logic; -- output system clock
en_out: out std_logic ; -- clock enable signal. Set it to '1'
en_clr_out: out std_logic ; -- reset signal. Set it to '0'
bin_data_out: out std_logic; -- Data from ROM
init_en_out: out std_logic; -- Set it to '1'
const_out: out std_logic -- Set it to '0'
);
end testDriver;
----------------------------------------------------
architecture behv_testDriver of testDriver is
--ROM. Save test data.
type ROM250by1 is array (0 to M_DATASIZE-1) of std_logic; --
totally 250
constant rom_data: ROM250by1 := ('1','0','1','0');
-- index of data in the ROM
signal nIndexBuf : integer := 0;
-- counter
signal nCounterBuf: integer := 0;
-- temp signal for input
signal clk_tmp : std_logic ;
signal en_tmp : std_logic ;
signal en_clr_tmp : std_logic;
signal out_tmp : std_logic := '0';
-- use as counter clear signal, index clear signal
signal clr_257 : std_logic := '0' ;
begin
clk_tmp <= clk_in;
en_tmp <= en_in;
en_clr_tmp <= en_clr_in;
out_tmp <= rom_data(nIndexBuf);
clk_out <= clk_tmp;
en_out <= en_tmp;
en_clr_out <= en_clr_tmp;
bin_data_out <= out_tmp;
const_out <= '1' ;
coun257_gen: process(clk_tmp)
begin
if clk_tmp'event and clk_tmp = '1' then
if (en_tmp = '1') then
if (en_clr_tmp = '1' or clr_257 = '1') then
nCounterBuf <= 0;
else
nCounterBuf <= nCounterBuf + 1;
end if; -- clear
end if; -- enable
end if; -- clock
end process;
clr257_gen: process(en_clr_tmp,nCounterBuf)
begin
if (en_clr_tmp = '1') then
clr_257 <= '1';
elsif nCounterBuf = M_COUNTER - 1 then
clr_257 <= '1';
else
clr_257 <= '0';
end if; -- clock
end process;
data_output: process(nCounterBuf, en_clr_tmp)
begin
if (en_clr_tmp = '1')then
nIndexBuf <= 0 ;
else
nIndexBuf <= (nIndexBuf+1) mod M_DATASIZE;
end if; -- clock
end process;
init_en_out <= '0';
end behv_testDriver;