OpenCores
URL https://opencores.org/ocsvn/tv80/tv80/trunk

Subversion Repositories tv80

[/] [tv80/] [trunk/] [sc_env/] [app_localcfg/] [app_env_top.cpp] - Diff between revs 106 and 108

Show entire file | Details | Blame | View Log

Rev 106 Rev 108
Line 7... Line 7...
#include <unistd.h>
#include <unistd.h>
#include "it_cfg_driver.h"
#include "it_cfg_driver.h"
#include "it_cfg_monitor.h"
#include "it_cfg_monitor.h"
#include "Vlcfg.h"
#include "Vlcfg.h"
#include "load_ihex.h"
#include "load_ihex.h"
 
#include <assert.h>
 
 
extern char *optarg;
extern char *optarg;
extern int optind, opterr, optopt;
extern int optind, opterr, optopt;
 
 
#define FILENAME_SZ 80
#define FILENAME_SZ 80
Line 23... Line 24...
  int index;
  int index;
  char dumpfile_name[FILENAME_SZ];
  char dumpfile_name[FILENAME_SZ];
  char mem_src_name[FILENAME_SZ];
  char mem_src_name[FILENAME_SZ];
  uint8_t memory[MAX_MEM_SIZE];
  uint8_t memory[MAX_MEM_SIZE];
  VerilatedVcdSc *tfp;
  VerilatedVcdSc *tfp;
 
  int run_time = 5; // in microseconds
  //z80_decoder dec0 ("dec0");
  //z80_decoder dec0 ("dec0");
 
 
  sc_clock clk("clk125", 8, SC_NS, 0.5);
  sc_clock clk("clk125", 8, SC_NS, 0.5);
 
 
  sc_signal<bool> reset_n;
  sc_signal<bool> reset_n;
Line 50... Line 52...
  sc_signal<uint32_t>  cfgo_rd_data;
  sc_signal<uint32_t>  cfgo_rd_data;
 
 
  // clear program memory
  // clear program memory
  for (int i=0; i<MAX_MEM_SIZE; i++) memory[i] = 0;
  for (int i=0; i<MAX_MEM_SIZE; i++) memory[i] = 0;
 
 
  while ( (index = getopt(argc, argv, "d:i:k")) != -1) {
  while ( (index = getopt(argc, argv, "d:i:t:")) != -1) {
    printf ("DEBUG: getopt optind=%d index=%d char=%c\n", optind, index, (char) index);
    printf ("DEBUG: getopt optind=%d index=%d char=%c\n", optind, index, (char) index);
    if  (index == 'd') {
    if  (index == 'd') {
      strncpy (dumpfile_name, optarg, FILENAME_SZ);
      strncpy (dumpfile_name, optarg, FILENAME_SZ);
      dumping = true;
      dumping = true;
      printf ("VCD dump enabled to %s\n", dumpfile_name);
      printf ("VCD dump enabled to %s\n", dumpfile_name);
    } else if (index == 'i') {
    } else if (index == 'i') {
      strncpy (mem_src_name, optarg, FILENAME_SZ);
      strncpy (mem_src_name, optarg, FILENAME_SZ);
      memfile = true;
      memfile = true;
 
    } else if (index == 't') {
 
      run_time = atoi (optarg);
 
      assert (run_time > 0);
 
      printf ("Running for %d microseconds\n", run_time);
 
    } else {
 
      printf ("Unknown index %c\n", (char) index);
    }
    }
  }
  }
 
 
  Vlcfg lcfg ("lcfg");
  Vlcfg lcfg ("lcfg");
  lcfg.clk (clk);
  lcfg.clk (clk);
Line 124... Line 132...
    max = load_ihex (mem_src_name, memory, MAX_MEM_SIZE);
    max = load_ihex (mem_src_name, memory, MAX_MEM_SIZE);
    printf ("Loading IHEX file %s, max addr=%d\n", mem_src_name, max);
    printf ("Loading IHEX file %s, max addr=%d\n", mem_src_name, max);
    while (bused <= max) {
    while (bused <= max) {
      cword = 0;
      cword = 0;
      for (int i=0; i<4; i++) cword |= (memory[bused++] << (i*8));
      for (int i=0; i<4; i++) cword |= (memory[bused++] << (i*8));
      printf ("Queueing %x\n", cword);
      //printf ("Queueing %x\n", cword);
      driver.add_queue (cword);
      driver.add_queue (cword);
    }
    }
  }
  }
 
 
  // set reset to 0 before sim start
  // set reset to 0 before sim start
Line 143... Line 151...
 
 
  //delete runtime; runtime = new sc_time (1000, SC_NS);
  //delete runtime; runtime = new sc_time (1000, SC_NS);
  sc_start (sc_time(2500,SC_NS));
  sc_start (sc_time(2500,SC_NS));
  lcfg_proc_reset.write(0);
  lcfg_proc_reset.write(0);
 
 
  sc_start (sc_time(5000, SC_NS));
  sc_start (sc_time(run_time, SC_US));
 
 
  /*
  /*
  sc_close_vcd_trace_file (trace_file);
  sc_close_vcd_trace_file (trace_file);
  */
  */
  if (dumping)
  if (dumping)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.