关于分频程序问题

2019-07-16 00:23发布

tica, Arial, sans-serif">初学Verilog,编了一小段关于分频的程序(输出50%占空比,5分频信号),但编译就是通不过,各位高手有兴趣就请帮忙看看,不胜感激!
下面是源程序:
  1. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">module hh(clk,k,k1,k2);</span>
  2. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">input clk;</span>
  3. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">output k,k1,k2;</span>
  4. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">reg [2:0]c1;</span>
  5. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">reg m1;</span>
  6. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">always @(posedge clk)…………………………第29行</span>
  7. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">    begin</span>
  8. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      if (c1==4) </span>
  9. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      begin</span>
  10. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">         c1<=0;m1<=~m1;</span>
  11. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      end</span>
  12. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      else c1<=c1+1;</span>
  13. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">    end</span>
  14. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">always @(negedge clk)………………………………第37行</span>
  15. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">    begin</span>
  16. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      if (c1==4)</span>
  17. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      begin </span>
  18. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">         c1<=0;m1<=~m1;</span>
  19. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      end</span>
  20. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      else c1<=c1+1;</span>
  21. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">    end</span>
  22. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">      assign k=m1;</span>
  23. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">endmodule</span>
复制代码

  1. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">编译提示的错误:</span>
  2. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error (10028): Can't resolve multiple constant drivers for net "c1[2]" at hh.v(37)</span>
  3. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error (10029): Constant driver at hh.v(29)</span>
  4. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error (10028): Can't resolve multiple constant drivers for net "c1[1]" at hh.v(37)</span>
  5. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error (10028): Can't resolve multiple constant drivers for net "c1[0]" at hh.v(37)</span>
  6. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error (10028): Can't resolve multiple constant drivers for net "m1" at hh.v(37)</span>
  7. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error: Can't elaborate top-level user hierarchy</span>
  8. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error: Quartus II Analysis & Synthesis was unsuccessful. 6 </span><span href="tag.php?name=error" class="t_tag" style="line-height: normal; cursor: pointer; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(255, 0, 0); white-space: nowrap; font-family: Verdana, Helvetica, Arial, sans-serif;">error</span><span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">s, 4 warnings</span>
  9. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error: Peak virtual memory: 170 megabytes</span>
  10. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error: Processing ended: Thu Oct 21 14:37:21 2010</span>
  11. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error: Elapsed time: 00:00:01</span>
  12. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error: Total CPU time (on all processors): 00:00:01</span>
  13. <span style="font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 22.390625px;">Error: Quartus II Full Compilation was unsuccessful. 8 errors, 4 warnings</span>
复制代码

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
3条回答
倪love
2019-07-16 05:56

首先,你的程序写的不甚规范(连rst信号都没有),刚开始写,一定要养成一个好的编程习惯才好;
其次,分频的程序其实用不着这么复杂的,不知道你为什么要用两个always块儿。
这也直接导致了错误的发生(多驱动)---------不能在多个always块中对同一个变量进行赋值。
你程序中的c1和m1在两个always块中都赋值了。

一周热门 更多>