@for pkg in $(PKGS); do\
cd $$pkg && $(MAKE) $$pkg ; cd ..;\
done
+ $(MAKE) -f main.mk main_app
libs: main.mk
$(MAKE) -f main.mk libs
#include <stdio.h>
-#include "globals.h"
+// sim.src
+#include "appcl.h"
+// local
#include "simavrcl.h"
int
main(int argc, char *argv[])
{
+ class cl_app *app;
class cl_sim *sim;
- sim= new cl_simavr(argc, argv);
+ app= new cl_app();
+ app->init();
+ sim= new cl_simavr(app, argc, argv);
sim->init();
+ app->set_simulator(sim);
sim->main();
- delete sim;
+ delete app;
return(0);
}
#include <ctype.h>
+// sim.src
+#include "appcl.h"
+
+// local
#include "simavrcl.h"
#include "avrcl.h"
-cl_simavr::cl_simavr(int iargc, char *iargv[]):
- cl_sim("h", iargc, iargv)
+cl_simavr::cl_simavr(class cl_app *the_app, int iargc, char *iargv[]):
+ cl_sim(the_app, "h", iargc, iargv)
{}
class cl_simavr: public cl_sim
{
public:
- cl_simavr(int iargc, char *iargv[]);
+ cl_simavr(class cl_app *the_app, int iargc, char *iargv[]);
virtual int proc_arg(char optopt, char *optarg);
virtual class cl_uc *mk_controller(void);
// sim
#include "simcl.h"
#include "argcl.h"
+#include "appcl.h"
// local
#include "newcmdcl.h"
}
int
-cl_console::proc_input(class cl_cmdset *cmdset)
+cl_console::proc_input(class cl_app *app, class cl_cmdset *cmdset)
{
int retval= 0;
class cl_cmd *cm;
cmdline= new cl_cmdline(cmdstr, this);
cmdline->init();
- cm= cmdset->get_cmd(cmdline);
+ cm= 0;
+ if (app)
+ cm= app->get_cmd(cmdline);
+ if (cm == 0 &&
+ cmdset)
+ cm= cmdset->get_cmd(cmdline);
if (cm)
retval= cm->work(sim, cmdline, this);
delete cmdline;
*____________________________________________________________________________
*/
-cl_commander::cl_commander(class cl_cmdset *acmdset, class cl_sim *asim):
+cl_commander::cl_commander(class cl_app *the_app,
+ class cl_cmdset *acmdset, class cl_sim *asim):
cl_base()
{
+ app= the_app;
cons= new cl_list(1, 1);
actual_console= frozen_console= 0;
cmdset= acmdset;
if (c->match(i))
{
actual_console= c;
- int retval= c->proc_input(cmdset);
+ int retval= c->proc_input(app, cmdset);
if (retval)
{
del_console(c);
virtual int get_in_fd(void);
virtual int input_avail(void);
virtual char *read_line(void);
- virtual int proc_input(class cl_cmdset *cmdset);
+ virtual int proc_input(class cl_app *app, class cl_cmdset *cmdset);
virtual bool interpret(char *cmd);
};
class cl_commander: public cl_base
{
public:
+ class cl_app *app;
class cl_list *cons;
fd_set read_set, active_set;
int fd_num;
class cl_cmdset *cmdset;
public:
- cl_commander(class cl_cmdset *acmdset, class cl_sim *asim);
+ cl_commander(class cl_app *the_app,
+ class cl_cmdset *acmdset, class cl_sim *asim);
~cl_commander(void);
virtual int init(void);
INSTALL = @INSTALL@
PRJDIR = .
+SIMDIR = sim.src
DEFS = $(subs -DHAVE_CONFIG_H,,@DEFS@)
# FIXME: -Imcs51 must be removed!!!
-CPPFLAGS = @CPPFLAGS@ -I$(PRJDIR)
+CPPFLAGS = @CPPFLAGS@ -I$(PRJDIR) -I$(PRJDIR)/$(SIMDIR)
CFLAGS = @CFLAGS@ -I$(PRJDIR) -Wall
CXXFLAGS = @CXXFLAGS@ -I$(PRJDIR) -Wall
M_OR_MM = @M_OR_MM@
+UCSIM_LIBS = -lsim -lcmd -lutil
+
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
srcdir = @srcdir@
OBJECTS = pobj.o globals.o utils.o
+SOURCES = $(patsubst %.o,%.cc,$(OBJECTS))
+UCSIM_OBJECTS = ucsim.o
+UCSIM_SOURCES = $(patsubst %.o,%.cc,$(UCSIM_OBJECTS))
+ALL_SOURCES = $(SOURCES) $(UCSIM_SOURCES)
# Compiling entire program or any subproject
libs: libutil.a
+main_app: checkconf ucsim_app
+
# Compiling and installing everything and runing test
# ---------------------------------------------------
install: all installdirs
# ---------------------
dep: main.dep
-main.dep: *.cc *.h
- $(CXXCPP) $(CPPFLAGS) $(M_OR_MM) *.cc >main.dep
+main.dep: $(ALL_SOURCES) *.h
+ $(CXXCPP) $(CPPFLAGS) $(M_OR_MM) $(ALL_SOURCES) >main.dep
include main.dep
include clean.mk
# My rules
# --------
-
libutil.a: $(OBJECTS)
ar -rcu $*.a $(OBJECTS)
$(RANLIB) $*.a
+ucsim_app: libs ucsim
+
+ucsim: $(UCSIM_OBJECTS) $()
+ $(CXX) $(CXXFLAGS) -o $@ $< -L$(PRJDIR) $(UCSIM_LIBS)
+
.cc.o:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
#include "ddconfig.h"
-//#include <stdio.h>
-
-//#include "globals.h"
+// sim.src
+#include "appcl.h"
+// local
#include "sim51cl.h"
main(int argc, char *argv[])
{
int retval;
+ class cl_app *app;
class cl_sim *sim;
- sim= new cl_sim51(argc, argv);
+ app= new cl_app();
+ app->init();
+ sim= new cl_sim51(app, argc, argv);
if (sim->init())
return(1);
+ app->set_simulator(sim);
retval= sim->main();
- delete sim;
+ delete app;
return(retval);
}
#include "glob.h"
-cl_sim51::cl_sim51(int iargc, char *iargv[]):
- cl_sim("t:s:S:hHk:", iargc, iargv)
+cl_sim51::cl_sim51(class cl_app *the_app, int iargc, char *iargv[]):
+ cl_sim(the_app, "t:s:S:hHk:", iargc, iargv)
{}
static void
class cl_sim51: public cl_sim
{
public:
- cl_sim51(int iargc, char *iargv[]);
+ cl_sim51(class cl_app *the_app, int iargc, char *iargv[]);
virtual int proc_arg(char optopt, char *optarg);
virtual class cl_uc *mk_controller(void);
};
-#include <8051.h>
+#include <reg51.h>
sfr at 0xa6 WDTRST;
-#include <8051.h>
+#include <reg51.h>
sfr at 0xa6 WDTRST;
-#include <8051.h>
+#include <reg51.h>
#define BUFSIZE 16
#define T0H 0xfc
// mod 0, TH= 8 bit t/c, TL= 5 bit precounter
//(MEM(MEM_SFR)[TL0])++;
sfr->add(TL0, 1);
- if (sfr->get(TL0) > 0x1f)
+ if ((sfr->get(TL0) & 0x1f) == 0)
{
- sfr->set_bit0(TL0, ~0x1f);
+ //sfr->set_bit0(TL0, ~0x1f);
+ sfr->set(TL0, 0);
if (!/*++(MEM(MEM_SFR)[TH0])*/sfr->add(TH0, 1))
{
sfr->set_bit1(TCON, bmTF0);
while (cycles--)
{
// mod 0, TH= 8 bit t/c, TL= 5 bit precounter
- if (/*++(MEM(MEM_SFR)[TL1])*/sfr->add(TL1, 1) > 0x1f)
+ if (/*++(MEM(MEM_SFR)[TL1])*/(sfr->add(TL1, 1) & 0x1f) == 0)
{
- sfr->set_bit0(TL1, ~0x1f);
+ //sfr->set_bit0(TL1, ~0x1f);
+ sfr->set(TL1, 0);
if (!/*++(MEM(MEM_SFR)[TH1])*/sfr->add(TH1, 1))
{
sfr->set_bit1(TCON, bmTF1);
# Compiling entire program or any subproject
# ------------------------------------------
-all: checkconf sim_lib
+all: checkconf sim_lib test_mem_speed
+
+test_mem_speed: test_mem_speed.o
+ $(CC) -o $@ $< -L$(PRJDIR) -lsim -lutil
sim.src: all
// prj
#include "i_string.h"
+// sim.src
+#include "simcl.h"
+
// local
#include "appcl.h"
* Program options
*/
-cl_option::cl_option(int atype, char sn, char *ln)
+/*cl_option::cl_option(int atype, char sn, char *ln)
{
type= atype;
short_name= sn;
if (index > values->count - 1)
return(0);
return((char*)(values->at(index)));
-}
+}*/
/* List of options */
-cl_options::cl_options(void):
+/*cl_options::cl_options(void):
cl_list(2, 2)
{
-}
+}*/
/*
cl_app::cl_app(void)
{
- options= new cl_options();
+ //options= new cl_options();
+ sim= 0;
}
cl_app::~cl_app(void)
{
- delete options;
+ //delete options;
+ remove_simulator();
+}
+
+int
+cl_app::init(void)
+{
+ cl_base::init();
+
+ return(0);
+}
+
+/* Main cycle */
+
+int
+cl_app::run(void)
+{
+ return(0);
+}
+
+void
+cl_app::done(void)
+{
+}
+
+
+/* Command handling */
+
+class cl_cmd *
+cl_app::get_cmd(class cl_cmdline *cmdline)
+{
+ return(0);
+}
+
+
+/* Adding and removing comonents */
+
+void
+cl_app::set_simulator(class cl_sim *simulator)
+{
+ if (sim)
+ remove_simulator();
+ sim= simulator;
+
+}
+
+void
+cl_app::remove_simulator(void)
+{
+ if (!sim)
+ return;
+ delete sim;
+ sim= 0;
+}
+
+void
+cl_app::build_cmdset(class cl_cmdset *cs)
+{
+
}
#define OPT_Z80 0x0040
#define OPT_TARGET (OPT_51|OPT_AVR|OPT_Z80)
-class cl_option: public cl_base
+/*class cl_option: public cl_base
{
public:
int type; // See OPT_XXX
{
public:
cl_options(void);
-};
+};*/
/* Application */
class cl_app: public cl_base
{
-public:
- class cl_options *options;
+protected:
+ //class cl_options *options;
+ class cl_sim *sim;
+ class cl_cmdset *cmdset;
public:
cl_app(void);
~cl_app(void);
+
+public:
+ virtual int init(void);
+ virtual int run(void);
+ virtual void done(void);
+
+public:
+ virtual class cl_cmd *get_cmd(class cl_cmdline *cmdline);
+
+public:
+ virtual void set_simulator(class cl_sim *simulator);
+ virtual void remove_simulator(void);
+
+protected:
+ virtual void build_cmdset(class cl_cmdset *cs);
};
}
+/*
+ */
+
+cl_cell::cl_cell(void):
+ cl_base()
+{
+ data= 0;
+}
+
+cl_cell::cl_cell(t_mem idata):
+ cl_base()
+{
+ data= idata;
+}
+
/*
* Memory
******************************************************************************
};
+class cl_cell: public cl_base
+{
+public:
+ t_mem data;
+
+public:
+ cl_cell(void);
+ cl_cell(t_mem idata);
+};
+
/* Memory */
class cl_mem: public cl_guiobj
* Simulator
*/
-cl_sim::cl_sim(char *more_args, int iargc, char *iargv[]):
+cl_sim::cl_sim(class cl_app *the_app,
+ char *more_args, int iargc, char *iargv[]):
cl_base()
{
+ app= the_app;
argc= iargc; argv= iargv;
uc= 0;
cmd= 0;
if (!(uc= mk_controller()))
return(1);
uc->init();
- cmd= new cl_commander(cmdset, this);
+ cmd= new cl_commander(app, cmdset, this);
cmd->init();
char *Config= get_sarg(0, "Config");
if (Config)
class cl_sim: public cl_base
{
+protected:
+ class cl_app *app;
public:
int state; // See SIM_XXXX
int argc; char **argv;
class cl_list *arguments;
public:
- cl_sim(char *more_args, int iargc, char *iargv[]);
+ cl_sim(class cl_app *the_app, char *more_args, int iargc, char *iargv[]);
~cl_sim(void);
virtual int init(void);
--- /dev/null
+#include "memcl.h"
+
+int
+main(void)
+{
+ class cl_mem *mem;
+ t_addr a;
+ t_mem d;
+
+ mem= new cl_mem(MEM_SFR, "egy", 0x10000, 8);
+ for (a= 0; a < mem->size; a++)
+ {
+ t_mem d2= a;
+ mem->write(a, &d2);
+ d= mem->read(a);
+ }
+ return(0);
+}
--- /dev/null
+/*
+ * Simulator of microcontrollers (ucsim.cc)
+ *
+ * Copyright (C) 2001,01 Drotos Daniel, Talker Bt.
+ *
+ * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
+ *
+ */
+
+/* This file is part of microcontroller simulator: ucsim.
+
+UCSIM is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+UCSIM is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with UCSIM; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+/*@1@*/
+
+#include "appcl.h"
+
+int
+main(int argc, char *argv[])
+{
+ class cl_app *app;
+ int ret;
+
+ app= new cl_app();
+ app->init();
+ ret= app->run();
+ app->done();
+ return(ret);
+}
+
+/* End of sim.src/ucsim.cc */
/*@1@*/
+// local
#include "simz80cl.h"
#include "z80cl.h"
-cl_simz80::cl_simz80(char *more_args, int iargc, char *iargv[]):
- cl_sim(more_args, iargc, iargv)
+cl_simz80::cl_simz80(class cl_app *the_app,
+ char *more_args, int iargc, char *iargv[]):
+ cl_sim(the_app, more_args, iargc, iargv)
{}
class cl_uc *
class cl_simz80: public cl_sim
{
public:
- cl_simz80(char *more_args, int iargc, char *iargv[]);
+ cl_simz80(class cl_app *the_app, char *more_args, int iargc, char *iargv[]);
virtual class cl_uc *mk_controller(void);
};
02111-1307, USA. */
/*@1@*/
-#include <stdio.h>
-
-#include "globals.h"
+// sim.src
+#include "appcl.h"
+// local
#include "simz80cl.h"
int
main(int argc, char *argv[])
{
- class cl_sim *sim= new cl_simz80(0, argc, argv);
+ class cl_app *app;
+ class cl_sim *sim;
+
+ app= new cl_app();
+ app->init();
+ sim= new cl_simz80(app, 0, argc, argv);
sim->init();
+ app->set_simulator(sim);
sim->main();
- delete sim;
+ delete app;
return(0);
}