⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_stepmot.v

📁 基于 MAXII的CPLD对电机的操作
💻 V
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************************************************** Test Bench for Step Motor Controller* December 2006*****************************************************************************************************************/module test_stepmot;  /* Applied test stimuli, corresponding to: reset,mode,	dir, move, phaseout. */ reg [3:0] test_vec;    reg oscena; wire [3:0] test_phase;             //output generated by the controller module. wire osc,clk_t,clk1; integer t;   initial  begin     oscena=1'b1;     t=0;  end/* Mapping the test bench varialbles into the main module variables.*/ stepmot s1_t(                                 .reset (test_vec[3]),         .mode (test_vec[2]),         .dir (test_vec[1]),         .move (test_vec[0]),         .phaseout(test_phase));  ufmclk  ufm1(                     //Instantiation  of ufmclk module.        .oscena (oscena),        .osc  (osc));                      divider1 d1_t(         .osc  (osc),               //Instantiation  of clk divider module.        .clk  (clk_t),        .clk1  (clk1));          initial         $monitor("Simulation period:%d,       Test vector:%b,        Test phase:%b",$time,test_vec,test_phase);        /* Providing all valid inputs to the main module of Stepper motor */        always @( negedge clk_t)     begin       if(t==0)            test_vec=4'b0011;              if(t==1)            test_vec=4'b1011;       if(t==2)             test_vec=4'b1011;       if(t==3)            test_vec=4'b1011;       if(t==4)            test_vec=4'b1011;        if(t==5)              test_vec=4'b1011;       if(t==6)            test_vec=4'b1011;       if(t==7)            test_vec=4'b1011;       if(t==8)            test_vec=4'b1011;       if(t==9)            test_vec=4'b1001;       if(t==10)            test_vec=4'b1001;       if(t==11)            test_vec=4'b1001;       if(t==12)            test_vec=4'b1001;       if(t==13)            test_vec=4'b1001;       if(t==14)            test_vec=4'b1001;       if(t==15)            test_vec=4'b1001;       if(t==16)            test_vec=4'b1001;       if(t==17)            test_vec=4'b1111;       if(t==18)            test_vec=4'b1110;       if(t==19)            test_vec=4'b1111;       if(t==20)            test_vec=4'b1110;       if(t==21)            test_vec=4'b1111;       if(t==22)            test_vec=4'b1110;       if(t==23)            test_vec=4'b1111;       if(t==24)            test_vec=4'b1110;       if(t==25)            test_vec=4'b1111;       if(t==26)            test_vec=4'b1110;       if(t==27)            test_vec=4'b1111;       if(t==28)            test_vec=4'b1110;       if(t==29)            test_vec=4'b1111;       if(t==30)            test_vec=4'b1110;       if(t==31)            test_vec=4'b1111;       if(t==32)            test_vec=4'b1110;       if(t==33)            test_vec=4'b1111;       if(t==34)            test_vec=4'b1110;       if(t==35)            test_vec=4'b1101;       if(t==36)            test_vec=4'b1100;       if(t==37)            test_vec=4'b1101;       if(t==38)            test_vec=4'b1100;       if(t==39)            test_vec=4'b1101;       if(t==40)            test_vec=4'b1100;       if(t==41)            test_vec=4'b1101;       if(t==42)            test_vec=4'b1100;       if(t==43)            test_vec=4'b1101;       if(t==44)            test_vec=4'b1100;       if(t==45)            test_vec=4'b1101;       if(t==46)            test_vec=4'b1100;       if(t==47)            test_vec=4'b1101;       if(t==48)            test_vec=4'b1100;       if(t==49)            test_vec=4'b1101;       if(t==50)            test_vec=4'b1100;       if(t==51)            test_vec=4'b1101;       if(t==52)            test_vec=4'b1100;       if(t==53)            test_vec=4'b1101;                                                               t=t+1;    end          /* Process to check the outputs for the corresponding inputs */always @( posedge clk1) begin   if (clk_t==1'b1)begin              if(t==1) begin           if(test_phase== 4'b0111)           $display ("Output Verified");           else begin            $display ("Error");            $stop;end           end                        if(t==2) begin           if(test_phase== 4'b0011)           $display ("Output Verified");           else begin            $display ("Error");            $stop;end           end                 if(t==3) begin           if(test_phase== 4'b1011)           $display ("Output Verified");           else begin            $display ("Error");            $stop; end           end                        if(t==4) begin           if(test_phase== 4'b1001)           $display ("Output Verified");           else begin           $display ("Error");           $stop; end           end                        if(t==5) begin           if(test_phase== 4'b1101)           $display ("Output Verified");           else begin           $display ("Error");           $stop; end           end                        if(t==6) begin           if(test_phase== 4'b1100)           $display ("Output Verified");           else begin            $display ("Error");            $stop; end           end                     if(t==7) begin           if(test_phase== 4'b1110)           $display ("Output Verified");           else begin            $display ("Error");           $stop; end           end                      if(t==8) begin           if(test_phase== 4'b0110)           $display ("Output Verified");           else begin           $display ("Error");           $stop; end           end           if(t==9) begin           if(test_phase== 4'b0111)           $display ("Output Verified");           else begin           $display ("Error");            $stop; end           end          if(t==10) begin           if(test_phase== 4'b0110)           $display ("Output Verified");           else begin            $display ("Error");           $stop; end           end         if(t==11) begin           if(test_phase== 4'b1110)           $display ("Output Verified");           else begin           $display ("Error");           $stop; end           end        if(t==12) begin           if(test_phase== 4'b1100)           $display ("Output Verified");           else begin           $display ("Error");           $stop; end           end       if(t==13) begin           if(test_phase== 4'b1101)           $display ("Output Verified");           else begin           $display ("Error");            $stop; end           end       if(t==14) begin           if(test_phase== 4'b1001)           $display("Output Verified");           else begin            $display ("Error");           $stop; end           end       if(t==15) begin           if(test_phase== 4'b1011)           $display ("Output Verified");           else begin           $display ("Error");           $stop; end           end       if(t==16) begin           if(test_phase== 4'b0011)           $display ("Output Verified");           else begin            $display ("Error");           $stop; end           end       if(t==17) begin           if(test_phase== 4'b0111)           $display ("Output Verified");           else begin            $display ("Error");            $stop; end           end       if(t==18) begin           if(test_phase== 4'b0111)           $display ("Output Verified");           else begin           $display ("Error");            $stop; end           end       if(t==19) begin           if(test_phase== 4'b0011)           $display ("Output Verified");           else begin            $display ("Error");            $stop; end           end       if(t==20) begin           if(test_phase== 4'b0011)           $display ("Output Verified");           else begin            $display ("Error");           $stop; end           end       if(t==21) begin           if(test_phase== 4'b1011)           $display ("Output Verified");           else begin            $display ("Error");           $stop; end           end       if(t==22) begin           if(test_phase== 4'b1011)           $display ("Output Verified");           else begin            $display ("Error");           $stop; end           end       if(t==23) begin           if(test_phase== 4'b1001)           $display ("Output Verified");           else begin           $display ("Error");            $stop; end           end                         if(t==24) begin           if(test_phase== 4'b1001)           $display ("Output Verified");           else begin            $display ("Error");            $stop; end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -