【发布时间】:2019-08-05 16:25:53
【问题描述】:
我需要使用“if-else”或“case”设置一个常量的值,并根据另一个常量的值选择不同的常量值。这在VHDL中可能吗?这将是在模拟开始时常数值的一次更改......示例:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity bridge is
generic (
burst_mode :std_logic := '0'
);
end entity;
architecture rtl of bridge is
constant fifo_aw_wdata :natural := 2 when (burst_mode = '0') else 5;
begin
-- fifo: entity work myfifo
-- generic map(
-- aw => fifo_aw_wdata
-- )
-- port map(
-- ...
-- );
end architecture;
上面的VHDL代码给出了错误信息:
Error ';' is expected instead of 'when'
在 Verilog 中,做这种事情很容易……所以我认为 VHDL 也可以做到这一点? Verilog 示例:
module #(parameter burst_mode = 1'b0) bridge;
localparam fifo_aw_wdata = (!burst_mode) ? 2 : 5;
// fifo myfifo #(.aw(fifo_aw_wdata)) ( ...);
endmodule;
【问题讨论】:
-
Vhdl 2019 将(最终)允许此代码。
标签: vhdl