sreevenkjan
Full Member level 5
- Joined
- Nov 4, 2013
- Messages
- 268
- Helped
- 27
- Reputation
- 54
- Reaction score
- 26
- Trophy points
- 1,308
- Location
- Germany
- Activity points
- 3,115
Then I assume the input to the ILA is reading "3FFF". The problem will be further upstream. The ILA isnt broken.
Basically, the problem will be in the logic connected to the ILA. There is no problem with the ILA.
Are the inputs on hardware the same as in simulation? is something stuck in a reset state? has logic been removed?
when count_output =>
count1 <= counter_array(conv_integer(count_loop));
if count1 > prev_count then
biggest_count <= count1;
count_number <= count_loop - "1";
else
biggest_count <= prev_count;
end if;
prev_count := biggest_count;
count_loop <= count_loop + "1";
--data_out <= label_pixel_start(conv_integer(count_number)) & label_pixel_end(conv_integer(count_number));
if count_loop = label_number then
row_addr <= "000000000";
count_loop <= "00000000";
biggest_count <= "00000000000000";
--state <= addr_increment;
--else
state <= count_output;
end if;
end case;
the arrays should have mapped to BRAMs - hence why I said you should be checking the RTL diagram to see if the hardware is as you expected. You also get a quick check if anything has been removed.
When are you capturing ILA data? does the system reset itself to create a neverending stream of data? are you sure you're not just capturing when data generation has finished?
Why not try connecting the ILA to the input data to ensure that is being generated correctly. I assume that, if you have no inputs other than a clock, source data comes from a ROM - has the compiler picked up the file to initialise the ROM correctly? are the address generators generating the read address correctly?
Basically, there is lots for you to look at. If you had a system where you could input and output data to a PC, you could input any data, read the output and use the ILA to debug the design (but the ILA would always be a last resort - you revert back to simulation wherever possible).
when col_filter =>
col_buf(0) <= row_out(col_count);
col_buf(8 downto 1) <= col_buf(7 downto 0);
col1 <= col_buf(0);
col2 <= col_buf(1);
col3 <= col_buf(2);
col4 <= col_buf(3);
col5 <= col_buf(4);
col6 <= col_buf(5);
col7 <= col_buf(6);
col8 <= col_buf(7);
col9 <= col_buf(8);
col_out <= col1 or col2 or col3 or col4 or col5 or col6 or col7 or col8 or col9;
delay_line(0) <= col_out;
delay_line(row_width + 1 downto 1) <= delay_line(row_width downto 0);
current_pixel <= delay_line(0);
left_pixel <= delay_line(1);
right_up_pixel <= delay_line(row_width - 1);
up_pixel <= delay_line(row_width);
left_up_pixel <= delay_line(row_width + 1);
if current_pixel = '0' then
id_label := "00000000";
elsif current_pixel = '1' then
if left_up_pixel = '0' and up_pixel = '0' and right_up_pixel = '0' and left_pixel = '0' then
if label_start = '0' then
id_label := "00000001";
label_start <= '1';
new_label <= id_label;
new_label_start <= '1';
label_pixel_start(conv_integer(id_label)) <= row_addr & conv_std_logic_vector(col_count + 1,10);
else
id_label := new_label + "1";
new_label <= id_label;
new_label_start <= '1';
label_pixel_start(conv_integer(id_label)) <= row_addr & conv_std_logic_vector(col_count + 1,10);
end if;
-- elsif left_pixel = '1' then
-- id_label := left_label;
-- new_label_start <= '0';
elsif left_pixel = '1' then
if right_up_pixel = '1' then
if left_label < right_up_label then
id_label := left_label;
else
id_label := right_up_label;
end if;
else
id_label := left_label;
end if;
elsif right_up_pixel = '1' then
id_label := right_up_label;
new_label_start <= '0';
elsif up_pixel = '1' then
id_label := up_label;
new_label_start <= '0';
elsif left_up_pixel = '1' then
id_label := left_up_label;
new_label_start <= '0';
end if;
end if;
current_label <= id_label;
if id_label > 0 then
label_pixel_end(conv_integer(id_label)) <= row_addr & conv_std_logic_vector(col_count + 1,10);
end if;
label_buffer(0) := id_label;
label_buffer(1 to row_width + 1) := label_buffer(0 to row_width);
left_up_label := label_buffer(row_width + 1);
up_label := label_buffer(row_width);
right_up_label := label_buffer(row_width - 1);
left_label := label_buffer(1);
if current_label > "0000000" then
count := counter_array(conv_integer(current_label));
count := count + "1";
counter_array(conv_integer(current_label)) <= count;
--else
--count := "00000000000000";
--counter_array(conv_integer(current_label)) <= count;
end if;
data_ready <= '0';
state <= filter_loop;
when filter_loop =>
output(col_count) <= col_out;
pixel_output <= col_out;
col_count <= col_count + 1;
if col_count = row_width-1 then
col_count <= 0;
data_ready <= '1';
--we <= "1";
--out_pixel <= output;
state <= addr_increment;
else
state <= col_filter;
end if;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity filter_mytop is
Port ( clk : in STD_LOGIC
--rstn : in STD_LOGIC
--data_out : out STD_LOGIC_VECTOR(37 downto 0)
);
end filter_mytop;
architecture Behavioral of filter_mytop is
-- Adding BRAM content
COMPONENT blk_pic5
PORT (
clka : IN STD_LOGIC;
wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
addra : IN STD_LOGIC_VECTOR(8 DOWNTO 0);
dina : IN STD_LOGIC_VECTOR(751 DOWNTO 0);
douta : OUT STD_LOGIC_VECTOR(751 DOWNTO 0)
);
END COMPONENT;
constant width : integer := 7;
constant row_width : integer := 752;
constant addr_width : integer := 9;
constant count_width : integer := 14;
constant label_number : integer := 200;
---- Adding ILA component
COMPONENT ila_1
PORT (
clk : IN STD_LOGIC;
probe0 : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
probe1 : IN STD_LOGIC_VECTOR(8 DOWNTO 0);
probe2 : IN STD_LOGIC_VECTOR(7 DOWNTO 0)
);
END COMPONENT;
-- Signal declarations for bram
signal we : std_logic_vector(0 downto 0);
signal row_addr : std_logic_VECTOR(8 downto 0);
signal row : std_logic_vector(751 downto 0);
signal out_pixel : std_logic_vector(751 downto 0);
-- State machine definitions for filter
type filter_state is (addr_increment,row_filter,col_filter,filter_loop,count_output);
signal state : filter_state := addr_increment;
-- Array buffer declaration for filter
type array_buffer is array(1 to 9) of STD_LOGIC_VECTOR(row_width-1 DOWNTO 0);
signal row_buf : array_buffer := (others=>(others=>'0'));
-- Array buffer declaration for label
type label_array is array(0 to row_width + 1) of std_logic_VECTOR(width downto 0);
-- Array declaration for pixel label location
type pixel_location is array(1 to label_number) of std_logic_VECTOR(addr_width*2 downto 0);
signal label_pixel_start,label_pixel_end : pixel_location := (others=>(others => '0'));
--Array declaration for label counter
type label_counter is array(1 to label_number) of std_logic_VECTOR(count_width-1 downto 0);
-- Signal declarations for counter labelling
signal counter_array : label_counter := (others=>(others => '0'));
signal count1,biggest_count,prev_count : std_logic_VECTOR(count_width-1 downto 0):= (others => '0');
signal count_loop : std_logic_vector(width downto 0) := "00000001";
signal count_number : std_logic_vector(width downto 0);
-- Signal declarations for filter
signal row1,row2,row3,row4,row5,row6,row7,row8,row9 : STD_LOGIC_VECTOR(row_width-1 DOWNTO 0):= (others => '0');
signal row_out,output,output_buf : STD_LOGIC_VECTOR(row_width-1 DOWNTO 0):= (others=>'0');
signal col_buf : std_logic_VECTOR(addr_width-1 downto 0):= (others=>'0');
signal col1,col2,col3,col4,col5,col6,col7,col8,col9,col_out : std_logic := '0';
signal data_ready : std_logic;
signal col_count : integer range 0 to row_width-1;
-- Signal declarations for component labelling
signal current_label : std_logic_VECTOR(width downto 0):= (others => '0');
signal current_pixel,left_pixel,up_pixel,right_up_pixel,left_up_pixel : std_logic := '0';
--signal new_label_start : std_logic;
signal delay_line : std_logic_vector(row_width + 1 downto 0) := (others => '0');
signal new_label : std_logic_vector(width downto 0);
signal data_out : STD_LOGIC_VECTOR(37 downto 0):= (others => '0');
-- Signal declarations for ILA
signal pixel_output : STD_LOGIC;
signal probe0_data : std_logic_vector( 1 downto 0 ) := "00";
signal reset_n : std_logic := '0';
signal reset_counter : integer range 0 to (10*1024*1024-1) := 0;
begin
--Instantiating BRAM.
bram : blk_pic5
port map(
clka => clk,
wea => we,
addra => row_addr,
dina => out_pixel,
douta => row);
-- Instantiating ILA
ila_system : ila_1
PORT MAP (
clk => clk,
probe0 => probe0_data,
probe1 => row_addr,
probe2 => current_label
);
probe0_data <= pixel_output & reset_n;
reset_gen : process (clk)
begin
if rising_edge(clk) then
reset_counter <= reset_counter + 1;
if reset_counter > 10000000 then
reset_counter <= 0;
reset_n <= not reset_n;
end if;
end if;
end process;
-- Filtering Process
dilation_filter : process(clk)
variable label_buffer : label_array := (others=>(others => '0'));
variable id_label : std_logic_vector(width downto 0):= (others => '0');
variable left_label : std_logic_vector(width downto 0) := (others => '0');
variable up_label : std_logic_vector(width downto 0) := (others => '0');
variable right_up_label : std_logic_vector(width downto 0) := (others => '0');
variable left_up_label : std_logic_vector(width downto 0) := (others => '0');
variable count,count_val : std_logic_vector(count_width-1 downto 0);
begin
if rising_edge(clk) then
if reset_n='0' then
state <= addr_increment;
row1 <= (others => '0');
row2 <= (others => '0');
row3 <= (others => '0');
row4 <= (others => '0');
row5 <= (others => '0');
row6 <= (others => '0');
row7 <= (others => '0');
row8 <= (others => '0');
row9 <= (others => '0');
--rst <= '1';
row_addr <= "000000000";
state <= addr_increment;
else
case state is
when addr_increment =>
we <= "0";
row_addr <= row_addr + "000000001";
--if row_addr = "111011110" then --- row = 478
if row_addr = "111100000" then --- row 480
--rst <= '1';
row_addr <= "000000000";
--state <= addr_increment;
data_ready <= '0';
state <= count_output;
else
data_ready <= '0';
state <= row_filter;
end if;
when row_filter =>
row_buf(1) <= row;
-- for i in 1 to 8 loop
-- row_buf(i+1) <= row_buf(i)
-- end loop;
row_buf(2) <= row_buf(1);
row_buf(3) <= row_buf(2);
row_buf(4) <= row_buf(3);
row_buf(5) <= row_buf(4);
row_buf(6) <= row_buf(5);
row_buf(7) <= row_buf(6);
row_buf(8) <= row_buf(7);
row_buf(9) <= row_buf(8);
row1 <= row_buf(1);
row2 <= row_buf(2);
row3 <= row_buf(3);
row4 <= row_buf(4);
row5 <= row_buf(5);
row6 <= row_buf(6);
row7 <= row_buf(7);
row8 <= row_buf(8);
row9 <= row_buf(9);
row_out <= row1 or row2 or row3 or row4 or row5 or row6 or row7 or row8 or row9;
state <= col_filter;
when col_filter =>
col_buf(0) <= row_out(col_count);
col_buf(8 downto 1) <= col_buf(7 downto 0);
col1 <= col_buf(0);
col2 <= col_buf(1);
col3 <= col_buf(2);
col4 <= col_buf(3);
col5 <= col_buf(4);
col6 <= col_buf(5);
col7 <= col_buf(6);
col8 <= col_buf(7);
col9 <= col_buf(8);
col_out <= col1 or col2 or col3 or col4 or col5 or col6 or col7 or col8 or col9;
-- labelling part of the algorithm starts
delay_line(0) <= col_out;
delay_line(row_width + 1 downto 1) <= delay_line(row_width downto 0);
current_pixel <= delay_line(0);
left_pixel <= delay_line(1);
right_up_pixel <= delay_line(row_width - 1);
up_pixel <= delay_line(row_width);
left_up_pixel <= delay_line(row_width + 1);
if current_pixel = '0' then
id_label := "00000000";
elsif current_pixel = '1' then
if left_up_pixel = '0' and up_pixel = '0' and right_up_pixel = '0' and left_pixel = '0' then
id_label := new_label + "1";
new_label <= id_label;
--new_label_start <= '1';
label_pixel_start(conv_integer(id_label)) <= row_addr & conv_std_logic_vector(col_count + 1,10);
-- elsif left_pixel = '1' then
-- id_label := left_label;
-- new_label_start <= '0';
elsif left_pixel = '1' then
if right_up_pixel = '1' then
if left_label < right_up_label then
id_label := left_label;
else
id_label := right_up_label;
end if;
else
id_label := left_label;
end if;
elsif right_up_pixel = '1' then
id_label := right_up_label;
--new_label_start <= '0';
elsif up_pixel = '1' then
id_label := up_label;
--new_label_start <= '0';
elsif left_up_pixel = '1' then
id_label := left_up_label;
--new_label_start <= '0';
end if;
end if;
current_label <= id_label;
if id_label > 0 then
label_pixel_end(conv_integer(id_label)) <= row_addr & conv_std_logic_vector(col_count + 1,10);
end if;
label_buffer(0) := id_label;
label_buffer(1 to row_width + 1) := label_buffer(0 to row_width);
left_up_label := label_buffer(row_width + 1);
up_label := label_buffer(row_width);
right_up_label := label_buffer(row_width - 1);
left_label := label_buffer(1);
if current_label > "0000000" then
count_val := counter_array(conv_integer(current_label));
count := count_val + "1";
counter_array(conv_integer(current_label)) <= count;
end if;
data_ready <= '0';
state <= filter_loop;
when filter_loop =>
output(col_count) <= col_out;
pixel_output <= col_out;
col_count <= col_count + 1;
if col_count = row_width-1 then
col_count <= 0;
data_ready <= '1';
--we <= "1";
--out_pixel <= output;
state <= addr_increment;
else
state <= col_filter;
end if;
when count_output =>
count1 <= counter_array(conv_integer(count_loop));
if count1 > prev_count then
biggest_count <= count1;
count_number <= count_loop - "1";
else
biggest_count <= prev_count;
end if;
prev_count <= biggest_count;
count_loop <= count_loop + "1";
--data_out <= label_pixel_start(conv_integer(count_number)) & label_pixel_end(conv_integer(count_number));
if count_loop = label_number then
state <= addr_increment;
else
state <= count_output;
end if;
end case;
end if; -- reset
end if; -- clock
end process dilation_filter;
end Behavioral;
I am not able to find the counter_array and label_pixel_start and label_pixel_End in my elaborated design..is it because I am using arrays as look up tables?..If replacing it by BRAM would solve my issue??but if i use BRAM i would be needing 2 clock cycles for reading and writing..so is there a way to avoid it??..
Hi TrickyDicky,
I am able to observe the pixel_output in the ILA which is nothing but my col_out i.e my filtered pixel data.
but what i am not able to observe is the biggest count signal data which gives me random values.
can you tell me why is it happening differently for pixel_output which is on probe0 which i am able to observe??
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?