yuyu87 发表于 2013-8-25 11:36:26

子模块如何仿真?求指点。。。。。。。。。。。。。。.....

如下:有主模块,TOP,有子模块,SPI

我现在要仿真SPI模块,发现Quartus II 9.0自带的仿真无法找到SPI相关节点,而TOP可以,如图,后来搜了一下,
网上说只能仿真顶层模块,子模块输入输出不能仿真,那咋弄?
大家平时写程序时顺序是咋样的?
我个人认为的肯定是先写子模块,然后验证,没问题再写其它子模块,完了之后再一点点顶层完善
是不是我这个软件版本太低了?要換最新的版本?
还是要下载专门的仿真软件?
求指点,

module top(clk,rst,spi_clk,spi_in,spi_out,spi_cs,sf_ok,sf_clk);
        input clk;                        //50Mhz输入
        input rst;                        //复位
        input spi_clk;                //SPI通讯时钟
        input spi_in;                //数据输入
        input spi_out;                //数据输出
        input spi_cs;                //片选
        input sf_ok;                //执行完毕,OK
        output sf_clk;                //       

        spi (rst,spi_clk,spi_in,spi_out,spi_cs);
endmodule

module spi(rst,spi_clk,spi_in,spi_out,spi_cs);
        input rst;                        //复位
        input spi_clk;                //SPI通讯时钟
        input spi_in;                //数据输入
        input spi_out;                //数据输出
        input spi_cs;                //片选

        reg buffer;
        always @ (negedge spi_clk)        //rst下降沿,CS下降沿准备,CLK上升沿读取数据
        begin
                if(rst==0 || spi_cs==1)        //寄存器复位
                        begin
                        buffer<=8'd0;
                        end
                else
                        begin
                        buffer={buffer,spi_in};
                        end
        end

endmodule

Fourier00 发表于 2013-8-25 14:46:38

把filter选项修改一下,仿真最好用modesim吧,还有         spi_clk不要做时钟而去做数据吧

qwerttt 发表于 2013-8-25 17:46:11

本帖最后由 qwerttt 于 2013-8-25 17:50 编辑

同意2楼
spi_clk做时钟,就变成了异步逻辑,最好避免使用异步
编程风格不同,个人认为时序要与逻辑分开写,因为你的always里既有<=也有=
写个testbench,用modelsim仿真灵活而且强大,况且QII_11版本开始没有仿真功能了,得调用第三方软件

逍遥慨 发表于 2013-8-27 21:37:44

同意以上两楼,用modesim速度比自带的快上几十几百倍
页: [1]
查看完整版本: 子模块如何仿真?求指点。。。。。。。。。。。。。。.....