views:

185

answers:

3

I have written two modules DLatch and RSLatch and i want to write verilog code to join those two to match the diagram here: (imagee link

http://img130.imageshack.us/i/mod.tif/

However i dont know how to go about doing this.

A: 

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.)

ScottJ
Its the wiring the ports thats giving me the troubles. Do i do something like assign Qa = RSLatch(params). but RSLatch returns 2 outputs, . Im just getting confused between imperative programming and HDL.
Faisal Abid
RSLatch is not a function so you do not call it in an imperative way. Anyway, what danielpoe said.
ScottJ
+2  A: 

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
danielpoe
+2  A: 

You might want to look into Emacs AUTOWIRE

OutputLogic