作者nichaellin (章鱼)
站内Programming
标题[问题] verilog基本简单的updown counter
时间Sun Aug 5 17:40:01 2012
module Counter(clk,rst,slect,out);
input [1:0]slect;
input clk,rst;
output [9:0]out;
reg [9:0]out;
always@(slect)
begin
if(slect==2'd0)
always@(posedge clk)
begin
if(rst)
begin
out=10'd0;
end
else if(out==10'd1023)
begin
out=10'd0;
end
else
begin
out=out+1'd1;
end
end
if(slect==2'd1)
always@(posedge clk)
begin
if(rst)
begin
out=10'd1023;
end
else if(out==10'd0)
begin
out=10'd1023;
end
else
begin
out=out-1'd1;
end
end
if(slect==2'd3)
always@(posedge clk)
begin
if(rst)
begin
out<=10'd0;
end
else if(out!=10'd1023)
out<=out+1'd1;
end
else(out!=10'd0)
out<=out-1'd1;
end
end
end
end module
条件我假设是可以让他
1.往上数到1023
2.往下数到0
3.0~1023~0这样数
可是compile不过
我是新手一直苦无解答QQ
不知道有没有人能帮帮我
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.131.177
1F:推 mars90226:错误讯息是甚麽?125.226.179.171 08/05 18:36
2F:→ nichaellin:我把end module改成endmodule140.116.131.177 08/05 18:48
3F:→ nichaellin:就可以了耶XD140.116.131.177 08/05 18:48
5F:→ flarehunter:always里面放always应该是不行的吧 140.112.41.107 08/09 17:53