carttst2.tdf 6.44 KB
TITLE "$Id: carttst2.tdf,v 1.1.1.1 2002/05/17 06:07:56 blythe Exp $ Copyright (C) 1994, 1995 Silicon Graphics, Inc.";
%*************************************************************************%
%*                                                                       *%
%*               Copyright (C) 1994, 1995 Silicon Graphics, Inc.         *%
%*                                                                       *%
%*  These coded instructions, statements, and computer programs  contain *%
%*  unpublished  proprietary  information of Silicon Graphics, Inc., and *%
%*  are protected by Federal copyright  law.  They  may not be disclosed *%
%*  to  third  parties  or copied or duplicated in any form, in whole or *%
%*  in part, without the prior written consent of Silicon Graphics, Inc. *%
%*                                                                       *%
%*************************************************************************%

% cycle counts for various cycle types (1 less than actual) %
constant CNT_ADR      = 5;
constant CNT_PGBRK    = 1;
constant CNT_LWAIT    = 5;
constant CNT_RD_WR    = 4;
constant CNT_RELWIDTH = 1;
constant CNT_IDLE     = 9;
 
% switch settings
+  swt1  0 => normal operation
+        1 => reset
+  swt2  0 => 1 pass through memory when swt3 is toggled
+        1 => continuous r/w looping
+  swt3  0 => if swt2 == 1, loop through low half of memory
+        1 => if swt2 == 1, loop through all of memory
+  swt4  0 => if swt2 == 0, write memory
+        1 => if swt2 == 0, read memory
+  swt6,swt5  00 => if swt2 == 0, use checkerboard pattern
+             01 => if swt2 == 0, use inverted checkerboard pattern
+             10 => if swt2 == 0, use address pattern
+             11 => if swt2 == 0, use inverted address pattern
%

subdesign carttst2
(
 clk, swt[6..1]                     : INPUT;
 aleh, alel, rdB, wrB, chk          : OUTPUT;
 ad[15..0]                          : BIDIR;
)

variable
   clock, adr_out[31..0], pagebreak, top_adr, ad_mux[15..0]          : NODE;
   cycleend, pbreak, adrinc, dataoe, count[7..0], nextcnt[7..0],
   r_w, hold_idle, cntzero, prechk[7..0], chk, chkdly                : DFF;
   ad_save[15..0], ad_int[15..0], adr[23..1], pgcnt[3..0],
   invert, save_idle, aleh, alel, wrB, rdB                           : DFFE;
   ad[15..0]                                                         : TRI;


begin
 clock  = global(clk);

 adr_out[31..24] = 0;
 adr_out[23..1]  = adr[];
 adr_out[0]      = GND;
 pagebreak       = (adr_out[13..0] == H"3ffe");
 top_adr         = (adr_out[23..0] == H"fffffe");

 r_w.clk  = clock;
 r_w.clrn = swt[1];
 if (!swt[2]) then             r_w = swt[4];
 elsif (top_adr & adrinc) then r_w = !r_w;
 else                          r_w = r_w;
 end if;
 
 hold_idle.clk = clock;
 hold_idle     = !swt[2] & (swt[3] == save_idle);

 save_idle.clk = clock;
 save_idle.ena = !swt[1] # swt[2] # (top_adr & adrinc);
 save_idle     = swt[3];

 pbreak.clk = clock;
 pbreak     = (adrinc & pagebreak) # (pbreak & !aleh);

 cycleend.clk = clock;
 cycleend     = (adrinc & pagebreak & (pgcnt[] == 15)) # (cycleend & !aleh);

 chk.clk  = clock;
 chk      = (prechk[] != 0) # chkdly;
 
 chkdly.clk = clock;
 chkdly     = (prechk[] != 0);
 
 prechk[].clk = clock;
 prechk[0]    = cntzero & !rdB & (ad[1..0] != ad_save[1..0]);
 prechk[1]    = cntzero & !rdB & (ad[3..2] != ad_save[3..2]);
 prechk[2]    = cntzero & !rdB & (ad[5..4] != ad_save[5..4]);
 prechk[3]    = cntzero & !rdB & (ad[7..6] != ad_save[7..6]);
 prechk[4]    = cntzero & !rdB & (ad[9..8] != ad_save[9..8]);
 prechk[5]    = cntzero & !rdB & (ad[11..10] != ad_save[11..10]);
 prechk[6]    = cntzero & !rdB & (ad[13..12] != ad_save[13..12]);
 prechk[7]    = cntzero & !rdB & (ad[15..14] != ad_save[15..14]);
 
 invert.clk  = clock;
 invert.clrn = swt[1];
 if (!swt[2]) then
    case swt[6..5] is
       WHEN 0 => invert = adr[1];  % checkerboard %
       WHEN 1 => invert = !adr[1]; % checkerboard bar %
       WHEN 2 => invert = gnd;     % address (32 bits) %
       WHEN 3 => invert = vcc;     % address bar (32 bits) %
    end case;
 elsif (top_adr & adrinc & r_w) then invert = !invert;
 else                                 invert = invert;
 end if;

 aleh.clk  = clock;
 aleh.prn  = swt[1];
 aleh.ena  = cntzero;
 !aleh     = alel # (!aleh & !pbreak);

 alel.clk  = clock;
 alel.clrn = swt[1];
 alel.ena  = cntzero;
 alel      = aleh & (!hold_idle # alel);

 rdB.clk  = clock;
 rdB.prn  = swt[1];
 rdB.ena  = cntzero;
 !rdB     = !alel & !aleh & rdB & r_w & !pbreak;

 wrB.clk  = clock;
 wrB.prn  = swt[1];
 wrB.ena  = cntzero;
 !wrB     = !alel & !aleh & wrB & !r_w & !pbreak;

 % downcounter to provide delays for each state %
 count[].clk = clock;
 count[].prn = swt[1];
 if (!cntzero) then                    count[] = count[] - 1;
 elsif (aleh & !alel & hold_idle) then count[] = 0;
 else                                  count[] = nextcnt[];
 end if;

 nextcnt[].clk = clock;
 if    (aleh) then         nextcnt[] = CNT_ADR;
 elsif (!aleh & alel) then nextcnt[] = CNT_LWAIT;
 elsif (cycleend) then     nextcnt[] = CNT_IDLE;
 elsif (pbreak) then       nextcnt[] = CNT_PGBRK;
 elsif (rdB & wrB) then    nextcnt[] = CNT_RD_WR;
 else                      nextcnt[] = CNT_RELWIDTH;
 end if;

 % select for count == 0 %
 cntzero.clk  = clock;
 cntzero      = ((count[] == 0) & hold_idle & aleh & !alel) # (count[] == 1);

 pgcnt[].clk  = clock;
 pgcnt[].clrn = swt[1];
 pgcnt[].ena  = adrinc & pagebreak;
 pgcnt[]      = pgcnt[] + 1;

 adrinc.clk = clock;
 adrinc     =  (count[] == 1) & (!rdB # !wrB);

 adr[].clk  = clock;
 adr[].clrn = swt[1];
 adr[].ena  = adrinc;
 if (swt[2] & !swt[3]) then
    adr[22..1] = adr[22..1] + 1;
    adr[23]    = gnd;
 else
    adr[]      = adr[] + 1;
 end if;

 dataoe.clk = clock;
 dataoe     = alel # !wrB;

 ad[].oe = dataoe;
 ad[]    = ad_int[];

 ad_int[].clk = clock;
 if    (aleh) then         ad_int[] = adr_out[31..16];
 elsif (!aleh & alel) then ad_int[] = adr_out[15..0];
 elsif (invert) then       ad_int[] = !ad_mux[];
 else                      ad_int[] = ad_mux[];
 end if;

 ad_save[].clk = clock;
 if    (aleh) then         ad_save[] = adr_out[31..16];
 elsif (!aleh & alel) then ad_save[] = adr_out[15..0];
 elsif (invert) then       ad_save[] = !ad_mux[];
 else                      ad_save[] = ad_mux[];
 end if;

 if    (!swt[2] & !swt[6]) then ad_mux[]      = H"aaaa";
 elsif (!adr[1]) then           ad_mux[]      = adr_out[31..16];
 else                           ad_mux[15..2] = adr_out[15..2];
                                ad_mux[1..0]  = 0;
 end if;

end;