File:  [gforth] / gforth / arch / misc / misc-sim.v
Revision 1.3: download - view: text, annotated - select for diffs
Fri Dec 31 13:23:59 2004 UTC (19 years, 3 months ago) by anton
Branches: MAIN
CVS tags: HEAD
updated copyright years for files changed in 2004

    1: // misc simulator environment
    2: 
    3: // Copyright (C) 1998,2000,2003,2004 Free Software Foundation, Inc.
    4: 
    5: // This file is part of Gforth.
    6: 
    7: // Gforth is free software; you can redistribute it and/or
    8: // modify it under the terms of the GNU General Public License
    9: // as published by the Free Software Foundation; either version 2
   10: // of the License, or (at your option) any later version.
   11: 
   12: // This program is distributed in the hope that it will be useful,
   13: // but WITHOUT ANY WARRANTY; without even the implied warranty of
   14: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15: // GNU General Public License for more details.
   16: 
   17: // You should have received a copy of the GNU General Public License
   18: // along with this program; if not, write to the Free Software
   19: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   20: 
   21:  `define L [0:l-1]
   22:  
   23: module main;
   24:    parameter l=16, d=10;
   25:    reg clock;
   26:    wire `L addr, data;
   27:    wire csel, rw, read, write;
   28: 
   29:    reg `L mem[0:(1<<l)-1];
   30:    reg [0:7] keys[0:15];
   31:    integer inputq, fileno, start;
   32:    
   33:    initial
   34:     begin
   35:        clock = 0;
   36:        for(start='h0000; start < 'h8000; start=start+1)
   37:          mem[start] = 0;
   38:        $readmemh("kernl-misc.hex", mem);
   39: //       fileno=$fopen("misc.out");
   40:        mem['hffff] = 1;
   41:        mem['hfffe] = 32;
   42:        keys[0]=99;
   43:        keys[1]=114;
   44:        keys[2]=32;
   45:        keys[3]=49;
   46:        keys[4]=32;
   47:        keys[5]=50;
   48:        keys[6]=32;
   49:        keys[7]=43;
   50:        keys[8]=32;
   51:        keys[9]=46;
   52:        keys[10]=13;
   53:        keys[11]=32;
   54:        inputq=0;
   55:        #d clock = 0;
   56:        #d clock = 0;
   57:        forever
   58: 	begin
   59: 	   #d clock = ~clock;
   60: 	end
   61:     end
   62: 
   63:    assign #d
   64:     write = csel & ~rw,
   65:     read  = csel &  rw;
   66:    
   67:    always @(posedge write)
   68:     #d if(addr == 'hfffc) $write("%c", data);
   69:     else
   70:      mem[addr] = data;
   71: 
   72:    assign
   73:     data = (read & ~write) ? mem[addr] : {l{1'bz}};
   74: 
   75:    always @(addr or read or write)
   76:     if(read & ~write & (addr == 'hfffe))
   77:      begin
   78: 	#(d*4)
   79: 	mem['hfffe] = { 8'b0, keys[inputq] };
   80: 	inputq = inputq + 1;
   81: 	if(inputq > 11) $finish;
   82:      end
   83: 
   84:    misc #(l,d)
   85:     misc0(clock, data, addr, csel, rw);
   86:    
   87: endmodule /* main */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>