File:  [gforth] / gforth / arch / misc / misc-sim.v
Revision 1.5: download - view: text, annotated - select for diffs
Mon Dec 31 19:02:25 2007 UTC (14 years, 11 months ago) by anton
Branches: MAIN
CVS tags: v0-7-0, HEAD
updated copyright year after changing license notice

    1: // misc simulator environment
    2: 
    3: // Copyright (C) 1998,2000,2003,2004,2007 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 3
   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, see http://www.gnu.org/licenses/.
   19: 
   20:  `define L [0:l-1]
   21:  
   22: module main;
   23:    parameter l=16, d=10;
   24:    reg clock;
   25:    wire `L addr, data;
   26:    wire csel, rw, read, write;
   27: 
   28:    reg `L mem[0:(1<<l)-1];
   29:    reg [0:7] keys[0:15];
   30:    integer inputq, fileno, start;
   31:    
   32:    initial
   33:     begin
   34:        clock = 0;
   35:        for(start='h0000; start < 'h8000; start=start+1)
   36:          mem[start] = 0;
   37:        $readmemh("kernl-misc.hex", mem);
   38: //       fileno=$fopen("misc.out");
   39:        mem['hffff] = 1;
   40:        mem['hfffe] = 32;
   41:        keys[0]=99;
   42:        keys[1]=114;
   43:        keys[2]=32;
   44:        keys[3]=49;
   45:        keys[4]=32;
   46:        keys[5]=50;
   47:        keys[6]=32;
   48:        keys[7]=43;
   49:        keys[8]=32;
   50:        keys[9]=46;
   51:        keys[10]=13;
   52:        keys[11]=32;
   53:        inputq=0;
   54:        #d clock = 0;
   55:        #d clock = 0;
   56:        forever
   57: 	begin
   58: 	   #d clock = ~clock;
   59: 	end
   60:     end
   61: 
   62:    assign #d
   63:     write = csel & ~rw,
   64:     read  = csel &  rw;
   65:    
   66:    always @(posedge write)
   67:     #d if(addr == 'hfffc) $write("%c", data);
   68:     else
   69:      mem[addr] = data;
   70: 
   71:    assign
   72:     data = (read & ~write) ? mem[addr] : {l{1'bz}};
   73: 
   74:    always @(addr or read or write)
   75:     if(read & ~write & (addr == 'hfffe))
   76:      begin
   77: 	#(d*4)
   78: 	mem['hfffe] = { 8'b0, keys[inputq] };
   79: 	inputq = inputq + 1;
   80: 	if(inputq > 11) $finish;
   81:      end
   82: 
   83:    misc #(l,d)
   84:     misc0(clock, data, addr, csel, rw);
   85:    
   86: endmodule /* main */

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