集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2982|回复: 4

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

[复制链接]
chen_cheng_an 发表于 2010-10-20 10:41:10 | 显示全部楼层 |阅读模式
本帖最后由 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 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-18 19:21 , Processed in 0.074585 second(s), 24 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表