【发布时间】:2019-04-26 19:24:05
【问题描述】:
我有一些 Verilog 代码如下:
module bus_fifo #(
parameter DEPTH_WIDTH = 0,
parameter DATA_WIDTH = 0
) (
input wire clk,
input wire rst,
input wire [DATA_WIDTH-1:0] wr_data_i,
input wire wr_en_i,
output wire [DATA_WIDTH-1:0] rd_data_o,
input wire rd_en_i,
output wire full_o,
output wire empty_o
);
localparam DW = (DATA_WIDTH == 10) ? 4 : DATA_WIDTH;
localparam AW = DEPTH_WIDTH>>2;
endmodule
我想要做同样事情的语法有效的 VHDL:
library ieee;
use ieee.std_logic_1164.all;
entity bus_fifo is
generic(
DEPTH_WIDTH : integer := 0;
DATA_WIDTH : integer := 0
);
port(
clk : in std_logic;
rst : in std_logic;
wr_data_i : in std_logic_vector(DATA_WIDTH-1 downto 0);
wr_en_i : in std_logic;
rd_data_o : out std_logic_vector(DATA_WIDTH-1 downto 0);
rd_en_i : in std_logic;
full_o : out std_logic;
empty_o : out std_logic
);
end entity;
architecture bus_fifo of bus_fifo is
constant DW : integer := (DATA_WIDTH == 10) ? 4 : DATA_WIDTH;
constant AW : integer := DEPTH_WIDTH>>2;
signal write_pointer; : std_logic_vector(AW downto 0);
signal read_pointer; : std_logic_vector(AW downto 0);
signal empty_int : std_logic;
signal full_or_empty : std_logic;
begin
end architecture;
我遇到的问题是 VHDL 不支持三元运算符并生成错误消息。我想知道是否有 VHDL 解决方案可以做类似于我在 Verilog 中所做的事情?
【问题讨论】:
-
函数是在 VHDL 2008 及以前版本中执行此操作的唯一方法。
-
我质疑这项任务是否完全有意义。如果
DATA_WIDTH是9 或11,DW也是9 或11,但如果DATA_WIDTH是10,DW应该是4!?