Hello,
I want to design a "fullbuffer" to better handle image operators like
sobel on a fpga. It is designed to be generic, so that the mask height,
mask width (used to define the pixels the local operator is executed
on), the pixel data width and the width of the image (in this case
mask_width + linebuffer_length = image width) can be tuned. I have
attached an image to better demonstrate the functionality (The example
uses a 3x3 mask and therefore 2 linebuffers to cache needed pixels). If
necessary I can describe the functionality in more detail. Unfortunately
there is a bus conflict while writing the "mask_ffs" signal (a 2d array
that is forming the flipflops of the mask) in the for generate loop,
which is instantiating the linebuffers (specificly in the line that
says: "dout => mask_ffs(i+1, 0)" ). I could not detect any mistakes in
my indices, or my coding.
I would be very thankful if you could help me figure out the mistake.
1 | library ieee;
|
2 | use ieee.std_logic_1164.all;
|
3 | --use ieee.numeric_std.all;
|
4 |
|
5 | use work.utils.all;
|
6 | -- defines constants for generics and type "generic_port_matrix" a 2d array(mask_height-1 downto 0, mask_width-1 downto 0) of std_logic_vector(data_width-1 downto 0) (first the y coord and then the x coord, with 0, 0 in the bottom right corner if you are using the attached image as reference)
|
7 |
|
8 | entity fullbuffer is
|
9 | generic (
|
10 | linebuffer_length : integer := linebuffer_length;
|
11 | data_width : integer := data_width;
|
12 | mask_width : integer := mask_width;
|
13 | mask_height : integer := mask_height
|
14 | );
|
15 | port (
|
16 | clk : in std_logic;
|
17 | we : in std_logic;
|
18 | din : in std_logic_vector(data_width-1 downto 0);
|
19 | dout : out generic_port_matrix
|
20 | );
|
21 | end fullbuffer;
|
22 |
|
23 |
|
24 | architecture fullbuffer_arch of fullbuffer is
|
25 |
|
26 | signal mask_ffs : generic_port_matrix;
|
27 |
|
28 | type generic_vector is array(mask_height-1 downto 0) of std_logic_vector(data_width-1 downto 0);
|
29 | signal mask_out : generic_vector;
|
30 |
|
31 | begin
|
32 |
|
33 | -- output mask
|
34 | dout <= mask_ffs;
|
35 |
|
36 | -- instantiate the linebuffers
|
37 | line_generate:
|
38 | for i in 0 to mask_height-2 generate
|
39 |
|
40 | linebuffer: entity work.linebuffer
|
41 | generic map (
|
42 | length => linebuffer_length,
|
43 | data_width => data_width
|
44 | )
|
45 | port map (
|
46 | clk => clk, -- in
|
47 | we => we, -- in
|
48 | din => mask_out(i), -- in
|
49 | dout => mask_ffs(i+1, 0) -- out
|
50 | );
|
51 |
|
52 | end generate line_generate;
|
53 |
|
54 |
|
55 | process (clk)
|
56 | begin
|
57 | if (clk'event and clk = '1') then
|
58 | if (we = '1') then
|
59 |
|
60 | -- shift registers of mask
|
61 | for i in 0 to mask_height-1 loop
|
62 | for j in 0 to mask_width-2 loop
|
63 | mask_ffs(i, j+1) <= mask_ffs(i, j);
|
64 | end loop;
|
65 |
|
66 | mask_out(i) <= mask_ffs(i, mask_width-1);
|
67 | end loop;
|
68 |
|
69 | -- input new pixel from sensor
|
70 | mask_ffs(0, 0) <= din;
|
71 | end if;
|
72 | end if;
|
73 | end process;
|
74 |
|
75 | end fullbuffer_arch;
|