发信人: whynot (父亲那双破草鞋), 信区: cnElectric
标  题: Re: fpga节省资源设计的一个例子(vhdl)
发信站: 哈工大紫丁香 (Thu Dec 23 13:31:50 1999), 转信

发信人: gyw (打倒cao_dd), 信区: Circuit       
发信站: BBS 水木清华站 (Sun Dec  5 12:18:16 1999)

我认为下面两种作法的差别可能仅仅在于一两个LE。
还有,是不是一定要用同步的初始化和复位?



【 在 wavelets (wavelet) 的大作中提到: 】
: fpga的结构化特点导致近似的设计会产生交大差别的MAPING(综合之后)之结果,
: 因此,设计时应充分学习FPGA之结构,才可以充分利用资源。
: 现举例如下:
: 设计方法1:
: library ieee;
: use     ieee.std_logic_1164.all;
: use     ieee.std_logic_unsigned.all;
: entity counter is 

:  port (       
:                       inti      : in  std_logic;
:                       clock     : in   std_logic;
:                       reset      : in   std_logic;
:                       bout       : out  std_logic_vector(4 downto 0));


: end counter;

: architecture behavior of counter      is

: signal  counter         : std_logic_vector(4 downto 0);

: begin

: counter_machine:process(clock)
: begin
:       if clock'event and clock='1' then
:               if inti='0' then
:                       counter<="00001";
:                            *****************  
:               elsif reset='1' then
:                       if counter=19 then
:                               counter<=(others=>'0');
:                       else
:                               counter<=counter+1;
:                       end if;
:               else
:                       counter<=(others=>'0');
:               end if;
:    end if;
: end process;

: bout<=counter;
: end behavior;



: 设计方法2
: library ieee;
: use     ieee.std_logic_1164.all;
: use     ieee.std_logic_unsigned.all;
: entity counter is 

:  port (       
:                       inti      : in  std_logic;
:                       clock     : in   std_logic;
:                       reset      : in   std_logic;
:                       bout       : out  std_logic_vector(4 downto 0));


: end counter;

: architecture behavior of counter      is

: signal  counter         : std_logic_vector(4 downto 0);

: begin

: counter_machine:process(clock)
: begin
:       if clock'event and clock='1' then
:               if inti='0' then
:                       counter<="00000";
:                            *****************  
:               elsif reset='1' then
:                       if counter=19 then
:                               counter<=(others=>'0');
:                       else
:                               counter<=counter+1;
:                       end if;
:               else
:                       counter<=(others=>'0');
:               end if;
:    end if;
: end process;

: bout<=counter;
: end behavior;
: 对于设计1,由于init和reset的counter置位是不同的,所以额外的LE完成
: 组合逻辑。
: 而对于设计2,
: 由于inti和reset可以用LE中的LUT和cascade_in和cascade_out实现计数器
: 的加,用programable register实现计数器的状态,所以资源利用率是比较
: 高的。
: 二者的速度几乎没有差别。
: 好了,该干活了。


--

--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: ningx.bbs@smth.org]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.299毫秒