时序仿真总出错
本帖最后由 fpgaw 于 2010-7-18 12:37 编辑有哪位高人给指点一下:下面的程序时序仿真总出错谁能给仿真一下阿?多谢了
module rxd(reset,clk460800,in,ready,out);
input reset;
input clk460800;
input in;
output ready;
output out;
reg ready;
reg out;
reg counter;
reg state;
parameter idle = 10'b00_0000_0000,
start = 10'b00_0000_0001,
first = 10'b00_0000_0010,
second = 10'b00_0000_0100,
third = 10'b00_0000_1000,
fourth = 10'b00_0001_0000,
fifth = 10'b00_0010_0000,
sixth = 10'b00_0100_0000,
seventh = 10'b00_1000_0000,
eighth = 10'b01_0000_0000,
stop = 10'b10_0000_0000;
always@(posedge clk460800)
begin
if (!reset)
begin
state <= idle;
ready <= 0;
counter <= 3'b000;
end
else
case (state)
idle: begin
if (in)
begin
state <= idle;
end
else
begin
state <= start;
end
end
start: begin
if ((counter < 3) && (in == 0))
begin
counter <= counter + 3'b001;
end
else
if (counter == 3)
begin
counter <= 3'b000;
state <= first;
end
else
begin
counter <= 3'b000;
state <= idle;
end
end
first: begin
if (counter <3)
begin
counter <= counter + 3'b001;
if (counter == 1)
begin
out<= in;
end
end
else
begin
state <= second;
counter = 3'b000;
end
end
second: begin
if (counter < 3)
begin
counter <= counter + 3'b001;
if (counter == 1)
begin
out<= in;
end
end
else
begin
state <= third;
counter <= 3'b000;
end
end
third: begin
if (counter < 3)
begin
counter <= counter + 3'b001;
if (counter == 1)
begin
out<= in;
end
end
else
begin
state <= fourth;
counter <= 3'b000;
end
end
fourth: begin
if (counter < 3)
begin
counter <= counter + 3'b001;
if (counter == 1)
begin
out<= in;
end
end
else
begin
state <= fifth;
counter <= 3'b000;
end
end
fifth: begin
if (counter < 3)
begin
counter <= counter + 3'b001;
if (counter == 1)
begin
out<= in;
end
end
else
begin
state <= sixth;
counter <= 3'b000;
end
end
sixth: begin
if (counter < 3)
begin
counter <= counter + 3'b001;
if (counter == 1)
begin
out<= in;
end
end
else
begin
state <= seventh;
counter <= 3'b000;
end
end
seventh:begin
if (counter < 3)
begin
counter <= counter + 3'b001;
if (counter == 1)
begin
out<= in;
end
end
else
begin
state <= eighth;
counter <= 3'b000;
end
end
eighth: begin
if (counter < 3)
begin
counter <= counter + 3'b001;
if (counter == 1)
begin
out<= in;
end
end
else
begin
state <= stop;
counter <= 3'b000;
end
end
stop: begin
if (counter <2)
begin
counter <= counter + 3'b001;
if (counter == 0)
begin
ready <= 1;
end
else
begin
ready <= 0;
end
end
else
begin
state <= idle;
counter <= 3'b000;
end
end
default: state <= idle;
endcase
end
endmodule 问一很弱智的问题,这个程序是实现串口的接受部分的?如果要涉及成波特率9600要CLK要怎样设计?CLK460800是什么意思? 这个程序好复杂啊 应该把仿真的错误贴出来,有些时候不用我们仿真,看着错误找找程序就能知道是什么原因 这么多状态! 我仿过了,没有error呀,只有几个warning罢了 哎,都不知道你想问什么哦 好难哦~!~1` 结构上应该是没有错误,可能状态转椅上是否有冲突,你得再考量一下状态转移逻辑,比如说有没有出现死逻辑,确保每个状态能够顺利转移到其它状态而没有冗余逻辑,最好把一些遇到的错误信息贴出来 太多了,看不年了
页:
[1]
2