为什么单个仿真都是正确的,但是连起来nimei中计数值不对...

2019-07-16 01:47发布

为什么单个仿真都是正确的,但是连起来nimei中计数值不对而且输入复位信号也不复位啊,
  1. module jishu (clk, rst,q,mh,ml,en);
  2. input clk,rst,en;
  3. input [1:0]mh;
  4. input [7:0]ml;
  5. output q;
  6. reg q;
  7. reg[7:0]countl;
  8. reg[1:0]counth;
  9. always @(posedge clk or negedge rst )
  10.         begin
  11.                
  12.                 if(!rst)
  13.                         begin
  14.                         countl<=8'b00000000;
  15.                         counth<=2'b00;
  16.                         end
  17.                 else
  18.                 begin
  19.                         if(!en)
  20.                         begin                               
  21.                              
  22.                                    if(counth[1:0]>=mh)
  23.                                            begin
  24.                                                 if(countl[7:0]==ml)
  25.                                                         begin
  26.                                                         q<=~q;                               
  27.                                                         countl<=8'b00000000;
  28.                                                     counth<=2'b00;       
  29.                                                         end                                               
  30.                                                         else
  31.                                                         countl<=countl+8'b00000001;

  32.                                                 end
  33.                                         else
  34.                                                 begin
  35.                                                 if(countl==8'b11111111)
  36.                                                                 begin
  37.                                                                 countl<=8'b00000000;
  38.                                                                 counth<=counth+2'b01;
  39.                                                                 end
  40.                                                 else
  41.                                                                 countl<=countl+8'b00000001;
  42.                                                                                
  43.                                        
  44.                                                                   end               
  45.                                                 end                                          
  46.                                     end
  47.             
  48.         end

  49. endmodule       











  50. module nimei(clk ,en ,countl,counth,choose,rst);
  51. input clk,en,rst;
  52. input [1:0]choose;
  53. output [7:0]countl;
  54. output [1:0]counth;
  55. reg[7:0]countl;
  56. reg[1:0]counth;
  57. parameter zb=2'b10;

  58. always @(posedge clk or negedge rst)
  59. begin
  60.         if(!rst)
  61.                 begin       
  62.                 countl<=8'b11110101;
  63.                 counth<=2'b01;       
  64.                 end

  65.    else
  66.                 begin
  67.                 if(!en)
  68.                 begin
  69.                   if(choose==zb)
  70.                           begin
  71.                                if(counth<=2'b00)  
  72.                                begin
  73.                                            if(countl<=8'b10001100)
  74.                                                    begin
  75.                                                            countl<=8'b10001100;
  76.                                                            counth<=2'b00;                               
  77.                                                    end
  78.                                            else
  79.                                                 countl<=countl-8'b00000100;               
  80.                                
  81.                                end   
  82.                                         else
  83.                                         begin
  84.                                   if(countl==8'b00000000)
  85.                                                   begin
  86.                                                   counth<=counth-2'b01;
  87.                                                   countl<=8'b11111011;                                  
  88.                                                   end
  89.                                          else  if(countl==8'b00000001)
  90.                                                    begin
  91.                                                   counth<=counth-2'b01;
  92.                                                   countl<=8'b11111100;                                  
  93.                                                    end
  94.                                                   
  95.                                         else  if(countl==8'b00000010)
  96.                                                    begin
  97.                                                   counth<=counth-2'b01;
  98.                                                   countl<=8'b11111101;
  99.                                                                                     
  100.                                                    end
  101.                                         else  if(countl==8'b00000011)
  102.                                                    begin
  103.                                                   counth<=counth-2'b01;
  104.                                                   countl<=8'b11111100;                                  
  105.                                                    end          
  106.                                                                                                     
  107.                                                   
  108.                                                 else
  109.                                                 countl<=countl-8'b00000100;
  110.                                 
  111.                                 end                               
  112.                                        
  113.                                
  114.                           end
  115.                
  116.                           
  117.                          
  118.                 end
  119.                
  120.                 end

  121. end
  122. endmodule
复制代码高手们帮忙看看啊


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。