我正在编写一个简单的vga控制器,我发现自己一次又一次地重复相同的模式。我怎么能避免这种情况。
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);
也许一个能帮我避免重复的命令?
答案 0 :(得分:2)
zero(x-106,y-63)&zero(x-106,y-63)&zero(x-106,y63)&zero(x-106,y-63)
,请使用函数。然后代码看起来像red_out<=f(zero, x, y);
等。p(red_out, green_out, blue_out, zero, x, y)
。答案 1 :(得分:2)
如果你的向量收到一个相同的单个位副本,那么下面的代码就会这样做,并且比使用函数更简单:
red_out <= (others => zero(x-106,y-63));
green_out <= (others => zero(x-106,y-63));
blue_out <= (others => zero(x-106,y-63));
甚至
my_bit <= zero(x-106,y-63);
red_out <= (others => my_bit);
green_out <= (others => my_bit);
blue_out <= (others => my_bit);