1

我正在编写一个简单的 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);

也许一个命令可以帮助我避免重复?

4

2 回答 2

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);等。
  • 要替换所有三个语句,请使用procedure。然后代码看起来像p(red_out, green_out, blue_out, zero, x, y).

检查http://www.csee.umbc.edu/portal/help/VHDL/design.html的语法。

于 2012-05-31T09:57:57.363 回答
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);
于 2012-06-05T08:41:10.377 回答