Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Reading a Vector to Create 5/9 Smoother

Thread Tools

Reading a Vector to Create 5/9 Smoother

ctennant ctennant is offline
Junior Member
Join Date: Aug 2009
Posts: 2

I am new to VHDL and am having difficulty with this part of my project.

I am trying to take a 9 bit vector and check to see if it has 5 or more 0s. If it does I am assigning a second signal a 0, but if it doesn't I am assigning that signal to a 1.

Is there a way to read a vector to determine the amount of 0s or 1s in it? Thanks for any and all help.

Reply With Quote
ctennant ctennant is offline
Junior Member
Join Date: Aug 2009
Posts: 2
This is what I have done, sorry for not posting this earlier, I think it should work. I found an example in my book and have expanded on it.

I am trying to read data coming in from a 9 bit vector. If there 5 or more zeros I need to assign a value of zero to a second signal, and 1 if otherwise. I am then running that through a shift register. I'm not sure that I am exiting my loop though. Thanks for reading.

entity smoother is
Port(smoother_clk, smoother_rst: In std_logic;
smoother_data_in: In std_logic_vector(8 downto 0);
smoother_data_out: Out std_logic_vector(75 downto 0));
end smoother;

architecture Behavioral of smoother is

SIGNAL zeros: integer;
SIGNAL smoothed: std_logic;
SIGNAL smoother_shift: std_logic_vector(75 downto 0);


Process(smoother_data_in, zeros, smoothed, smoother_shift, smoother_clk, smoother_rst)

variable count: Integer Range 0 to 8;

If (smoother_rst ='0') then
smoother_data_out <= x"0000000000000000000";

elsif (smoother_clk'EVENT and smoother_clk='1') THEN
count := 0;
FOR i IN smoother_data_in'Range LOOP
CASE smoother_data_in(i) IS
WHEN '0' => count := count + 1;
WHEN Others => count := count;
End Case;
End Loop;

zeros <= count;
If zeros >= 5 then
smoothed <= '0';
smoothed <= '1';
end if;
smoother_shift <= smoother_shift(74 downto 0) & smoothed;
end if;
smoother_data_out <= smoother_shift;

End Process;
end Behavioral;
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adobe Bicubic Smoother upsize vs Genuine Fractals John Navas Digital Photography 30 12-01-2007 07:12 AM
Smoother Lines in Turtle Graphics tomy Python 5 08-10-2007 02:23 PM
Free memory allocate by a STL vector, vector of vector, map of vector C++ 8 02-18-2006 12:48 AM
smoother transition of "display" property Gregor Traven HTML 1 11-19-2004 08:54 PM
smoother pan on cheap tripods?? tkranz Digital Photography 3 08-11-2003 09:19 AM