gpping2010 发表于 2011-5-27 10:27:22

急!Verilog中怎样将一个模块的部分输出作为另一个模块的部分输入

我是新手,我现在编了几个verilog小模块,这几个小模块是按顺序计算的,就是模块1的部分输出是模块2的部分输入,模块2的输出又是模块3的部分输入……,这个模块之间的连接在verilog中怎样实现?求高手指点,

gpping2010 发表于 2011-5-27 10:33:58

回复 1# gpping2010

补充一下:是一个计算过程
模块一:module line_1(X0,Y0,Xe,Ye ,a,b,l,V,T,clk,rst);
input clk,rst;
input X0,Y0,Xe,Ye;
input V,T;
output a,b;
output l;
fpsadd_sub m_01(clk,Xe,X0,a);
fpsadd_sub m_02(clk,Ye,Y0,b);
fpsmult m_0(clk,V,T,l);   
endmodule
模块一中的输出a,b,是模块二中的输入a_1,b_1,是模块三中的部分输入a,b。

模块二:module line_2(a_1,b_1,d,clk,rst);
input clk,rst;
input a_1,b_1;

output d;
reg a,b;
reg d;
always @(posedge clk or negedge rst)
begin   
    if(!rst)
       begin      
         d=32'b0;
       end
    else
       begin
          d<=a_1*a_1+b_1*b_1;      
       end
end
endmodule
模块三:module line_4(a,b,c,sin_x,cos_x,clk,rst);
input clk,rst;
input a,b,c;
output sin_x,cos_x;

fpsdiv m0(clk,b,c,sin_x);
fpsdiv m1(clk,a,c,cos_x);
endmodule

应该怎样将这之间的联系在顶层模块里实现?

哦十全_至芯学员 发表于 2011-5-27 20:53:27

module top_alu(clk,rst,X0,Y0,Xe,Ye,l,V,T,d,c,sin_x,cos_x);
input clk,rst;
input X0,Y0,Xe,Ye;
input V,T;
input c;
output l;
output d;
output sin_x,cos_x;

wire a,b;

line_1line_1_m (.X0(X0),.Y0(Y0),.Xe(Xe),.Ye(Ye) ,.a(a),.b(b),.l(l),.V(V),.T(T),.clk(clk),.rst(rst));
line_2line_2_m (.a_1(a),.b_1(b),.d(d),.clk(clk),.rst(rst));
line_4line_4_m (.a(a),.b(b),.c(c),.sin_x(sin_x),.cos_x(cos_x),.clk(clk),.rst(rst));

endmodule
有点乱 你凑合看吧

nuaahjj 发表于 2011-7-18 15:56:21

用下一级的模块例化前一级的模块

蓝余 发表于 2011-7-18 16:27:18

如果用ise开发工具 可以通过画图来弄 即将顶层模块选为 schematic

liujilei311 发表于 2011-7-18 17:13:55

顶蓝余版主!!!!!!!
页: [1]
查看完整版本: 急!Verilog中怎样将一个模块的部分输出作为另一个模块的部分输入