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

📄 clock.v

📁 熟悉verilog,帮助初学者尽快掌握verilog
💻 V
字号:
 /* 请教verilog问题? --------- 发表时间 2002-7-28-19:07:58 - 来自 61.48.8.143 - 佚名的人  
module Clock(reset_l, clkout, lclk, dclk, a, cs_en, cs_l) ;  */

// add your declarations here 
input reset_l; 
input clkout ; 
input dclk; 
input [2:0]a; 
input cs_en; 
output lclk ; 
output [4:1]cs_l ; 

reg lclk; 
wire [2:0]a; 
reg [2:0]b; 
wire cs_en; 
reg [4:1]cs_l; 
reg [1:0]counter; 

// add your code here 
always @(posedge clkout or negedge reset_l) 
begin 
   if (reset_l == 0) 
      begin 
         counter[1:0] = 2'b00; 
         lclk = 0; 
      end 
   else if (counter[1:0] != 2'b11) 
      begin 
         counter[1:0] = counter +1; 
         lclk = 1; 
      end 
   else 
      begin 
         counter[1:0] = 2'b00; 
         lclk = 0; 
      end 
end 

always @( a or cs_en))//出错Error: Non-static loop or event waits in only some 

begin               branches detected  
   b = a; 
   while (cs_en == 1) 
      begin 
         case (b) 
            2'b00: 
               begin 
                  cs_l[1] = 0; 
               end 
            2'b01: 
               begin 
                  cs_l[2] = 0; 
               end            
            2'b10: 
               begin 
                  cs_l[3] = 0; 
               end            
            2'b11: 
               begin 
                  cs_l[4] = 0; 
               end 
         endcase 
      end 
   cs_l = 4'b1111; 
end   

endmodule 


 
/*佚名的人的Email: 个人主页:    <-回应| <-返回|  
  改正结果: --------- 发表时间 2002-7-29-11:24:22 - 来自 218.17.86.230 - Dick Hou  
module Clock(reset_l, clkout, lclk, dclk, a, cs_en, cs_l) ; */

// add your declarations here 
input reset_l; 
input clkout ; 
input dclk; 
input [2:0]a; 
input cs_en; 
output lclk ; 
output [4:1]cs_l ; 

reg lclk; 
wire [2:0]a; 
reg [2:0]b; 
wire cs_en; 
reg [4:1]cs_l; 
reg [1:0]counter; 

// add your code here 
always @(posedge clkout or negedge reset_l) 
begin 
if (reset_l == 0) 
begin 
counter[1:0] = 2'b00; 
lclk = 0; 
end 
else if (counter[1:0] != 2'b11) 
begin 
counter[1:0] = counter +1; 
lclk = 1; 
end 
else 
begin 
counter[1:0] = 2'b00; 
lclk = 0; 
end 
end 

always @( a or cs_en) 
begin 
b = a; 
if (cs_en == 1) //Modify while() to if() statement 
begin 
case (b) 
2'b00: 
begin 
cs_l[1] = 0; 
end 
2'b01: 
begin 
cs_l[2] = 0; 
end 
2'b10: 
begin 
cs_l[3] = 0; 
end 
2'b11: 
begin 
cs_l[4] = 0; 
end 
endcase 
end 
  else 
cs_l = 4'b1111; 
end 
endmodule 

 
  //Dick Hou的Email:dickhou@yeah.net 个人主页:http://dickhou.6to23.com 

⌨️ 快捷键说明

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