How to wire two modules in Verilog?

匿名 (未验证) 提交于 2019-12-03 00:58:01

问题:

I have written two modules DLatch and RSLatch and i want to write verilog code to join those two.

回答1:

Seriously, you should get yourself a Verilog handbook or search for some online resources.

Anyway, something like this should work:

module dff (     input Clk,     input D,     output Q,     output Qbar   );    wire q_to_s;   wire qbar_to_r;   wire clk_bar;    assign clk_bar = ~Clk;    D_latch dlatch (     .D(D),     .Clk(Clk),     .Q(q_to_s),     .Qbar(qbar_to_r)   );    RS_latch rslatch (     .S(q_to_s),     .R(qbar_to_r),     .Clk(clk_bar),     .Qa(Q),     .Qb(Qbar)   );  endmodule 


回答2:

You might want to look into Emacs AUTOWIRE



回答3:

You will need to create an outer module, with the ports as shown in your schematic (D, Clk, Q, NQ). Inside this module you instantiate the two submodules DLatch and RSLatch, and wire the ports appropriately. (You will need to declare extra wires for the internal interconnects.)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!