verilog完整程序结构的基本构成有哪些?

verilog完整程序结构的基本构成有哪些?,第1张

verilog一个完整的程序包括如下

1.module名定义

2.输入/出信号名,方向和位宽

3.模块逻辑定义和实现

4.endmodule

module traffic(clk,urgency,east_west,south_north,led)

input clk

input urgency

output [7:0]east_west,south_north

output [5:0]led

reg [7:0]east_west,south_north

reg [5:0]led

initial begin

east_west<=8'b0

south_north<=8'b0

led<=6'b100001end

always @(posedge clk)

begin if(urgency==1) led<=6'b100100

else if(east_west==8'b0 &&south_north==8'b0) begin

east_west<=8'b00101101

south_north<=8'b00101000

led<=6'b100001end

else if(east_west==8'b00000110 &&south_north==8'b1) begin

east_west<=8'b00000101

south_north<=8'b00000101

led<=6'b100010end

else if(east_west==8'b1 &&south_north==8'b1 &&led[5]==1'b1) begin

east_west<=8'b00101000

south_north<=8'b00101101

led<=6'b001100end

else if(east_west==8'b1 &&south_north==8'b00000110) begin

east_west<=8'b00000101

south_north<=8'b00000101

led<=6'b010100end

else if(east_west==8'b1 &&south_north==8'b1 &&led[2]==1'b1) begin

east_west<=8'b00101101

south_north<=8'b00101000

led<=6'b100001end

else if(east_west[3:0]==4'b0000) begin

east_west<=east_west-8'b111

south_north<=south_north-1'b1end

else if(south_north[3:0]==4'b0000) begin

east_west<=east_west-1'b1

south_north<=south_north-8'b111end

else begin

east_west<=east_west-1'b1

south_north<=south_north-1'b1

end

end

endmodule

上面是我前一段时间写的交通灯控制器设计代码,相应的英文字母对应相应的信号


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

原文地址: http://outofmemory.cn/yw/11396765.html

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

发表评论

登录后才能评论

评论列表(0条)

保存