阅读下面的3段verilog程序,说明其实现了什么功能?

module timer1(clk,second);
input clk;
output reg second;
reg[24:0] cnt;
always @(posedge clk)
begin
cnt <= cnt + 1'b1;
if (cnt==25'd24999999)
begin
cnt <= 24'd0;
second <= ~second;
end
end
endmodule

module ex6(A,B,C,Y);
input A,B,C;
output Y;
wire out1,out2,out3;
and a1(out1,A,B);
and a2(out2,A,C);
and a3(out3,B,C);
or or1(Y,out1,out2,out3);
endmodule

module multiplexer4_to_1(out, i0, i1, i2, i3, s1, s0);
output out;
input i0, i1, i2, i3;
input s1, s0;
assign out = s1 ? (s0 ? i3 : i2) : (s0? i1 : i0);
endmodule

module timer1(clk,second);
input clk;
output reg second;
reg[24:0] cnt;
always @(posedge clk)
begin
cnt <= cnt + 1'b1;
if (cnt==25'd24999999)
begin
cnt <= 24'd0;
second <= ~second;
end
end
endmodule
这是一个分频器,是50000000分频器,但是cnt <= 24'd0;这句似乎写错了,应该是cnt <= 25'd0;再多说一句,这个写的很屁,没有复位操作,初始状态不可控制。

module ex6(A,B,C,Y);
input A,B,C;
output Y;
wire out1,out2,out3;
and a1(out1,A,B);
and a2(out2,A,C);
and a3(out3,B,C);
or or1(Y,out1,out2,out3);
endmodule
这个门级描述的:Y=out1 | out2 | out3 = (A&B) | (A&C) | (B&C);写出真值表,其实就是一个检测ABC三个信号中为真的个数大于等于2电路。大于等于2,Y=1,否则Y=0;

module multiplexer4_to_1(out, i0, i1, i2, i3, s1, s0);
output out;
input i0, i1, i2, i3;
input s1, s0;
assign out = s1 ? (s0 ? i3 : i2) : (s0? i1 : i0);
endmodule
这个就更简单了,根据语句直接就是该功能。

同学,我答的很纠结,如果你真的很初学的初学者,我就忍了,如果你已经学了一段时间的verilog了,还是这个水平,我不得不为你担忧哦。嘿嘿,玩笑,希望你能明白!
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-07-07
这么直白还来问.

就当做c语言看, 什么都搞定了
相似回答