- BlackBox:
    name: Clash.Prelude.ROM.File.asyncRomFile#
    kind: Declaration
    type: |-
      asyncRomFile# :: KnownNat m -- ARG[0]
                     => SNat n     -- sz,   ARG[1]
                     -> FilePath   -- file, ARG[2]
                     -> Int        -- rd,   ARG[3]
                     -> BitVector m
    template: |-
      -- asyncRomFile begin
      ~GENSYM[asyncROMFile][0] : block
        type ~GENSYM[RomType][4] is array(natural range <>) of bit_vector(~LIT[0]-1 downto 0);

        impure function ~GENSYM[InitRomFromFile][1] (RomFileName : in string) return ~SYM[4] is
          FILE RomFile : text open read_mode is RomFileName;
          variable RomFileLine : line;
          variable ROM : ~SYM[4](0 to ~LIT[1]-1);
        begin
          for i in ROM'range loop
            readline(RomFile,RomFileLine);
            read(RomFileLine,ROM(i));
          end loop;
          return ROM;
        end function;

        signal ~GENSYM[ROM][2] : ~SYM[4](0 to ~LIT[1]-1) := ~SYM[1](~FILE[~LIT[2]]);
        signal ~GENSYM[rd][3] : integer range 0 to ~LIT[1]-1;
      begin
        ~SYM[3] <= to_integer(~VAR[rdI][3](31 downto 0))
        -- pragma translate_off
                      mod ~LIT[1]
        -- pragma translate_on
                      ;

        ~RESULT <= to_stdlogicvector(~SYM[2](~SYM[3]));
      end block;
      -- asyncRomFile end
