|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
设计了一个16位加法器,在这个例子中adder16模块调用了另一个通用加法器adder模块。源程序如下:
`include "adder.v"
module adder16(cout,sum,a,b,cin);
output cout;
parameter my_size=16;
output[my_size-1:0] sum;
input[my_size-1:0] a,b;
input cin;
adder my_adder(cout,sum,a,b,cin);
endmodule
下面是adder模块代码:
module adder(cout,sum,a,b,cin);
parameter size=16;
output cout;
output[size-1:0] sum;
input cin;
input[size-1:0] a,b;
assign {cout,sum}=a+b+cin;
endmodule
编译仿真时有两个源文件:adder.v和adder16.v,请问建工程时工程名和顶层文件的实体名该如何命名?我命名为adder16或者adder都不行,编译时总出错,不晓得什么原因,编译时有提示:
Error (10228): Verilog HDL error at adder.v(1): module "adder" cannot be declared more than once
Error (10112): Ignored design unit "adder16" at adder16.v(3) due to previous errors
一个工程难道只能有一个文件而不能添加其他的吗?求教该如何解决? |
|