
/* =====================================================================
 * Always include this header file when writing digital simulation !!!
 * ===================================================================== */
#include "Sim.h"

void simnet()
{
  /* ==============================================
     ROM contains 8 words, each word has 16 bits
     ============================================== */
  unsigned char RomContent[] = {
                                 0b10101010, 0b10101010,   // Word 0
                                 0b11110000, 0b11110000,   // Word 1
                                 0b00110011, 0b00110011,   // Word 2
                                 0b11001100, 0b11001100,   // Word 3
                                 0b00001111, 0b00001111,   // Word 4
                                 0b11111111, 0b11111111,   // Word 5
                                 0b00000000, 0b00000001,   // Word 6
                                 0b10000000, 0b00000000};  // Word 7

  Sig(addr,3);           // Address signals
  Sig(out,16);            // Output signals

  Switch( "fa", addr[2], '2', Zero );   
  Switch( "fb", addr[1], '1', Zero );   
  Switch( "fc", addr[0], '0', Zero );   

  /* ============================================================
     Rom with 3 address bits and 8 data bits

     Requirement:
          1. # words = 2^(size of addr)
          2. # bits  = size of out
     ============================================================ */
  Rom ( "bb-db", addr, out, 8 /* # words */, 16 /* # bits in a word */,
	 RomContent );
                                   // Rom

  ProbeH( "aa-ad", out);           // Probe output
}
