Verilog 的always块里面的敏感列表里的信号为电平型

always的敏感列表里面是电平敏感型,只要电平满足条件,就会输出一次测量结果。如下代码当rst为低电平时,一直满足(!rst)一直为真,输出out一直为1。

`timescale 1ns/1ps;
module top(

input rst,
input [1:0]sel,
output reg out
);

always @ (rst or sel)begin
    if (!rst)
    out = 1;
    else if (sel!= 0)
    out = 0;
    else 
    out =0;
end

endmodule
`timescale 1ns/1ns
module tb_dianping();
reg rst;
reg [1:0]sel;
wire out;

initial begin
rst = 1'b1;
sel = 2'd0;
#200 rst = 1'b0;
#50 sel =2'd1;
#70 sel = 2'd2;
#15 sel = 2'd3;
end

 top top_u(
.rst(rst),
.sel(sel),
.out(out)
);

endmodule

在这里插入图片描述

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值