集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 5167|回复: 10

时序仿真总出错

[复制链接]
VVC 发表于 2010-6-26 02:22:02 | 显示全部楼层 |阅读模式
本帖最后由 fpgaw 于 2010-7-18 12:37 编辑

有哪位高人给指点一下:下面的程序时序仿真总出错谁能给仿真一下阿?多谢了
module rxd(reset,clk460800,in,ready,out);
    input    reset;
    input    clk460800;
    input    in;
    output    ready;
    output    [7:0]out;

    reg        ready;
    reg        [7:0]out;
    reg     [2:0]counter;
    reg        [9:0]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[0]<= 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[1]<= 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[2]<= 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[3]<= 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[4]<= 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[5]<= 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[6]<= 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[7]<= 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
CHAN 发表于 2010-6-26 02:27:45 | 显示全部楼层
问一很弱智的问题,这个程序是实现串口的接受部分的?如果要涉及成波特率9600要CLK要怎样设计?CLK460800是什么意思?
HANG 发表于 2010-6-26 03:34:30 | 显示全部楼层
这个程序好复杂啊
longtim 发表于 2010-6-26 04:06:23 | 显示全部楼层
应该把仿真的错误贴出来,有些时候不用我们仿真,看着错误找找程序就能知道是什么原因
longtim 发表于 2010-6-26 06:00:46 | 显示全部楼层
这么多状态!
CCIE 发表于 2010-6-26 06:41:20 | 显示全部楼层
我仿过了,没有error呀,只有几个warning罢了
UFO 发表于 2010-6-26 07:56:48 | 显示全部楼层
哎,都不知道你想问什么哦
ups 发表于 2010-6-26 08:50:41 | 显示全部楼层
好难哦~!~1`
interig 发表于 2010-6-26 10:03:56 | 显示全部楼层
结构上应该是没有错误,可能状态转椅上是否有冲突,你得再考量一下状态转移逻辑,比如说有没有出现死逻辑,确保每个状态能够顺利转移到其它状态而没有冗余逻辑,最好把一些遇到的错误信息贴出来
ngtim 发表于 2010-6-26 11:37:01 | 显示全部楼层
太多了,看不年了
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-5-6 17:13 , Processed in 0.068966 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表