石田宇 发表于 2010-10-26 19:26:19

麻烦帮我看一下这个Verilog程序是哪儿的问题

本帖最后由 石田宇 于 2010-10-31 16:21 编辑

程序:
`timescale 1ns/1ps
module mux16(
            clk,
            rst_n,
            start,
            ain,
            bin,
            yout,
            done
            );
parameter WIDTH=16;
parameter LONGWIDTH=32;

input clk;
input rst_n;
input start;
input ain;
input bin;

output yout;
output done;
//-----------------------------------------------------------------------------------------------

reg cnt=0;
reg shift_ain;
reg shift_bin;
reg done_r;
reg yout_r;

always @ (posedge clk or negedge rst_n or posedge start)
    begin
    if(!rst_n)
      begin
      yout_r<=32'd0;
      done_r<=1'b0;
      cnt<=0;
      shift_ain<=0;
      shift_bin<=0;
      end
    else
      begin
      if(start)
            begin
            if(cnt<5'd17)
                begin
                shift_ain<=ain;
                shift_bin<=bin;
                yout_r<=0;
                for(cnt=5'd1;cnt<5'd17;cnt=cnt+1'b1)
                  begin
                  if(shift_bin) yout_r<=yout_r+shift_ain;
                  shift_ain<=shift_ain<<1;
                  shift_bin<=shift_bin>>1;
                  if(cnt==5'd17) done_r<=1'b1;
                  end
                end
            end
      else if(!start)
            begin
            cnt<=0;
            done_r<=1'b0;
            end
      end
    end

assign done=done_r;
assign yout=yout_r;

endmodule








testbentch:
`timescale 1 ns/ 1 ps
module mux16_vlg_tst();
// test vector input registers
reg ain;
reg bin;
reg clk;
reg rst_n;
reg start;
// wires                                             
wire done;
wire yout;

// assign statements (if any)                        
mux16 i1 (
// port map - connection between master ports and signals/registers   
        .ain(ain),
        .bin(bin),
        .clk(clk),
        .done(done),
        .rst_n(rst_n),
        .start(start),
        .yout(yout)
);
initial
begin
    clk=0;
    forever
      #10 clk=~clk;
end

initial
begin
    rst_n=0;
    #1000;
    rst_n=1;
    #19000;
    $stop;
end

initial
begin
    start=0;
    #2000;
    start=1;
    #18000;
    $stop;
end

initial
begin
    ain=16'd0;
    #5000;
    ain=16'd10;
    #15000;
    $stop;
end

initial
begin
    bin=16'd0;
    #5000;
    bin=16'd20;
    #15000;
    $stop;
end

endmodule

然后调用modelsim仿真的时候没有输出结果,只有输入的波形,而且报错:# ERROR: No extended dataflow License exists

石田宇 发表于 2010-10-26 19:26:59

补充下,程序想实现一个16位乘法器

smallwind1 发表于 2010-10-27 22:48:19

你能不能把波形也贴出来?啥叫输出结果?你指的啥?

石田宇 发表于 2010-10-30 09:43:15

回复 3# smallwind1

你好,波形我上传上去了,就是没有输出啊,输出全是0,没有输出想要的结果。麻烦各位分析下

nonews 发表于 2010-10-30 12:28:57

你软件安装没问题吧

石田宇 发表于 2010-10-30 17:40:59

回复 5# nonews
应该是没事的,我仿真了几个别的程序都是可以的

liqz 发表于 2010-11-2 21:12:54

lways @ (posedge clk or negedge rst_n or posedge start)
把or posedge start去掉

Sunlife 发表于 2015-4-8 15:16:39


你能不能把波形也贴出来?啥叫输出结果?你指的啥?
页: [1]
查看完整版本: 麻烦帮我看一下这个Verilog程序是哪儿的问题