Reputation: 2087
I am writing a simple vga controller and I find myself repeating the same pattern again and again. How I can avoid this.
red_out <= zero(x-106,y-63)&zero(x-106,y-63)&zero(x-106,y63)&zero(x-106,y-63);
green_out <= zero(x-106,y-63)&zero(x-106,y-63)&zero(x-106,y-63)&zero(x-106,y-63);
blue_out <= zero(x-106,y-63)&zero(x-106,y-63)&zero(x-106,y-63)&zero(x-106,y-63);
Maybe a command that will help me avoid the repetition?
Upvotes: 1
Views: 1646
Reputation: 2290
If your vectors receive a copy a the same single bit then the following code would do it, and would be simpler than resorting to functions:
red_out <= (others => zero(x-106,y-63));
green_out <= (others => zero(x-106,y-63));
blue_out <= (others => zero(x-106,y-63));
or even
my_bit <= zero(x-106,y-63);
red_out <= (others => my_bit);
green_out <= (others => my_bit);
blue_out <= (others => my_bit);
Upvotes: 2
Reputation: 1145
zero(x-106,y-63)&zero(x-106,y-63)&zero(x-106,y63)&zero(x-106,y-63)
, use a function. The code would then look something like red_out<=f(zero, x, y);
etc.p(red_out, green_out, blue_out, zero, x, y)
.Check http://www.csee.umbc.edu/portal/help/VHDL/design.html for the syntax.
Upvotes: 2