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

Subversion Repositories tms1000

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

/tms1000/trunk/assembler/Makefile
0,0 → 1,62
# Makefile for CASM package
 
# -----------------------------------------------------------------------------
# You may need to change the following definitions. In particular you will
# need to remove the -DUSE_TIMER if you don't have the setitimer() system
# call, and you may need to chage X11LIBS and X11INCS if X isn't in /usr/X11.
#
# If you are using a version of Flex later than 2.4.1 you can optionally
# remove the "-DOLD_FLEX" from CFLAGS, resulting in a completely imperceptible
# performance improvement in CASM.
# -----------------------------------------------------------------------------
 
CC = gcc
CFLAGS = -g -Dstricmp=strcasecmp -DUSE_TIMER -DENTER_KEY_MOD -DOLD_FLEX
 
YACC = bison
YFLAGS = -d -y
 
# YACC = yacc
# YFLAGS = -d
 
LEX = flex
 
# -----------------------------------------------------------------------------
# You shouldn't have to change anything below this point, but if you do please
# let me know why so I can improve this Makefile.
# -----------------------------------------------------------------------------
 
PROGRAMS = casm
 
HEADERS = casm.h symtab.h xio.h
SOURCES = casm.c casml.l casmy.y symtab.c
 
OBJECTS = casm.o symtab.o lex.yy.o y.tab.o
 
INTERMEDIATE = lex.yy.c y.tab.c y.tab.h
 
all: $(PROGRAMS)
 
casm: $(OBJECTS)
$(CC) -o $@ $(OBJECTS)
 
casm.o: casm.c casm.h
$(CC) -c $(CFLAGS) -o $@ $<
 
lex.yy.o: lex.yy.c casm.h symtab.h y.tab.h
$(CC) -c $(CFLAGS) -o $@ $<
 
lex.yy.c: casml.l
$(LEX) $(LFLAGS) $<
 
y.tab.o: y.tab.c casm.h symtab.h
$(CC) -c $(CFLAGS) -o $@ $<
 
y.tab.c y.tab.h: casmy.y
$(YACC) $(YFLAGS) $<
 
symtab.o: symtab.c symtab.h
$(CC) -c $(CFLAGS) -o $@ $<
 
clean:
rm -f $(PROGRAMS) $(OBJECTS) $(INTERMEDIATE)
/tms1000/trunk/assembler/casm.c
0,0 → 1,388
/*
casm.c
 
CASM is an assembler for the tms1000 processor.
*/
 
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "symtab.h"
#include "casm.h"
 
char *progname;
int pass;
int lineno;
int errors;
int warnings;
 
int group; /* current rom group */
int rom; /* current rom */
int pc; /* current pc */
 
int dsr; /* delayed select rom */
int dsg; /* delayed select group */
 
char flag_char;
 
int objflag; /* used to remember args to emit() */
int objcode;
 
int symtab_flag;
 
int last_instruction_type;
 
 
int targflag; /* used to remember args to target() */
int targgroup;
int targrom;
int targpc;
 
char linebuf [MAX_LINE];
char *lineptr;
 
#define MAX_ERRBUF 2048
char errbuf [MAX_ERRBUF];
char *errptr;
 
#define SRC_TAB 32
char listbuf [MAX_LINE];
char *listptr;
 
#ifndef PATH_MAX
#define PATH_MAX 256
#endif
 
char srcfn [PATH_MAX];
char objfn [PATH_MAX];
char listfn [PATH_MAX];
 
FILE *srcfile = NULL;
FILE *objfile = NULL;
FILE *listfile = NULL;
 
t_symtab symtab /*[MAXGROUP] [MAXROM]*/; /* separate symbol tables for each ROM */
 
void format_listing (void)
{
int i;
sprintf (listptr, "%4d ", lineno);
listptr += strlen (listptr);
 
if (objflag)
{
sprintf (listptr, "L%03x: ", (rom << 6)+pc);
listptr += strlen (listptr);
for (i = 0x80; i; i >>= 1)
*listptr++ = (objcode & i) ? '1' : '.';
*listptr = '\0';
}
else
{
strcat (listptr, " ");
listptr += strlen (listptr);
}
 
if (targflag)
{
sprintf (listptr, " -> L%1o%1o%03o", targgroup, targrom, targpc);
listptr += strlen (listptr);
}
else
{
strcat (listptr, " ");
listptr += strlen (listptr);
}
sprintf (listptr, " %c%c%c%c%c ", flag_char, flag_char, flag_char,
flag_char, flag_char);
listptr += strlen (listptr);
strcat (listptr, linebuf);
listptr += strlen (listptr);
}
 
void do_pass (int p)
{
int i;
 
pass = p;
lineno = 0;
errors = 0;
warnings = 0;
pc = 0;
dsr = rom;
dsg = group;
last_instruction_type = OTHER_INST;
 
printf ("Pass %d rom", pass);
 
while (fgets (linebuf, MAX_LINE, srcfile))
{
/* remove newline */
i = strlen (linebuf);
if (linebuf [i - 1] == '\n')
linebuf [i - 1] = '\0';
 
lineno++;
lineptr = & linebuf [0];
 
listptr = & listbuf [0];
listbuf [0] = '\0';
 
errptr = & errbuf [0];
errbuf [0] = '\0';
 
objflag = 0;
targflag = 0;
flag_char = ' ';
symtab_flag = 0;
 
yyparse ();
 
if (pass == 2)
{
if (symtab_flag)
print_symbol_table (symtab, listfile);
else
{
format_listing ();
fprintf (listfile, "%s\n", listbuf);
if (errptr != & errbuf [0])
{
fprintf (stderr, "%s\n", listbuf);
fprintf (listfile, "%s", errbuf);
fprintf (stderr, "%s", errbuf);
}
}
}
 
if (objflag) {
pc = ((pc != 31) && ((pc >> 4) != 0) && (((pc & 0xf) == 15) || ((pc >> 4) != 3))) ? (pc << 1) : (pc << 1)+1;
pc = pc & 0x3f;
}
//pc = (pc + 1) & 0xff;
}
 
printf ("\n");
}
 
void munge_filename (char *dst, char *src, char *ext)
{
int i;
int lastdot = 0;
for (i = 0; src [i]; i++)
{
if (src [i] == '.')
lastdot = i;
}
if (lastdot == 0)
lastdot = strlen (src);
memcpy (dst, src, lastdot);
dst [lastdot] = '\0';
strcat (dst, ext);
}
 
int main (int argc, char *argv[])
{
progname = argv [0];
 
if (argc != 2)
{
fprintf (stderr, "Usage: %s sourcefile\n", progname);
exit (1);
}
 
symtab = alloc_symbol_table ();
if (! symtab )
fatal ("symbol table allocation failed\n");
 
strcpy (srcfn, argv [1]);
 
srcfile = fopen (srcfn, "r");
 
if (! srcfile)
fatal ("can't open input file '%s'\n", srcfn);
 
munge_filename (objfn, srcfn, ".mem");
munge_filename (listfn, srcfn, ".lst");
 
objfile = fopen (objfn, "w");
 
if (! objfile)
fatal ("can't open input file '%s'\n", objfn);
 
listfile = fopen (listfn, "w");
 
if (! listfile)
fatal ("can't open listing file '%s'\n", listfn);
 
rom = 0;
group = 0;
 
do_pass (1);
 
rewind (srcfile);
 
do_pass (2);
 
err_printf ("%d errors, %d warnings\n", errors, warnings);
 
fclose (srcfile);
fclose (objfile);
fclose (listfile);
}
 
void yyerror (char *s)
{
error ("%s\n", s);
}
 
void do_label (char *s)
{
int prev_val;
 
if (pass == 1)
{
if (! create_symbol (symtab, s, (rom << 6) + pc, lineno))
error ("multiply defined symbol '%s'\n", s);
}
else if (! lookup_symbol (symtab, s, & prev_val))
error ("undefined symbol '%s'\n", s);
else if (prev_val != ((rom << 6) + pc))
error ("phase error for symbol '%s'\n", s);
}
 
static void emit_core (int op, int inst_type)
{
objcode = op;
objflag = 1;
last_instruction_type = inst_type;
 
if ((pass == 2) && objfile)
fprintf (objfile, "@%03x %02x\n", (rom<<6)+pc, op);
}
 
void emit (int op)
{
emit_core (op, OTHER_INST);
}
 
void emit_arith (int op)
{
emit_core (op, ARITH_INST);
}
 
void emit_test (int op)
{
emit_core (op, TEST_INST);
}
 
void target (int g, int r, int p)
{
targflag = 1;
targgroup = g;
targrom = r;
targpc = p;
}
 
int range (int val, int min, int max)
{
if ((val < min) || (val > max))
{
error ("value out of range [%d to %d], using %d", min, max, min);
return min;
}
return val;
}
 
char *newstr (char *orig)
{
int len;
char *r;
 
len = strlen (orig);
r = (char *) malloc (len + 1);
if (! r)
fatal ("memory allocation failed\n");
 
memcpy (r, orig, len + 1);
return (r);
}
 
/*
* print to both listing error buffer and standard error
*
* Use this for general messages. Don't use this for warnings or errors
* generated by a particular line of the source file. Use error() or
* warning() for that.
*/
int err_vprintf (char *format, va_list ap)
{
int res;
 
if (listfile)
vfprintf (listfile, format, ap);
res = vfprintf (stderr, format, ap);
return (res);
}
 
int err_printf (char *format, ...)
{
int res;
va_list ap;
 
va_start (ap, format);
res = err_vprintf (format, ap);
va_end (ap);
return (res);
}
 
 
/* generate fatal error message to stderr, doesn't return */
void fatal (char *format, ...)
{
va_list ap;
 
fprintf (stderr, "fatal error: ");
va_start (ap, format);
vfprintf (stderr, format, ap);
va_end (ap);
exit (2);
}
 
 
/* generate error or warning messages and increment appropriate counter */
/* actually just puts the message into the error buffer */
int error (char *format, ...)
{
int res;
va_list ap;
 
err_printf ("error in file %s line %d: ", srcfn, lineno);
va_start (ap, format);
res = err_vprintf (format, ap);
va_end (ap);
errptr += res;
errors ++;
return (res);
}
 
int warning (char *format, ...)
{
int res;
va_list ap;
 
err_printf ("warning in file %s line %d: ", srcfn, lineno);
va_start (ap, format);
res = err_vprintf (format, ap);
va_end (ap);
errptr += res;
warnings ++;
return (res);
}
 
 
/tms1000/trunk/assembler/casm.exe Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
tms1000/trunk/assembler/casm.exe Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: tms1000/trunk/assembler/casm.h =================================================================== --- tms1000/trunk/assembler/casm.h (nonexistent) +++ tms1000/trunk/assembler/casm.h (revision 2) @@ -0,0 +1,72 @@ +/* +casm.h + +CASM is an assembler for the tms1000 processor. +*/ + +extern int pass; +extern int lineno; +extern int errors; + +extern int group; /* current rom group */ +extern int rom; /* current rom */ +extern int pc; /* current pc */ + +extern int dsr; /* delayed select rom */ +extern int dsg; /* delayed select group */ + +extern char flag_char; /* used to mark jumps across rom banks */ + +extern int symtab_flag; + + +#define OTHER_INST 0 +#define ARITH_INST 1 +#define TEST_INST 2 + +extern int last_instruction_type; + + +#define MAX_LINE 256 +extern char linebuf [MAX_LINE]; +extern char *lineptr; + +#define MAXGROUP 2 +#define MAXROM 8 +extern t_symtab symtab /*[MAXGROUP] [MAXROM]*/; /* separate symbol tables for each ROM */ + +void do_label (char *s); + + +void emit (int op); /* use for instructions that never set carry */ +void emit_arith (int op); /* use for arithmetic instructions that may set carry */ +void emit_test (int op); /* use for test instructions that + + +void etarget (int targrom, int targpc); /* for branch target info */ + +/* + * Check that val is in the range [min, max]. If so, return val. + * If not, issue an error and return min. + */ +int range (int val, int min, int max); + +char *newstr (char *orig); +void format_listing (void); + +/* + * print to both listing error buffer and standard error + * + * Use this for general messages. Don't use this for warnings or errors + * generated by a particular line of the source file. Use error() or + * warning() for that. + */ +int err_printf (char *format, ...); + +/* generate error or warning messages and increment appropriate counter */ +int error (char *format, ...); +int warning (char *format, ...); + +/* generate fatal error message to stderr, doesn't return */ +void fatal (char *format, ...); + Index: tms1000/trunk/assembler/casml.l =================================================================== --- tms1000/trunk/assembler/casml.l (nonexistent) +++ tms1000/trunk/assembler/casml.l (revision 2) @@ -0,0 +1,134 @@ +/* +casm.l: lexical analyzer specification + +CASM is an assembler for the TMS1000 processor. +*/ + +%{ +#include "y.tab.h" +#include "symtab.h" +#include "casm.h" + +#ifdef OLD_FLEX +#undef yywrap +/* Only needed for versions of flex prior to 2.4.1. */ +int yywrap (void); +#endif /* OLD_FLEX */ + +#undef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + { \ + int r = strlen (lineptr); \ + if (r > max_size) \ + r = max_size; \ + memcpy (buf, lineptr, r); \ + lineptr += r; \ + result = r; \ + } +#if 0 + fprintf (stderr, "yy_input: '%s', %d\n", lineptr, r); \ + +#endif +%} + +octaldig [0-7] +hexdigit [0-9a-fA-F] +digit [0-9] +alpha [a-zA-Z] +alphanum [a-zA-Z0-9_] + +%% +{digit}+ { yylval.integer = atoi (yytext); return INTEGER; } + +@{hexdigit} { sscanf (yytext+1, "%x", &yylval.integer); return INTEGER; } + +{alpha}{alphanum}* { + if (yylval.integer = keyword (yytext)) + return yylval.integer; + yylval.string = newstr (yytext); + return IDENT; + } + + +\;.* ; +[ \t]+ ; +\n ; +. { return yytext [0]; } + +%% + +struct keyword +{ + char *name; + int value; +} +keywords [] = +{ + "br", BR , + "call", CALL , + "calll", CALLL, + "clo", CLO , + "comx", COMX , + "ldp", LDP , + "ldx", LDX , + "sbit", SBIT , + "rbit", RBIT , + "retn", RETN , + "rstr", RSTR , + "setr", SETR , + "tdo", TDO , + "alec", ALEC , + "alem", ALEM , + "amaac", AMAAC, + "a6aac", A6AAC, + "a8aac", A8AAC, + "a10aac", A10AAC, + "cla", CLA , + "cpaiz", CPAIZ, + "dan", DAN , + "dman", DMAN , + "dyn", DYN , + "ia", IA , + "imac", IMAC , + "iyc", IYC , + "knez", KNEZ , + "mnez", MNEZ , + "saman", SAMAN, + "tam", TAM , + "tamiy", TAMIY, + "tamza", TAMZA, + "tay", TAY , + "tbit1", TBIT1, + "tcy", TCY , + "tcmiy", TCMIY, + "tka", TKA , + "tma", TMA , + "tmy", TMY , + "tya", TYA , + "xma", XMA , + "ynea", YNEA , + "ynec", YNEC , + "bl", BL , + "rom", ROM , + "symtab", SYMTAB, + NULL, 0, +}; + +int keyword (char *string) +{ + struct keyword *ptr; + + for (ptr = keywords; ptr->name; ptr++) + if (stricmp (string, ptr->name) == 0) + return ptr->value; + return 0; +} + +int yywrap (void) +{ +#ifdef OLD_FLEX +/* Only needed for versions of flex prior to 2.4.1. */ + yyrestart (yyin); +#endif /* OLD_FLEX */ + return (1); +} Index: tms1000/trunk/assembler/casmy.y =================================================================== --- tms1000/trunk/assembler/casmy.y (nonexistent) +++ tms1000/trunk/assembler/casmy.y (revision 2) @@ -0,0 +1,211 @@ +/* +casm.y: grammar + +CASM is an assembler for the TMS1000 processor. +*/ + +%{ +#include +#include "symtab.h" +#include "casm.h" +int bitreverse4[]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15}; +int bitreverse2[]={0,2,1,3}; +%} + +%union { + int integer; + char *string; + } + + +%token INTEGER +%token IDENT + +%token BR +%token CALL +%token CALLL +%token CLO +%token COMX +%token LDP +%token LDX +%token SBIT +%token RBIT +%token RETN +%token RSTR +%token SETR +%token TDO +%token ALEC +%token ALEM +%token AMAAC +%token A6AAC +%token A8AAC +%token A10AAC +%token CLA +%token CPAIZ +%token DAN +%token DMAN +%token DYN +%token IA +%token IMAC +%token IYC +%token KNEZ +%token MNEZ +%token SAMAN +%token TAM +%token TAMIY +%token TAMZA +%token TAY +%token TBIT1 +%token TCY +%token TCMIY +%token TKA +%token TMA +%token TMY +%token TYA +%token XMA +%token YNEA +%token YNEC +%token BL +%token ROM +%token SYMTAB + +%type expr + +%% + +line : label instruction + | label + | instruction + | pseudo_op + | + | error + ; + +label: IDENT ':' { do_label ($1); } + ; + +expr : INTEGER { $$ = $1; } + | IDENT { if (pass == 1) + $$ = 0; + else if (! lookup_symbol (symtab, $1, &$$)) + { + error ("undefined symbol '%s'\n", $1); + $$ = 0; + } + } + ; +pseudo_op : ps_rom + | ps_symtab + ; + +ps_rom : '.' ROM expr { /*$3 = range ($3, 0, MAXGROUP * MAXROM - 1); + group = dsg = ($3 >> 3); + rom = dsr = ($3 & 7); */ + rom = $3; + pc = 0; + last_instruction_type = OTHER_INST; + printf (" %d", $3); } + ; + +ps_symtab : '.' SYMTAB { symtab_flag = 1; } + ; + +instruction : inst_br + | inst_bl + | inst_call + | inst_calll + | inst_clo + | inst_comx + | inst_ldp + | inst_ldx + | inst_sbit + | inst_rbit + | inst_retn + | inst_rstr + | inst_setr + | inst_tdo + | inst_alec + | inst_alem + | inst_amaac + | inst_a6aac + | inst_a8aac + | inst_a10aac + | inst_cla + | inst_cpaiz + | inst_dan + | inst_dman + | inst_dyn + | inst_ia + | inst_imac + | inst_iyc + | inst_knez + | inst_mnez + | inst_saman + | inst_tam + | inst_tamiy + | inst_tamza + | inst_tay + | inst_tbit1 + | inst_tcy + | inst_tcmiy + | inst_tka + | inst_tma + | inst_tmy + | inst_tya + | inst_xma + | inst_ynea + | inst_ynec + ; + +inst_br : BR expr { emit (0x80 | ($2 & 0x3f)); } ; +inst_bl : BL expr { emit (0x10 | bitreverse4[(($2 & 0x3c0) >> 6)]); + pc = ((pc != 31) && ((pc >> 4) != 0) && (((pc & 0xf) == 15) || ((pc >> 4) != 3))) ? (pc << 1) : (pc << 1)+1; + pc = pc & 0x3f; + emit (0x80 | ($2 & 0x3f)); } ; +inst_call : CALL expr { emit (0xc0 | ($2 & 0x3f)); } ; +inst_calll : CALLL expr { emit (0x10 | bitreverse4[(($2 & 0x3c0) >> 6)]); + pc = ((pc != 31) && ((pc >> 4) != 0) && (((pc & 0xf) == 15) || ((pc >> 4) != 3))) ? (pc << 1) : (pc << 1)+1; + pc = pc & 0x3f; + emit (0xc0 | ($2 & 0x3f)); } ; +inst_clo : CLO { emit (0x0b); } ; +inst_comx : COMX { emit (0x00); } ; +inst_ldp : LDP expr { emit (0x10 | bitreverse4[($2 & 0xf)]); } ; +inst_ldx : LDX expr { emit (0x3c | bitreverse2[($2 & 0x3)]); } ; +inst_sbit : SBIT expr { emit (0x30 | bitreverse2[($2 & 0x3)]); } ; +inst_rbit : RBIT expr { emit (0x34 | bitreverse2[($2 & 0x3)]); } ; +inst_retn : RETN { emit (0x0f); } ; +inst_rstr : RSTR { emit (0x0c); } ; +inst_setr : SETR { emit (0x0d); } ; +inst_tdo : TDO { emit (0x0a); } ; +inst_alec : ALEC expr { emit (0x70 | bitreverse4[($2 & 0xf)]); } ; +inst_alem : ALEM { emit (0x29); } ; +inst_amaac : AMAAC { emit (0x25); } ; +inst_a6aac : A6AAC { emit (0x06); } ; +inst_a8aac : A8AAC { emit (0x01); } ; +inst_a10aac : A10AAC { emit (0x05); } ; +inst_cla : CLA { emit (0x2f); } ; +inst_cpaiz : CPAIZ { emit (0x2d); } ; +inst_dan : DAN { emit (0x07); } ; +inst_dman : DMAN { emit (0x2a); } ; +inst_dyn : DYN { emit (0x2c); } ; +inst_ia : IA { emit (0x0e); } ; +inst_imac : IMAC { emit (0x28); } ; +inst_iyc : IYC { emit (0x2b); } ; +inst_knez : KNEZ { emit (0x09); } ; +inst_mnez : MNEZ { emit (0x26); } ; +inst_saman : SAMAN { emit (0x27); } ; +inst_tam : TAM { emit (0x03); } ; +inst_tamiy : TAMIY { emit (0x20); } ; +inst_tamza : TAMZA { emit (0x04); } ; +inst_tay : TAY { emit (0x24); } ; +inst_tbit1 : TBIT1 expr { emit (0x38 | bitreverse2[($2 & 0x3)]); } ; +inst_tcy : TCY expr { emit (0x40 | bitreverse4[($2 & 0xf)]); } ; +inst_tcmiy : TCMIY expr { emit (0x60 | bitreverse4[($2 & 0xf)]); } ; +inst_tka : TKA { emit (0x08); } ; +inst_tma : TMA { emit (0x21); } ; +inst_tmy : TMY { emit (0x22); } ; +inst_tya : TYA { emit (0x23); } ; +inst_xma : XMA { emit (0x2e); } ; +inst_ynea : YNEA { emit (0x02); } ; +inst_ynec : YNEC expr { emit (0x50 | bitreverse4[($2 & 0xf)]); } ; +%% Index: tms1000/trunk/assembler/icalc.asm =================================================================== --- tms1000/trunk/assembler/icalc.asm (nonexistent) +++ tms1000/trunk/assembler/icalc.asm (revision 2) @@ -0,0 +1,326 @@ +.rom @0 + lock : tka + kin : alec 7 + br k1 + a8aac + k1 : retn + alec 0 + br reset + br lock + + reset : tcy 6 + re1 : rstr + dyn + br re1 + + disp : tcy 6 + br scan2 + + scan1 : tya + tcy 12 + tamiy + + tka + tbit1 1 + br clok + call kin + alec 0 + br nok + + delay : dan + br delay + dyn + br delay + call lock + alec 0 + br nok + bl key + + noclk : rbit 0 + nok : tcy 12 + tmy + dyn ;fetch 1 + + + scan2 : tma + iyc + rstr + dyn + tdo + + setr + ynec 15 + br scan1 + br disp + + clok : alec 7 + br noclk + tbit1 0 + br nok + + sbit 0 + tcy 6 + tst2 : ldp 1 + mnez + br clk1 + ldp 0 + dyn + br tst2 + + + tya + ynea + + tcy 13 + tcmiy 0 + br nok + br lock + br lock +.rom @1 + clk1 : tcy 14 + imac + alec 9 + br clk3 + tcmiy 0 + imac + alec 5 + br clk3 + + tcmiy 0 + clk2 : dman + br clk3 + tcmiy 9 + br clk2 + + clk3 : tam + bl nok +.rom @2 + key : tcy 6 + clen : xma + alec 9 + br clen1 + cla + clen1 : xma + dyn + br clen + + tcy 13 + ldp 3 + alec 1 + br func + + + ldp 2 + tbit1 3 + br ne_1 + sbit 3 + calll creg + + + ne_1 : tcy 12 + xma + tbit1 2 + br k4in + + a6aac + k4in : tcy 5 + mnez + br exnum + calll ldata + + exnum : bl blank + +.rom @3 + func : rbit 3 + tcy 12 + dman + br not_0 + + + tcy 13 + sbit 1 + ynea + bl lock + + not_0 : ldp 15 + alec 0 + br cler + ldp 6 + alec 1 + br trab + ldp 4 + alec 2 + br plus + alec 3 + br mins + ldp 7 + alec 4 + br mult + + divid : ldx 1 + calll creg + + d1 : calll sbaa + alec 0 + br incc + tcy 0 + trca : ldx 1 + tma + ldx 0 + tamiy + ynec 7 + br trca + bl blank + + incc : ldx 1 + tcy 0 + d2 : imac + tam + alec 9 + br d1 + tcmiy 0 + br d2 +.rom @4 + plus : calll aaba + + tob : bl blank + + mins : calll sbaa + + alec 0 + br tob + + calll creg + br tob + +.rom @5 + aaba : ldx 0 + tcy 0 + cla + ad1 : comx + amaac + comx + amaac + br gt9 + alec 9 + br lt10 + gt9 : a6aac + tamza + ia + incy : iyc + ynec 7 + br ad1 + retn + lt10 : tamza + br incy + + + sbaa : ldx 0 + tcy 0 + cla + s1 : comx + amaac + comx + saman + br nobor + a10aac + tamza + ia + incys : iyc + ynec 7 + br s1 + retn + + nobor : tamza + br incys + +.rom @6 + trac : tcy 0 + t1 : ldx 0 + tma + ldx 1 + tamiy + ynec 7 + br t1 + retn + + trab : ldx 3 + tr0 : tcy 0 + t2 : comx + tma + comx + tamiy + ynec 7 + br t2 + retn + bl blank + + rshft : cla + tcy 6 + r1 : xma + dyn + br r1 + retn +.rom @7 + mult : calll trac + tcmiy 6 + ldx 0 + calll creg + ml2 : ldx 1 + tcy 7 + tmy + dman + br nobr + tcy 7 + dman + br ml1 + bl blank + ml1 : tam + ldx 0 + + + lshft : cla + ldata : tcy 0 + l1 : xma + iyc + ynec 7 + br l1 + retn + + br ml2 + nobr : tam + calll aaba + br ml2 + + +.rom @f + cla + tcy 0 + ynea + cler : ldx 3 + call creg + ldx 1 + call creg + ldx 0 + + clall : tcy 7 + br c1 + + creg : tcy 0 + c1 : tcmiy 0 + ynec 7 + br c1 + retn + + + blank : ldx 0 + tcy 6 + bl1 : mnez + br brlck + tcmiy 15 + dyn + dyn + br bl1 + brlck : bl lock + + .symtab Index: tms1000/trunk/assembler/symtab.c =================================================================== --- tms1000/trunk/assembler/symtab.c (nonexistent) +++ tms1000/trunk/assembler/symtab.c (revision 2) @@ -0,0 +1,139 @@ +/* +symtab.c: a simple binary tree symbol table + +CASM is an assembler for the TMS1000 processor. +*/ + +#include +#include +#include "symtab.h" + +typedef struct sym +{ + char *name; + int value; + int lineno; + struct sym *left; + struct sym *right; +} sym; + +static char *newstr (char *orig) +{ + int len; + char *r; + + len = strlen (orig); + r = (char *) malloc (len + 10); + + if (! r) + { + fprintf (stderr, "memory allocation failed\n"); + exit (2); + } + + memcpy (r, orig, len + 1); + return (r); +} + +t_symtab alloc_symbol_table (void) +{ + sym **table; + table = (sym **) calloc (1, sizeof (sym *)); + return (table); +} + +static void free_entry (sym *p) +{ + if (p->left) + free_entry (p->left); + if (p->right) + free_entry (p->right); + free (p); +} + +void free_symbol_table (t_symtab t) +{ + sym **table = t; + free_entry (*table); + free (table); +} + +static int insert_symbol (sym **p, sym *newsym) +{ + int i; + + if (! *p) + { + (*p) = newsym; + return (1); + } + + i = stricmp (newsym->name, (*p)->name); + + if (i == 0) + return (0); + else if (i < 0) + return (insert_symbol (& ((*p)->left), newsym)); + else + return (insert_symbol (& ((*p)->right), newsym)); +} + + +/* returns 1 for success, 0 if duplicate name */ +int create_symbol (t_symtab t, char *name, int value, int lineno) +{ + sym **table = t; + sym *p = *table; + sym *newsym; + + newsym = (sym *) calloc (1, sizeof (sym)); + if (! newsym) + { + fprintf (stderr, "memory allocation failure\n"); + exit (2); + } + + newsym->name = newstr (name); + newsym->value = value; + newsym->lineno = lineno; + + return (insert_symbol (table, newsym)); +} + +/* returns 1 for success, 0 if not found */ +int lookup_symbol (t_symtab t, char *name, int *value) +{ + sym **table = t; + sym *p = *table; + int i; + + while (p) + { + i = stricmp (name, p->name); + if (i == 0) + { + *value = p->value; + return (1); + } + if (i < 0) + p = p->left; + else + p = p->right; + } + return (0); +} + +static void print_symbols (FILE *f, sym *p) +{ + if (! p) + return; + print_symbols (f, p->left); + fprintf (f, "%03x %s %d\n", p->value, p->name, p->lineno); + print_symbols (f, p->right); +} + +void print_symbol_table (t_symtab t, FILE *f) +{ + sym **table = t; + print_symbols (f, *table); +} Index: tms1000/trunk/assembler/symtab.h =================================================================== --- tms1000/trunk/assembler/symtab.h (nonexistent) +++ tms1000/trunk/assembler/symtab.h (revision 2) @@ -0,0 +1,21 @@ +/* +symtab.h: a simple binary tree symbol table + +CASM is an assembler for the TMS1000 processor. +*/ + +typedef void * t_symtab; + +/* create a symbol table, returns handle to be passed in to all other calls */ +t_symtab alloc_symbol_table (void); + +/* free a symbol table */ +void free_symbol_table (t_symtab t); + +/* returns 1 for success, 0 if duplicate name */ +int create_symbol (t_symtab t, char *name, int value, int lineno); + +/* returns 1 for success, 0 if not found */ +int lookup_symbol (t_symtab t, char *name, int *value); + +void print_symbol_table (t_symtab t, FILE *f); Index: tms1000/trunk/assembler/test.asm =================================================================== --- tms1000/trunk/assembler/test.asm (nonexistent) +++ tms1000/trunk/assembler/test.asm (revision 2) @@ -0,0 +1,29 @@ +.rom @f + cla + tay + ynea +disp : tcy 7 +dis1 : dyn + tma + iyc + rstr + dyn + tdo + setr + knez + br exit + ynec 15 + br dis1 + br disp +exit : cla + + + + + cla + tya +loop: tamiy + tya + br loop + + Index: tms1000/trunk/rtl/icalc.asm =================================================================== --- tms1000/trunk/rtl/icalc.asm (nonexistent) +++ tms1000/trunk/rtl/icalc.asm (revision 2) @@ -0,0 +1,326 @@ +.rom @0 + lock : tka + kin : alec 7 + br k1 + a8aac + k1 : retn + alec 0 + br reset + br lock + + reset : tcy 6 + re1 : rstr + dyn + br re1 + + disp : tcy 6 + br scan2 + + scan1 : tya + tcy 12 + tamiy + + tka + tbit1 1 + br clok + call kin + alec 0 + br nok + + delay : dan + br delay + dyn + br delay + call lock + alec 0 + br nok + bl key + + noclk : rbit 0 + nok : tcy 12 + tmy + dyn ;fetch 1 + + + scan2 : tma + iyc + rstr + dyn + tdo + + setr + ynec 15 + br scan1 + br disp + + clok : alec 7 + br noclk + tbit1 0 + br nok + + sbit 0 + tcy 6 + tst2 : ldp 1 + mnez + br clk1 + ldp 0 + dyn + br tst2 + + + tya + ynea + + tcy 13 + tcmiy 0 + br nok + br lock + br lock +.rom @1 + clk1 : tcy 14 + imac + alec 9 + br clk3 + tcmiy 0 + imac + alec 5 + br clk3 + + tcmiy 0 + clk2 : dman + br clk3 + tcmiy 9 + br clk2 + + clk3 : tam + bl nok +.rom @2 + key : tcy 6 + clen : xma + alec 9 + br clen1 + cla + clen1 : xma + dyn + br clen + + tcy 13 + ldp 3 + alec 1 + br func + + + ldp 2 + tbit1 3 + br ne_1 + sbit 3 + calll creg + + + ne_1 : tcy 12 + xma + tbit1 2 + br k4in + + a6aac + k4in : tcy 5 + mnez + br exnum + calll ldata + + exnum : bl blank + +.rom @3 + func : rbit 3 + tcy 12 + dman + br not_0 + + + tcy 13 + sbit 1 + ynea + bl lock + + not_0 : ldp 15 + alec 0 + br cler + ldp 6 + alec 1 + br trab + ldp 4 + alec 2 + br plus + alec 3 + br mins + ldp 7 + alec 4 + br mult + + divid : ldx 1 + calll creg + + d1 : calll sbaa + alec 0 + br incc + tcy 0 + trca : ldx 1 + tma + ldx 0 + tamiy + ynec 7 + br trca + bl blank + + incc : ldx 1 + tcy 0 + d2 : imac + tam + alec 9 + br d1 + tcmiy 0 + br d2 +.rom @4 + plus : calll aaba + + tob : bl blank + + mins : calll sbaa + + alec 0 + br tob + + calll creg + br tob + +.rom @5 + aaba : ldx 0 + tcy 0 + cla + ad1 : comx + amaac + comx + amaac + br gt9 + alec 9 + br lt10 + gt9 : a6aac + tamza + ia + incy : iyc + ynec 7 + br ad1 + retn + lt10 : tamza + br incy + + + sbaa : ldx 0 + tcy 0 + cla + s1 : comx + amaac + comx + saman + br nobor + a10aac + tamza + ia + incys : iyc + ynec 7 + br s1 + retn + + nobor : tamza + br incys + +.rom @6 + trac : tcy 0 + t1 : ldx 0 + tma + ldx 1 + tamiy + ynec 7 + br t1 + retn + + trab : ldx 3 + tr0 : tcy 0 + t2 : comx + tma + comx + tamiy + ynec 7 + br t2 + retn + bl blank + + rshft : cla + tcy 6 + r1 : xma + dyn + br r1 + retn +.rom @7 + mult : calll trac + tcmiy 6 + ldx 0 + calll creg + ml2 : ldx 1 + tcy 7 + tmy + dman + br nobr + tcy 7 + dman + br ml1 + bl blank + ml1 : tam + ldx 0 + + + lshft : cla + ldata : tcy 0 + l1 : xma + iyc + ynec 7 + br l1 + retn + + br ml2 + nobr : tam + calll aaba + br ml2 + + +.rom @f + cla + tcy 0 + ynea + cler : ldx 3 + call creg + ldx 1 + call creg + ldx 0 + + clall : tcy 7 + br c1 + + creg : tcy 0 + c1 : tcmiy 0 + ynec 7 + br c1 + retn + + + blank : ldx 0 + tcy 6 + bl1 : mnez + br brlck + tcmiy 15 + dyn + dyn + br bl1 + brlck : bl lock + + .symtab Index: tms1000/trunk/rtl/icalc.lst =================================================================== --- tms1000/trunk/rtl/icalc.lst (nonexistent) +++ tms1000/trunk/rtl/icalc.lst (revision 2) @@ -0,0 +1,388 @@ + 1 .rom @0 + 2 L000: ....1... lock : tka + 3 L001: .111111. kin : alec 7 + 4 L003: 1...1111 br k1 + 5 L007: .......1 a8aac + 6 L00f: ....1111 k1 : retn + 7 L01f: .111.... alec 0 + 8 L03f: 1.1111.1 br reset + 9 L03e: 1....... br lock + 10 + 11 L03d: .1...11. reset : tcy 6 + 12 L03b: ....11.. re1 : rstr + 13 L037: ..1.11.. dyn + 14 L02f: 1.111.11 br re1 + 15 + 16 L01e: .1...11. disp : tcy 6 + 17 L03c: 1....11. br scan2 + 18 + 19 L039: ..1...11 scan1 : tya + 20 L033: .1....11 tcy 12 + 21 L027: ..1..... tamiy + 22 + 23 L00e: ....1... tka + 24 L01d: ..111.1. tbit1 1 + 25 L03a: 1.1..1.. br clok + 26 L035: 11.....1 call kin + 27 L02b: .111.... alec 0 + 28 L016: 1.111... br nok + 29 + 30 L02c: .....111 delay : dan + 31 L018: 1.1.11.. br delay + 32 L030: ..1.11.. dyn + 33 L021: 1.1.11.. br delay + 34 L002: 11...... call lock + 35 L005: .111.... alec 0 + 36 L00b: 1.111... br nok + 37 L02e: 1....... bl key + 38 + 39 L01c: ..11.1.. noclk : rbit 0 + 40 L038: .1....11 nok : tcy 12 + 41 L031: ..1...1. tmy + 42 L023: ..1.11.. dyn ;fetch 1 + 43 + 44 + 45 L006: ..1....1 scan2 : tma + 46 L00d: ..1.1.11 iyc + 47 L01b: ....11.. rstr + 48 L036: ..1.11.. dyn + 49 L02d: ....1.1. tdo + 50 + 51 L01a: ....11.1 setr + 52 L034: .1.11111 ynec 15 + 53 L029: 1.111..1 br scan1 + 54 L012: 1..1111. br disp + 55 + 56 L024: .111111. clok : alec 7 + 57 L008: 1..111.. br noclk + 58 L011: ..111... tbit1 0 + 59 L022: 1.111... br nok + 60 + 61 L004: ..11.... sbit 0 + 62 L009: .1...11. tcy 6 + 63 L013: ...11... tst2 : ldp 1 + 64 L026: ..1..11. mnez + 65 L00c: 1....... br clk1 + 66 L019: ...1.... ldp 0 + 67 L032: ..1.11.. dyn + 68 L025: 1..1..11 br tst2 + 69 + 70 + 71 L00a: ..1...11 tya + 72 L015: ......1. ynea + 73 + 74 L02a: .1..1.11 tcy 13 + 75 L014: .11..... tcmiy 0 + 76 L028: 1.111... br nok + 77 L010: 1....... br lock + 78 L020: 1....... br lock + 79 .rom @1 + 80 L040: .1...111 clk1 : tcy 14 + 81 L041: ..1.1... imac + 82 L043: .1111..1 alec 9 + 83 L047: 1.1111.. br clk3 + 84 L04f: .11..... tcmiy 0 + 85 L05f: ..1.1... imac + 86 L07f: .1111.1. alec 5 + 87 L07e: 1.1111.. br clk3 + 88 + 89 L07d: .11..... tcmiy 0 + 90 L07b: ..1.1.1. clk2 : dman + 91 L077: 1.1111.. br clk3 + 92 L06f: .11.1..1 tcmiy 9 + 93 L05e: 1.111.11 br clk2 + 94 + 95 L07c: ......11 clk3 : tam + 96 L073: 1.111... bl nok + 97 .rom @2 + 98 L080: .1...11. key : tcy 6 + 99 L081: ..1.111. clen : xma + 100 L083: .1111..1 alec 9 + 101 L087: 1..11111 br clen1 + 102 L08f: ..1.1111 cla + 103 L09f: ..1.111. clen1 : xma + 104 L0bf: ..1.11.. dyn + 105 L0be: 1......1 br clen + 106 + 107 L0bd: .1..1.11 tcy 13 + 108 L0bb: ...111.. ldp 3 + 109 L0b7: .1111... alec 1 + 110 L0af: 1....... br func + 111 + 112 + 113 L09e: ...1.1.. ldp 2 + 114 L0bc: ..111.11 tbit1 3 + 115 L0b9: 1..111.1 br ne_1 + 116 L0b3: ..11..11 sbit 3 + 117 L08e: 1111.111 calll creg + 118 + 119 + 120 L09d: .1....11 ne_1 : tcy 12 + 121 L0ba: ..1.111. xma + 122 L0b5: ..111..1 tbit1 2 + 123 L0ab: 1.1.11.. br k4in + 124 + 125 L096: .....11. a6aac + 126 L0ac: .1..1.1. k4in : tcy 5 + 127 L098: ..1..11. mnez + 128 L0b0: 1....1.1 br exnum + 129 L082: 11111.1. calll ldata + 130 + 131 L08b: 1.11..11 exnum : bl blank + 132 + 133 .rom @3 + 134 L0c0: ..11.111 func : rbit 3 + 135 L0c1: .1....11 tcy 12 + 136 L0c3: ..1.1.1. dman + 137 L0c7: 1.111.11 br not_0 + 138 + 139 + 140 L0cf: .1..1.11 tcy 13 + 141 L0df: ..11..1. sbit 1 + 142 L0ff: ......1. ynea + 143 L0fd: 1....... bl lock + 144 + 145 L0fb: ...11111 not_0 : ldp 15 + 146 L0f7: .111.... alec 0 + 147 L0ef: 1....111 br cler + 148 L0de: ...1.11. ldp 6 + 149 L0fc: .1111... alec 1 + 150 L0f9: 1.1111.1 br trab + 151 L0f3: ...1..1. ldp 4 + 152 L0e7: .111.1.. alec 2 + 153 L0ce: 1....... br plus + 154 L0dd: .11111.. alec 3 + 155 L0fa: 1...1111 br mins + 156 L0f5: ...1111. ldp 7 + 157 L0eb: .111..1. alec 4 + 158 L0d6: 1....... br mult + 159 + 160 L0ec: ..11111. divid : ldx 1 + 161 L0f0: 1111.111 calll creg + 162 + 163 L0c2: 11111.1. d1 : calll sbaa + 164 L0c5: .111.... alec 0 + 165 L0cb: 1.11.11. br incc + 166 L0d7: .1...... tcy 0 + 167 L0ee: ..11111. trca : ldx 1 + 168 L0dc: ..1....1 tma + 169 L0f8: ..1111.. ldx 0 + 170 L0f1: ..1..... tamiy + 171 L0e3: .1.1111. ynec 7 + 172 L0c6: 1.1.111. br trca + 173 L0db: 1.11..11 bl blank + 174 + 175 L0f6: ..11111. incc : ldx 1 + 176 L0ed: .1...... tcy 0 + 177 L0da: ..1.1... d2 : imac + 178 L0f4: ......11 tam + 179 L0e9: .1111..1 alec 9 + 180 L0d2: 1.1....1 br d1 + 181 L0e4: .11..... tcmiy 0 + 182 L0c8: 1..11.1. br d2 + 183 .rom @4 + 184 L101: 11...... plus : calll aaba + 185 + 186 L107: 1.11..11 tob : bl blank + 187 + 188 L11f: 11111.1. mins : calll sbaa + 189 + 190 L13f: .111.... alec 0 + 191 L13e: 1.....11 br tob + 192 + 193 L13b: 1111.111 calll creg + 194 L137: 1.....11 br tob + 195 + 196 .rom @5 + 197 L140: ..1111.. aaba : ldx 0 + 198 L141: .1...... tcy 0 + 199 L143: ..1.1111 cla + 200 L147: ........ ad1 : comx + 201 L14f: ..1..1.1 amaac + 202 L15f: ........ comx + 203 L17f: ..1..1.1 amaac + 204 L17e: 1.11.111 br gt9 + 205 L17d: .1111..1 alec 9 + 206 L17b: 1...111. br lt10 + 207 L177: .....11. gt9 : a6aac + 208 L16f: .....1.. tamza + 209 L15e: ....111. ia + 210 L17c: ..1.1.11 incy : iyc + 211 L179: .1.1111. ynec 7 + 212 L173: 1....111 br ad1 + 213 L167: ....1111 retn + 214 L14e: .....1.. lt10 : tamza + 215 L15d: 1.1111.. br incy + 216 + 217 + 218 L17a: ..1111.. sbaa : ldx 0 + 219 L175: .1...... tcy 0 + 220 L16b: ..1.1111 cla + 221 L156: ........ s1 : comx + 222 L16c: ..1..1.1 amaac + 223 L158: ........ comx + 224 L170: ..1..111 saman + 225 L161: 1.11...1 br nobor + 226 L142: .....1.1 a10aac + 227 L145: .....1.. tamza + 228 L14b: ....111. ia + 229 L157: ..1.1.11 incys : iyc + 230 L16e: .1.1111. ynec 7 + 231 L15c: 1..1.11. br s1 + 232 L178: ....1111 retn + 233 + 234 L171: .....1.. nobor : tamza + 235 L163: 1..1.111 br incys + 236 + 237 .rom @6 + 238 L180: .1...... trac : tcy 0 + 239 L181: ..1111.. t1 : ldx 0 + 240 L183: ..1....1 tma + 241 L187: ..11111. ldx 1 + 242 L18f: ..1..... tamiy + 243 L19f: .1.1111. ynec 7 + 244 L1bf: 1......1 br t1 + 245 L1be: ....1111 retn + 246 + 247 L1bd: ..111111 trab : ldx 3 + 248 L1bb: .1...... tr0 : tcy 0 + 249 L1b7: ........ t2 : comx + 250 L1af: ..1....1 tma + 251 L19e: ........ comx + 252 L1bc: ..1..... tamiy + 253 L1b9: .1.1111. ynec 7 + 254 L1b3: 1.11.111 br t2 + 255 L1a7: ....1111 retn + 256 L19d: 1.11..11 bl blank + 257 + 258 L1ba: ..1.1111 rshft : cla + 259 L1b5: .1...11. tcy 6 + 260 L1ab: ..1.111. r1 : xma + 261 L196: ..1.11.. dyn + 262 L1ac: 1.1.1.11 br r1 + 263 L198: ....1111 retn + 264 .rom @7 + 265 L1c1: 11...... mult : calll trac + 266 L1c3: .11..11. tcmiy 6 + 267 L1c7: ..1111.. ldx 0 + 268 L1df: 1111.111 calll creg + 269 L1ff: ..11111. ml2 : ldx 1 + 270 L1fe: .1..111. tcy 7 + 271 L1fd: ..1...1. tmy + 272 L1fb: ..1.1.1. dman + 273 L1f7: 1.1....1 br nobr + 274 L1ef: .1..111. tcy 7 + 275 L1de: ..1.1.1. dman + 276 L1fc: 1.1..111 br ml1 + 277 L1f3: 1.11..11 bl blank + 278 L1e7: ......11 ml1 : tam + 279 L1ce: ..1111.. ldx 0 + 280 + 281 + 282 L1dd: ..1.1111 lshft : cla + 283 L1fa: .1...... ldata : tcy 0 + 284 L1f5: ..1.111. l1 : xma + 285 L1eb: ..1.1.11 iyc + 286 L1d6: .1.1111. ynec 7 + 287 L1ec: 1.11.1.1 br l1 + 288 L1d8: ....1111 retn + 289 + 290 L1f0: 1.111111 br ml2 + 291 L1e1: ......11 nobr : tam + 292 L1c5: 11...... calll aaba + 293 L1cb: 1.111111 br ml2 + 294 + 295 + 296 .rom @f + 297 L3c0: ..1.1111 cla + 298 L3c1: .1...... tcy 0 + 299 L3c3: ......1. ynea + 300 L3c7: ..111111 cler : ldx 3 + 301 L3cf: 1111.111 call creg + 302 L3df: ..11111. ldx 1 + 303 L3ff: 1111.111 call creg + 304 L3fe: ..1111.. ldx 0 + 305 + 306 L3fd: .1..111. clall : tcy 7 + 307 L3fb: 1.1.1111 br c1 + 308 + 309 L3f7: .1...... creg : tcy 0 + 310 L3ef: .11..... c1 : tcmiy 0 + 311 L3de: .1.1111. ynec 7 + 312 L3fc: 1.1.1111 br c1 + 313 L3f9: ....1111 retn + 314 + 315 + 316 L3f3: ..1111.. blank : ldx 0 + 317 L3e7: .1...11. tcy 6 + 318 L3ce: ..1..11. bl1 : mnez + 319 L3dd: 1.1.11.. br brlck + 320 L3fa: .11.1111 tcmiy 15 + 321 L3f5: ..1.11.. dyn + 322 L3eb: ..1.11.. dyn + 323 L3d6: 1...111. br bl1 + 324 L3d8: 1....... brlck : bl lock + 325 +140 aaba 197 +147 ad1 200 +3ce bl1 318 +3f3 blank 316 +3ec brlck 324 +3ef c1 310 +3fd clall 306 +081 clen 99 +09f clen1 103 +3c7 cler 300 +040 clk1 80 +07b clk2 90 +07c clk3 95 +024 clok 56 +3f7 creg 309 +0e1 d1 163 +0da d2 177 +02c delay 30 +01e disp 16 +0ec divid 160 +085 exnum 131 +0c0 func 134 +177 gt9 207 +0f6 incc 175 +17c incy 210 +157 incys 229 +00f k1 6 +0ac k4in 126 +080 key 98 +001 kin 3 +1f5 l1 284 +1fa ldata 283 +000 lock 2 +1dd lshft 282 +14e lt10 214 +10f mins 188 +1e7 ml1 278 +1ff ml2 269 +1c0 mult 265 +09d ne_1 120 +171 nobor 234 +1e1 nobr 291 +01c noclk 39 +038 nok 40 +0fb not_0 145 +100 plus 184 +1ab r1 260 +03b re1 12 +03d reset 11 +1ba rshft 258 +156 s1 221 +17a sbaa 218 +039 scan1 19 +006 scan2 45 +181 t1 239 +1b7 t2 249 +103 tob 186 +1bb tr0 248 +1bd trab 247 +180 trac 238 +0ee trca 167 +013 tst2 63 +0 errors, 0 warnings Index: tms1000/trunk/rtl/icalc.mem =================================================================== --- tms1000/trunk/rtl/icalc.mem (nonexistent) +++ tms1000/trunk/rtl/icalc.mem (revision 2) @@ -0,0 +1,284 @@ +@000 08 +@001 7e +@003 8f +@007 01 +@00f 0f +@01f 70 +@03f bd +@03e 80 +@03d 46 +@03b 0c +@037 2c +@02f bb +@01e 46 +@03c 86 +@039 23 +@033 43 +@027 20 +@00e 08 +@01d 3a +@03a a4 +@035 c1 +@02b 70 +@016 b8 +@02c 07 +@018 ac +@030 2c +@021 ac +@002 c0 +@005 70 +@00b b8 +@017 14 +@02e 80 +@01c 34 +@038 43 +@031 22 +@023 2c +@006 21 +@00d 2b +@01b 0c +@036 2c +@02d 0a +@01a 0d +@034 5f +@029 b9 +@012 9e +@024 7e +@008 9c +@011 38 +@022 b8 +@004 30 +@009 46 +@013 18 +@026 26 +@00c 80 +@019 10 +@032 2c +@025 93 +@00a 23 +@015 02 +@02a 4b +@014 60 +@028 b8 +@010 80 +@020 80 +@040 47 +@041 28 +@043 79 +@047 bc +@04f 60 +@05f 28 +@07f 7a +@07e bc +@07d 60 +@07b 2a +@077 bc +@06f 69 +@05e bb +@07c 03 +@079 10 +@073 b8 +@080 46 +@081 2e +@083 79 +@087 9f +@08f 2f +@09f 2e +@0bf 2c +@0be 81 +@0bd 4b +@0bb 1c +@0b7 78 +@0af 80 +@09e 14 +@0bc 3b +@0b9 9d +@0b3 33 +@0a7 1f +@08e f7 +@09d 43 +@0ba 2e +@0b5 39 +@0ab ac +@096 06 +@0ac 4a +@098 26 +@0b0 85 +@0a1 1e +@082 fa +@085 1f +@08b b3 +@0c0 37 +@0c1 43 +@0c3 2a +@0c7 bb +@0cf 4b +@0df 32 +@0ff 02 +@0fe 10 +@0fd 80 +@0fb 1f +@0f7 70 +@0ef 87 +@0de 16 +@0fc 78 +@0f9 bd +@0f3 12 +@0e7 74 +@0ce 80 +@0dd 7c +@0fa 8f +@0f5 1e +@0eb 72 +@0d6 80 +@0ec 3e +@0d8 1f +@0f0 f7 +@0e1 1a +@0c2 fa +@0c5 70 +@0cb b6 +@0d7 40 +@0ee 3e +@0dc 21 +@0f8 3c +@0f1 20 +@0e3 5e +@0c6 ae +@0cd 1f +@0db b3 +@0f6 3e +@0ed 40 +@0da 28 +@0f4 03 +@0e9 79 +@0d2 a1 +@0e4 60 +@0c8 9a +@100 1a +@101 c0 +@103 1f +@107 b3 +@10f 1a +@11f fa +@13f 70 +@13e 83 +@13d 1f +@13b f7 +@137 83 +@140 3c +@141 40 +@143 2f +@147 00 +@14f 25 +@15f 00 +@17f 25 +@17e b7 +@17d 79 +@17b 8e +@177 06 +@16f 04 +@15e 0e +@17c 2b +@179 5e +@173 87 +@167 0f +@14e 04 +@15d bc +@17a 3c +@175 40 +@16b 2f +@156 00 +@16c 25 +@158 00 +@170 27 +@161 b1 +@142 05 +@145 04 +@14b 0e +@157 2b +@16e 5e +@15c 96 +@178 0f +@171 04 +@163 97 +@180 40 +@181 3c +@183 21 +@187 3e +@18f 20 +@19f 5e +@1bf 81 +@1be 0f +@1bd 3f +@1bb 40 +@1b7 00 +@1af 21 +@19e 00 +@1bc 20 +@1b9 5e +@1b3 b7 +@1a7 0f +@18e 1f +@19d b3 +@1ba 2f +@1b5 46 +@1ab 2e +@196 2c +@1ac ab +@198 0f +@1c0 16 +@1c1 c0 +@1c3 66 +@1c7 3c +@1cf 1f +@1df f7 +@1ff 3e +@1fe 4e +@1fd 22 +@1fb 2a +@1f7 a1 +@1ef 4e +@1de 2a +@1fc a7 +@1f9 1f +@1f3 b3 +@1e7 03 +@1ce 3c +@1dd 2f +@1fa 40 +@1f5 2e +@1eb 2b +@1d6 5e +@1ec b5 +@1d8 0f +@1f0 bf +@1e1 03 +@1c2 1a +@1c5 c0 +@1cb bf +@3c0 2f +@3c1 40 +@3c3 02 +@3c7 3f +@3cf f7 +@3df 3e +@3ff f7 +@3fe 3c +@3fd 4e +@3fb af +@3f7 40 +@3ef 60 +@3de 5e +@3fc af +@3f9 0f +@3f3 3c +@3e7 46 +@3ce 26 +@3dd ac +@3fa 6f +@3f5 2c +@3eb 2c +@3d6 8e +@3ec 10 +@3d8 80 Index: tms1000/trunk/rtl/tms1000.tcl =================================================================== --- tms1000/trunk/rtl/tms1000.tcl (nonexistent) +++ tms1000/trunk/rtl/tms1000.tcl (revision 2) @@ -0,0 +1,328 @@ +# This file is part of TMS1000 CPU +# +# tms1000.tcl - Run script and GUI frontend of the TMS1000 +# processor based calculator +# +# Written By - Nand Gates (2021) +# +# This program 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, or (at your option) any +# later version. +# +# This program 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. +# +# In other words, you are welcome to use, share and improve this program. +# You are forbidden to forbid anyone else to use, share and improve +# what you give them. Help stamp out software-hoarding! + +proc start_running {} { + global clock_running + if { $clock_running == 0 } { + set clock_running 1 + run_clock + } +} + +proc run_clock {} { + + global clock_running clk_count + + if { $clock_running == 1 } { + paint_displays + after 20 run_clock + } +# changed to 50 for demo +} + +proc paint_displays {} { + update_display .topwindow.disp.display_1 [ run_command examine_display_1 ] + update_display .topwindow.disp.display_2 [ run_command examine_display_2 ] + update_display .topwindow.disp.display_3 [ run_command examine_display_3 ] + update_display .topwindow.disp.display_4 [ run_command examine_display_4 ] + update_display .topwindow.disp.display_5 [ run_command examine_display_5 ] + update_display .topwindow.disp.display_6 [ run_command examine_display_6 ] +} + + +proc CreateWindow. {args} { + + + # Window manager configurations + destroy .topwindow + toplevel .topwindow -width 700 -height 350 + + wm title .topwindow "Calculator Simulator" + wm protocol .topwindow WM_DELETE_WINDOW close_window + +# wm geometry .topwindow 80000+100+100 + +# Create_Menubar .topwindow menubar + + set height 20 + frame .topwindow.disp -width 640 -height 120 -borderwidth 4 + pack .topwindow.disp -side top + +# create the sevensegment displays + create_display .topwindow.disp.display_1 + create_display .topwindow.disp.display_2 + create_display .topwindow.disp.display_3 + create_display .topwindow.disp.display_4 + create_display .topwindow.disp.display_5 + create_display .topwindow.disp.display_6 + + place .topwindow.disp.display_6 -relx 0.1 + place .topwindow.disp.display_5 -relx 0.2 + place .topwindow.disp.display_4 -relx 0.3 + place .topwindow.disp.display_3 -relx 0.4 + place .topwindow.disp.display_2 -relx 0.5 + place .topwindow.disp.display_1 -relx 0.6 + + frame .topwindow.keyboard -width 450 -height 800 -borderwidth 4 + pack .topwindow.keyboard -side top + + # build widget .pb1 + button .topwindow.keyboard.pb1 -background {#AEAEB2B2C3C3} -font {Helvetica 10} \ + -foreground {#000000000000} -text {Start} + + button .topwindow.keyboard.exit \ + -background {#AEAEB2B2C3C3} -font {Helvetica 10} \ + -foreground {#000000000000} -text {exit} -command {run_command exit} + + + bind .topwindow.keyboard.pb1

powered by: WebSVN 2.1.0

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