FPGA 如何产生一个时钟周期的延时比如输入i,输出o,o要在i基础上延时一个时钟周期,忽略芯片自身延时。

FPGA 如何产生一个时钟周期的延时比如输入i,输出o,o要在i基础上延时一个时钟周期,忽略芯片自身延时。,第1张

有赋值符号 <= 就可以了,这个符号是延迟一个时钟的。而 = 是不延迟的。

module(clk,i,0);

input clk,i;

output 0;

always @(posedge clk)

begin

0<=i;

end

endmodule

VHDL语言数据对象有哪几种?作用范围如何?对其赋初值作用有何不同?

答:VHDL语言数据对象有信号,变量,常量。

1、常量(CONSTANT)

一般用来代表数字电路中的电源、地、恒等逻辑值等常数。

常量的使用范围取决于它被定义的位置。即在程序包中定义可在整个程序包中使用,在实体中定义,有效范围为这个实体定义的所有结构体;定义在结构体中只能用于该结构体;定义在结构体中某一单元如一个进程则只能用在这个进程当中。

2、变量

常用在实现某些算法的赋值语句当中,只是个局部变量,只能在进程和子程序中使用。(是一种理想化的数据传输,不存在任何的延时行为)

3、信号

表示一条硬件连接线:如输入输出端口,描述硬件系统的基本数据对象。

library ieee;

use ieeestd_logic_arithall;

use ieeestd_logic_1164all;

use ieeestd_logic_unsignedall;

-----------------------------------------------------------

entity shiyan is

port(

a: in std_logic;

rst: in std_logic;

b: in std_logic

);

end shiyan;

-----------------------------------------------------------

architecture behav of shiyan is

signal counter : std_logic_vector(3 downto 0);

begin

process(rst,a,b)

begin

if(rst='1')then

counter<="0000";

else

if(a'event and a='1')then

if(counter="1111")then

counter<="0000";

else

counter<=counter+'1';

end if;

else

if(b'event and b='1')then

if(counter="0000")then

counter<="1111";

else

counter<=counter-'1';

end if;

end if;

end if;

end if;

end process;

end behav;

你试试这个 我觉得 A、B是要有优先级的 不然A和B 同时产生上升延时 COUNTER是加1还是减1?这个编译通过了 没仿真 你看看先

#d 表示延时d1ns (1ns是有timescale 1ns/10ps 的1ns)。

#(2d) 就是延时2个d 1ns。

这个d是你用parameter定义的一个常数。

假设parameter d=2 。

那你的程序就是延时2ns。

wave=0 。

再延时4ns。

wave =1。

相关定义

Verilog HDL是一种硬件描述语言,以文本形式来描述数字系统硬件的结构和行为的语言,用它可以表示逻辑电路图、逻辑表达式,还可以表示数字逻辑系统所完成的逻辑功能。

Verilog HDL和VHDL是世界上最流行的两种硬件描述语言,都是在20世纪80年代中期开发出来的。前者由Gateway Design Automation公司(该公司于1989年被Cadence公司收购)开发。两种HDL均为IEEE标准。

对于信号signal而言不要使用:=这种赋值方式。这种赋值方式不好进行综合。

这段程序计数器设计比较乱。实际上不需要用小于的表达方式(因为这样会生成比较器),几个计数器都用等号就好了

伙计分点少了

呵呵

不过还是帮你一下吧

源程序和仿真波形:

library ieee;

use ieeestd_logic_1164all;

use ieeestd_logic_unsignedall;

entity m6 is

port(clk,rst:in std_logic;

q: out std_logic_vector(2 downto 0));

end m6;

architecture bhv of m6 is

type states is(st0,st1,st2,st3,st4,st5);

signal stx:states;

begin

process(clk)

begin

if rst='1' then stx<=st0;q<="000";

elsif clk'event and clk='1' then

case(stx) is

when st0=>q<="000";stx<=st1;

when st1=>q<="001";stx<=st2;

when st2=>q<="011";stx<=st3;

when st3=>q<="111";stx<=st4;

when st4=>q<="101";stx<=st5;

when st5=>q<="100";stx<=st0;

when others=> stx<=st0;

end case;

end if;

end process;

end bhv;

以上就是关于FPGA 如何产生一个时钟周期的延时比如输入i,输出o,o要在i基础上延时一个时钟周期,忽略芯片自身延时。全部的内容,包括:FPGA 如何产生一个时钟周期的延时比如输入i,输出o,o要在i基础上延时一个时钟周期,忽略芯片自身延时。、vhdl语言数据对象有哪几种作用范围如何对其赋初值作用有何不同、vhdl语言关于if语句的问题。等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9408249.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存