Skip to content

Commit 0618261

Browse files
authored
Register outputs t maintain value until next frame (#173)
1 parent ea63c0c commit 0618261

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

sim_fpga/examples/poc/example6/rtl/centroid.v

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,10 @@ module centroid
261261
end
262262
else begin
263263
new_centroid_o <= new_frame_proc_i;
264-
centroid_o <= centroid_tmp;
265-
proximity_o <= proximity_tmp;
264+
if (new_frame_proc_i == 1'b1) begin
265+
centroid_o <= centroid_tmp;
266+
proximity_o <= proximity_tmp;
267+
end
266268
end
267269
end
268270

sim_fpga/examples/poc/example6/rtl/tb_design_top.vhd

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ ARCHITECTURE behavior OF tb_design_top IS
3333
constant c_img_pxls : natural := c_img_cols * c_img_rows;
3434
-- $clog2(c_img_pxls), //160*120=19200 -> 2^15
3535
constant c_nb_img_pxls :natural := 15;
36+
constant c_nb_img_cols :natural := 8; -- 8 bits to count 160
3637

3738
signal cnt_pxl : unsigned(c_nb_img_pxls-1 downto 0);
39+
signal cnt_col : unsigned(c_nb_img_cols-1 downto 0);
3840
--Inputs
3941
signal clk : std_logic := '0';
4042
signal rst : std_logic := '0';
@@ -95,6 +97,7 @@ BEGIN
9597
pxl_proc: process
9698
begin
9799
cnt_pxl <= (others => '0');
100+
cnt_col <= (others => '0');
98101
capture_newframe <= '0';
99102
wea <= '0';
100103
wait until rst = '0';
@@ -103,6 +106,12 @@ BEGIN
103106
capture_newframe <= '0';
104107
wea <= '1';
105108
wait until clk'event and clk = '1';
109+
if cnt_col < c_img_cols-1 then
110+
cnt_col <= cnt_col + 1;
111+
else
112+
cnt_col <= (others => '0');
113+
end if;
114+
106115
if cnt_pxl < c_img_pxls-1 then
107116
cnt_pxl <= cnt_pxl + 1;
108117
else
@@ -115,7 +124,9 @@ BEGIN
115124
end process;
116125

117126
addrin <= std_logic_vector(cnt_pxl);
118-
datain <= std_logic_vector(cnt_pxl(11 downto 0));
127+
--datain <= std_logic_vector(cnt_pxl(11 downto 0));
128+
datain <= std_logic_vector(cnt_pxl(11 downto 0)) when cnt_col < c_img_cols/2
129+
else (others => '0');
119130
addrout <= std_logic_vector(cnt_pxl);
120131

121132
END;

0 commit comments

Comments
 (0)