title: How do you feed a file into memory made from custom modules (no reg) like with readmemb?
body: <p>For example, instead of using <code>reg [3:0] RAM [0:31];</code> I've made my own module attempting to use using a hardwired FlipFlopMod.</p>
  
  <p>This is what I'm trying to do (but you'll see it obviously doesn't work):</p>
  
  <pre><code>module mem_mod(addr, mem_out);
     input [4:0] addr;        // 5-bit addr bus
     output [3:0] mem_out;    // 4-bit inst/data out
  
     // a real flip flop instead of using reg.
     FlipFlopMod_4bit RAM [0:31] (1/*enabled*/, 4'b1111, q, nq);    // # of nibbles
  
     assign mem_out = RAM[addr]; // change this to an AND selector.
  
     // read binary code into RAM, prepare inst.txt 1st
     initial $readmemb("inst.txt", RAM);
  endmodule
  
  // Gated Flip Flop
  module FlipFlopMod_1bit(clk, d, q, nq);
      input clk, d;
      output q, nq;
  
      wire and0, and1, d_inv;
  
      not(d_inv, d); // d and d_inv are someties referred to as R and S, respectively.
  
      // these two and gates cause the input to be latched only when clk
      // (enable) is high.
      and(and0, d, clk);
      and(and1, clk, d_inv);
  
      // These nor gates are the actual flipflop/latch.
      nor(nq, and0, q);
      nor(q, nq, and1);
  endmodule
  
  // 4 bit gated flip flop made using 1 bit gated flip flops.
  module FlipFlopMod_4bit(clk, d, q, nq);
      input clk;
      input [3:0] d;
      output [3:0] q, nq;
  
      FlipFlopMod_1bit latch3 (clk, d[3], q[3], nq[3]);
      FlipFlopMod_1bit latch2 (clk, d[2], q[2], nq[2]);
      FlipFlopMod_1bit latch1 (clk, d[1], q[1], nq[1]);
      FlipFlopMod_1bit latch0 (clk, d[0], q[0], nq[0]);
  endmodule
  </code></pre>
  
  <p>This is where I started from, using <code>reg</code> (this works):</p>
  
  <pre><code>module mem_mod(addr, mem_out);
     input [4:0] addr;        // 5-bit addr bus
     output [3:0] mem_out;    // 4-bit inst/data out
  
     reg [3:0] RAM [0:31];    // # of nibbles
  
     assign mem_out = RAM[addr];
  
     // read binary code into RAM, prepare inst.txt 1st
     initial $readmemb("inst.txt", RAM);
  endmodule
  </code></pre>
  
  <p>As you can see, I'm not quite sure how to read each 4bit piece of data from a file into my custom array of FlipFlops, so that each of my FlipFlops holds a different value, like the <code>reg</code> example. I think I could probably just hard code 32 flip flops, and hard code the values in each parameter instead of reading the file, but that's no fun!</p>
  
  <p>The file that I'm reading from (inst.txt) looks like this:</p>
  
  <pre><code>0001
  0011
  1000
  0011
  ...
  ...
  ... etc, 32 lines total.
  </code></pre>