返回该小组首页 回复主题
风晨林

风晨林

小组等级:     E币:89  (E币换礼)

#1楼主:帮忙把这个问题分析下

文章发表于:2008-05-08 01:07

这是我写verilog程序

//  Module Declaration
module clock_generater
(
 // {{ALTERA_ARGS_BEGIN}} DO NOT REMOVE THIS LINE!
 clk, rst, alu_clk, fetch, clk1
 // {{ALTERA_ARGS_END}} DO NOT REMOVE THIS LINE!
);
// Port Declaration

 // {{ALTERA_IO_BEGIN}} DO NOT REMOVE THIS LINE!
 input clk;
 input rst;
 output alu_clk;
 output fetch;
 output clk1;
 // {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE!

reg /*clk2,clk4,*/fetch,alu_clk;
reg [7:0] state;
wire  clk/*,rst*/;
 
parameter  s1=8'b00000001,
     s2=8'b00000010,
   s3=8'b00000100,
   s4=8'b00001000,
   s5=8'b00010000,
   s6=8'b00100000,
   s7=8'b01000000,
   s8=8'b10000000,
    idle="8"'b00000000;
/*
assign clk1=~clk;
always @ (negedge clk)
    if(rst)
   begin
   clk2<=0;
   clk4<=1;
   fetch<=0;
   alu_clk<=0;
   state<=idle;
   end
  else
   begin
    case(state)
     s1:
      begin
      clk2<=~clk2;
      alu_clk<=~alu_clk;
      state<=s2;
      end
     s2:
      begin
      clk2<=~clk2;
      clk4<=~clk4;
      alu_clk<=~alu_clk;
      state<=s3;
      end
     s3:
      begin
      clk2<=~clk2;
      state<=s4;
      end
     s4:
      begin
      clk2<=~clk2;
      clk4<=~clk4;
      fetch<=~fetch;
      state<=s5;
      end
     s5:
      begin
      clk2<=~clk2;
      state<=s6;
      end
     s6:
      begin
      clk2<=~clk2;
      clk4<=~clk4;
      state<=s7;
      end
     s7:
      begin
      clk2<=~clk2;
      state<=s8;
      end
     s8:
      begin
      clk2<=~clk2;
      clk4<=~clk4;
      fetch<=~fetch;
      state<=s1;
      end
      idle: state<=s1;
    default:state<=idle;
   endcase
  end
endmodule
*/
assign clk1=~clk;
always @ (posedge clk)
 if(rst)
  begin
   fetch<=0;
   alu_clk<=0;
   state<=idle;
  end
 else
  begin
  case (state)
   s1:
    begin
    alu_clk<=~alu_clk;
    state<=s2;
    end
   s2: 
    begin
    alu_clk<=~alu_clk;
    state<=s3;
    end
   s3: state<=s4;
   s4: 
    begin
    fetch<=~fetch;
    state<=s5;
    end
   s5: state<=s6;
   s6: state<=s7;
   s7: state<=s8;
   s8:
    begin
    fetch<=~fetch;
    state<=s1;
    end
  idle: state<=s1;
  default:state<=idle;
  endcase
  end
endmodule
想得到的时序图请看附件

但是仿真后的波形是下图

请大侠们帮我分析哈是哪里出问题了

      【回复】

g0tazu

   小组等级:    E币:254  (E币换礼)

#2

文章发表于:2008-05-10 12:57

这么长 你想实现什么功能呀? 分频?

twzh

   小组等级:    E币:150  (E币换礼)

#3

文章发表于:2008-05-10 22:31

天那,好长的程序啦,没有注释,不是很明白:)

总共 , 当前 /

快速回复主题--如果想加入编辑器功能,建议使用 [高级回复]

您目前还不是小组成员,请先加入

回复贴子区

用户名:    您没有注册?

密码:    忘记了密码?

内容:

浏览该小组的用户还看过...

设计资源与分销

赞助商链接

";