微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 搞不懂为什么无法综合。请教之,关于无法综合成FF的问题

搞不懂为什么无法综合。请教之,关于无法综合成FF的问题

时间:10-02 整理:3721RD 点击:
一个计数器:
module counter_fiv(clk,rst,start0,counter_out);

input clk,rst;
        input start0;
output [5:0] counter_out;
reg [5:0] counter_out;


reg [5:0] counter_m;
wire temp;


assign temp = !rst | !start0 ;


always @ (posedge clk or negedge rst) begin
   if (temp)
              counter_m <= 6'd0;
      else   
      counter_m <=counter_m +1'b1;
      end

always @ (counter_m) counter_out = counter_m;
endmodule
----------------------------------------------------

ERROR:Xst:899 - "../counter_fiv.v" line 15: The logic for <counter_m> does not match a known FF or Latch template. The description style you are using to describe a register or latch is not supported in the current software release.
------------------------------------------------------
还有一个问题,有点困扰,就是,可综合的模块不允许在两个always模块里面给同一个寄存器赋值,可是又不允许在敏感表中同时列举沿触发和电平触发。那怎么写呢。
比如这个计数器,我想有一个外部开关来控制启动与否,用start0来表示,start0=1时启动,start0=0时关闭。那start0和posedge clk之间怎么写呢,把start0写在posedge里面,肯定不是本意;可是写在外面,单独用一个always块写又不可综合,是不是要用assign来连接start0和counter_m呢?。
求教。

个人见解:
问题1:你是想把counter_m赋值给counter_out吧,为何不直接always@*
问题2:状态机

你的时序always的敏感表里定义了:posedge clk or negedge rst,但是rst根本没用到。改成posedge clk or posedge temp试试。
always @ (counter_m) counter_out = counter_m;这个赋值想做什么呢?把reg [5:0] counter_out去掉,直接assign counter_out = counter_m不就行?

always @ (posedge clk or negedge rst) begin
   if (temp)

把敏感变量里的 or negedge rst去掉。因为你没有用到这个信号。编译工具不能判断你断表示什么样的逻辑电路,所以无法综合。

我认为把代码改成这样更好
module counter_fiv(clk,rst,start0,counter_out);

input clk,rst;
        input start0;
output [5:0] counter_out;
reg [5:0] counter_out;
always @ (posedge clk or negedge rst) begin
   if (~rst)
        counter_out <= 6'd0;
   else if (start0==1'b1)
      counter_out <=counter_out +1'b1;
   else
     counter_out <= counter_out;
endmodule
如果counter_out在start0无效的时候要回零,就把counter_out<=counter_out换成counter_out<=0;

6L的code比较好一些,LZ的有些像初学者的风格。

你的counter是要寄存器来实现,就考虑当时钟沿来的时候,在什么条件下累加,什么条件下保持
只能在一个always block中赋值



   我觉得negedge rst 是用到了吧。temp=!rst | !start0,如果下降沿到来,那!rst=1,temp=1,形成了触发呀。
   assign语句的左边值只能是线网型的吧,计数器里面定义了counter_out是reg型啊,不能直接用assign赋值吧。



   可是这样的话,start0的优先级就在rst之下了。其实我是想让strat0有最高的优先级,电平开关,然后当start0=1时,其他的才有效。您能再帮我改一下么?谢谢。初学VERILOG,很多都不会,摸索中,向前辈们请教。



   按照你的改了,是可以综合的。我觉得是不是不可综合的地方在于,temp=!rst | ! strat0. 也就是这个temp是一个沿触发和一个电平触发的位或,但触发的条件却是rst的下降沿。这个综合器不能理解。


其实按照你的想法是可以综合成一个DFFSR就是带有复位和置位的寄存器的。
出问题的地方是你将rst与start0线或在一起,temp这根线既是跳变的边沿又是电平,综合器不知道这个线到底是reset还是set,所以就报出来找不到这样的器件。
按照你代码的理解是这样的有reset,counter_m就回零,start0为低的时候counter_m也是回零。按照我前面给你的代码,就能综合成DFFSR。
个人的理解是这样的,有不对的地方还请高手出来指点。
这位兄弟设计虽然简单但是也引出来不简单的问题。大家多讨论,都提高。



    嗯,多向大家学习。谢谢指教!哈哈~

module counter_fiv(clk,rst,start0,counter_out);
input clk,rst;
input start0;
wire reset = !rst | !start0;
output [5:0] counter_out;
reg [5:0] counter_out;
always @ (posedge clk or posedge reset) begin
   if (reset)
        counter_out <= 6'd0;
   else if (start0 == 1'b1)
      counter_out <=counter_out +1'b1;
endmodule
按你的想法可以这样写,但是一般都会按照6楼的写法来写的。

RST往往都是最优先的啊

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top