chen_cheng_an 发表于 2010-10-20 10:41:10

verilog程序问题,还是quartus的问题??

本帖最后由 fpgaw 于 2010-11-12 06:20 编辑

今天我尝试在quartus中进行综合。所以我从书中抄了下面的verilog代码(很简单,很基础),(项目和文件名都为fre_ctr):

module        fre_ctr(rst,clk,load,count_en,count_clr);
output        count_en,count_clr,load;
input        rst,clk;
reg        count_clr,load;
always        @(posedge clk)       
        begin      if(rst)        begin        count_en <= 0;        load <= 1;   end
                  else         begin        count_en <= ~count_en;
                                load <= ~count_en;
                        end
        end
assign        count_clr = ~clk&load;
endmodule

但编译出错:
Error (10137): Verilog HDL Procedural Assignment error at fre_ctr.v(6): object "count_en" on left-hand side of assignment must have a variable data type
Error (10137): Verilog HDL Procedural Assignment error at fre_ctr.v(7): object "count_en" on left-hand side of assignment must have a variable data type
Error (10219): Verilog HDL Continuous Assignment error at fre_ctr.v(11): object "count_clr" on left-hand side of assignment must have a net type

我不知道我的代码错在哪里?希望大家指点!!

liyujie 发表于 2010-10-20 10:49:20

程序问题,count_en为wire型,不可以在always里面赋值,count_clr为reg型,不能用assign赋值

liyujie 发表于 2010-10-20 10:51:35

module      fre_ctr(rst,clk,load,count_en,count_clr);
output      count_en,count_clr,load;
input      rst,clk;
reg      count_en,load;
always      @(posedge clk)      
      begin      if(rst)      begin      count_en <= 0;      load <= 1;   end
                  else         begin      count_en <= ~count_en;
                              load <= ~count_en;
                        end
      end
assign      count_clr = ~clk&load;
endmodule

liyujie 发表于 2010-10-20 10:52:22

就是把那个reg定义改成count_en,你再试试看,应该可以的

liyujie 发表于 2010-10-20 10:53:07

在编译报告中已经说的很清楚了,你要会看错误报告
页: [1]
查看完整版本: verilog程序问题,还是quartus的问题??