试编写一个实现3输入与非门的verilog源程序

试编写一个实现3输入与非门的verilog源程序,第1张

module gate3(

input a,

input b,

input c,

output y

)

assign y=~(a&b&c)

endmodule

修改了一下,加了输入输出端口,以及触发条件

module test(red,amber,green ,able)

input able

output red,amber,green

reg clock,red,amber,green

parameter on=1,off=0,red_tics=350,green_tics=200,amber_tics=30

//交通灯初始化

initial red=off

initial amber=off

initial green=off

//交通灯控制时序

always

wait(able)

begin

red=on//开红灯

light(red,red_tics)//调用等待任务

green=on//开绿灯

light(green,green_tics)//等待

amber=on//开黄灯

light(amber,amber_tics)//等待

end

//定义交通灯开启时间的任务

task light

output color

input [31:0]tics

begin

repeat(tics)

@(posedge clock)

color=off

end

endtask

always

begin

#100 clock=0

#100 clock=1

end

endmodule

编译通过

Tools >Netlist viewer >RTL viewer

选中相应的symbol上,点击上面的“→”箭头,可以看到原始的由门和触发器搭建的电路图。


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

原文地址: https://outofmemory.cn/yw/11247836.html

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

发表评论

登录后才能评论

评论列表(0条)

保存