微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > VHDL 转 Verilog 求助。 input port 是 integer

VHDL 转 Verilog 求助。 input port 是 integer

时间:10-02 整理:3721RD 点击:
大家好,我对两种 HDL 都不熟悉,现在遇到个难题,希望大侠指点一下。
在 VHDL 里 sub block 有一个 input port 是 integer 类型:

  1. entity counter is
  2. port( M : in integer );
  3. end counter;

复制代码


调用的情况如下:

  1. entity top is
  2. port( set_i : in unsigned(4 downto 0) );
  3. end top;

  4. architecture rtl of top is
  5. begin
  6. inst1 : entity work.counter
  7. port map( M => (2**24) );
  8. inst2 : entity work.counter
  9. port map( M => 4096 );
  10. inst3 : entity work.counter
  11. port map( M => to_integer(set_i) );
  12. end rtl;

复制代码


这里有 map 到表达式、常数、signal,还有类型转换,转成 Verilog 对我来说实在太难了。我有想过将 M 变成 parameter, 但是 inst3 那里不知道该怎么处理。

直接定义为端口上的一个input 32bit的信号,然后将map的值连到这个信号上就可以了


按照你提供的帮助,对两个module相关的语句分别改成:
    input [31:0] M;
    counter inst3( .M({27'b0,set_i}) );
看上去是OK的,谢谢!



    这个方法应该是行的通的


请问有一个input 原来是: clk_period_i    :     in unsigned(29 downto 0);
它只用在两个 if 里面:
if (counter < clk_period_i/2-1)
elsif (counter >= clk_period_i/2-1 and counter < clk_period_i-1)
我现在给它增加一个最高位0:
test <= '0'&clk_period_i(29 downto 0);
if (counter < test/2-1)
elsif (counter >= test/2-1 and counter < test-1)
这样出来的结果会不match,请问它们差在哪里?这是我在转VHDL到Verilog中想找出它们不一致在哪的一个尝试,有时间也帮我看一下吧。http://bbs.eetop.cn/viewthread.php?tid=464131&amp;extra=

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top