集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 4109|回复: 5

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

[复制链接]
gpping2010 发表于 2011-5-27 10:27:22 | 显示全部楼层 |阅读模式
我是新手,我现在编了几个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 [31:0] X0,Y0,Xe,Ye;
input [31:0] V,T;
output [31:0] a,b;
output [31:0] 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 [31:0] a_1,b_1;

output [31:0] d;
reg [31:0]a,b;
reg [31:0]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 [31:0] a,b,c;
output[31:0] 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 [31:0] X0,Y0,Xe,Ye;
input [31:0] V,T;
input [31:0] c;
output [31:0] l;
output [31:0] d;
output[31:0] sin_x,cos_x;

wire [31:0] a,b;

line_1  line_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_2  line_2_m (.a_1(a),.b_1(b),.d(d),.clk(clk),.rst(rst));
line_4  line_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 下一条

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

GMT+8, 2024-5-5 22:38 , Processed in 0.069953 second(s), 24 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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