#!/usr/bin/env python3
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Generate 256-bitwidth vmem file from 32-bitwidth vmem file
"""

import argparse
import re

def main():
  """
  Args:
      input:  The input 32-bitwidth vmem file name.
      output: The output 256-bitwidth vmem file name.
  """
  parser = argparse.ArgumentParser(description='Generate 256-bitwidth vmem file.')
  parser.add_argument("--input",
                      "-i",
                      action='store',
                      required=True,
                      help="Input 32-bitwidth vmem file")
  parser.add_argument("--output",
                      "-o",
                      required=True,
                      help="Output 256-bitwidth vmem file")
  parser.add_argument("--entry_addr",
                      default = 0x0,
                      help="Entry address of kelvin program")
  args = parser.parse_args()

  # Open input/output files
  infile = open(args.input, 'r')
  outfile = open(args.output, 'w')

  # Fetch each line from 32-bitwidth vmem file and dump each data line for
  # 256-bitwidth vmem file.
  addr_base = args.entry_addr
  mem_data_line = ""
  word_per_line = 8
  for line in infile.readlines():
    # Ignore comment
    if re.match(r"\/\*(.)*\*\/", line):
      continue
    tokens = line.split()
    m = re.match(r"@([0-9a-fA-F]{8})", tokens[0])
    addr = int(m[1], 16)
    for token in tokens[1:]:
      mem_data_line = token + mem_data_line
      addr = addr + 1
      # Write out a mem data line when it is ready
      if (addr % word_per_line) == 0:
        outfile.write(f"@{addr_base:08X} {mem_data_line}\n")
        addr_base = int((addr + args.entry_addr) / word_per_line)
        mem_data_line = ""
  if mem_data_line:
    outfile.write(f"@{addr_base:08X} {mem_data_line}\n")
  infile.close()
  outfile.close()

if __name__ == "__main__":
  main()
