本帖最后由 atchboy 于 2012-4-18 15:01 编辑
module sanfenpin(clk,R);
input clk;
output R;
reg [1:0]counter=0;
reg temp1=1;
reg temp2=1;
always @(posedge clk)
begin
counter<=counter+1;
begin
if(counter==2)
counter<=0;
end
end
always @(posedge clk)
begin
if(counter==2)
temp1=~temp1;
end
always @(negedge clk)
begin
if(counter==0)
temp2=~temp2;
end
assign R=temp1~^temp2;
endmodule
这样写程序是不是太简单了,但是仿真结果正确,不知道这种方法实现会有什么问题么? |