如何使用依赖于实体的其他通用参数的通用参数?

Dr.*_*son 4 syntax vhdl

我试图转换一些Verilog代码,从UART模块的更快时钟产生更慢的时钟.原始的verilog代码基于fpga4fun.com上的模块,这是我尝试将其翻译为基于VHDL的设计.

entity baud_generator is
generic(
    f_clk : integer := 50000000;  -- default: 50 MHz
    baud  : integer := 115200;    -- default: 115,200 baud
    accum_width : integer := 16;
    accum_inc : integer := (baud sll accum_width) / f_clk
);
port(
    clock : in std_logic;
    reset_n : in std_logic;
    enable : in std_logic;
    baud_clock : out std_logic
);  
end entity baud_generator;
Run Code Online (Sandbox Code Playgroud)

但是,我的编译器Aldec-HDL不喜欢以下行:

 accum_inc : natural := (baud sll accum_width) / f_clk
Run Code Online (Sandbox Code Playgroud)

这是确切的错误消息:

 # Error: COMP96_0300: baud_generator.vhd : (20, 52): Cannot reference "f_clk" until the interface list is complete.
 # Error: COMP96_0300: baud_generator.vhd : (20, 28): Cannot reference "baud" until the interface list is complete.
 # Error: COMP96_0071: baud_generator.vhd : (20, 28): Operator "sll" is not defined for such operands.
 # Error: COMP96_0104: baud_generator.vhd : (20, 27): Undefined type of expression.
 # Error: COMP96_0077: baud_generator.vhd : (20, 27): Assignment target incompatible with right side. Expected type 'INTEGER'.
Run Code Online (Sandbox Code Playgroud)

在verilog中,我有这样的事情:

module baud_generator(
  input clock,
  input reset_n,
  input enable,
  output baud_clock
);
parameter f_clock = 50000000;
parameter baud    = 115200;
parameter accum_width = 16;
parameter accum_inc = (baud << accum_width) / f_clock;
//...
endmodule
Run Code Online (Sandbox Code Playgroud)

为了使编译器满意,我需要在该行中进行修改是什么?是否可以像这样使用链接在一起的泛型?

Phi*_*ppe 6

这基本上说你不能用通用值来计算其他泛型的caluclate(默认值).

只是accum_inc用作常量,而不是通用.

此外,SLL(移位逻辑左)操作者是为位模式(unsignedsigned数据类型在ieee.numeric_stdieee.numeric_bit封装),不为整数.您可以通过乘以2的幂来做同样的事情.