我正在尝试在Verilog中编写代码(通过将2个模块添加到一起(并将其上传到FPGA。我想用LCD 1602模块启动一个红外模块,我创建了一个模块,并在主模块中编写了红外和LCD模块
module Satellite(clk, rs, rw, en,dat,rst_n,IR,led_cs,led_db)
module lcd(clk, rs, rw, en,dat)
input clk;
output [7:0] dat;
output rs,rw,en;
代码有 2 个问题。
-
模块声明需要端口后
;
,如下所示:module abc(port1, port2,...);
-
在 Verilog 中不允许在模块内声明模块。
module
...endmodule
结构必须是独立的。
因此,您的代码可能如下所示:
module Satellite(clk, rs, rw, en,dat,rst_n,IR,led_cs,led_db);
input clk;
// ... define other ports
// instantiate the module 'lcd'
lcd lcd(clk, rs, rw, en, dat);
// ... do something else
endmodule
module lcd(clk, rs, rw, en,dat);
input clk;
output [7:0] dat;
output rs,rw,en;
// ... do something here
endmodule
reg dis;
reg [0:0] led_cs;
reg [7:0] led_db;
.
.
.
case(led2)
8'b01101000:
led_db=8'b1100_0000;
dis="0";
.
.
.
dat0: begin rs<=1; dat<=dis; next<=dat1; end