How to connect two modules in Verilog?

I wrote two DLatch and RSLatch modules, and I want to write Verilog code to join these two.

+3
source share
3 answers

Seriously, you should get a Verilog guide or find 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
+4
source

You might want to explore Emacs AUTOWIRE

+2
source

, (D, Clk, Q, NQ). DLatch RSLatch . ( .)

0

Source: https://habr.com/ru/post/1722386/


All Articles