Guest User

Untitled

a guest
Nov 29th, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. /*
  4. Copyright (c) 2016, Stephen J. Leary
  5. All rights reserved.
  6.  
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions are met:
  9. 1. Redistributions of source code must retain the above copyright
  10.    notice, this list of conditions and the following disclaimer.
  11. 2. Redistributions in binary form must reproduce the above copyright
  12.    notice, this list of conditions and the following disclaimer in the
  13.    documentation and/or other materials provided with the distribution.
  14. 3. All advertising materials mentioning features or use of this software
  15.    must display the following acknowledgement:
  16.    This product includes software developed by the <organization>.
  17. 4. Neither the name of the <organization> nor the
  18.    names of its contributors may be used to endorse or promote products
  19.    derived from this software without specific prior written permission.
  20.  
  21. THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
  22. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  25. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  28. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31.  
  32. */
  33.  
  34. module sjl520(
  35.  
  36.            input     CLKCPU,
  37.            input     CLK7M,
  38.  
  39.            input     BG20,
  40.            input     AS20,
  41.            input     DS20,
  42.            input     RW20,
  43.            output    RW00,
  44.  
  45.            
  46.            input [2:0]   FC,
  47.            input [1:0]   SIZ,
  48.  
  49.        input         A0,  
  50.            input [19:16] A,
  51.  
  52.            input     BGACK,
  53.            input     VPA,
  54.            input     DTACK,
  55.  
  56.            output    BG,
  57.            output    LDS,
  58.            output    UDS,
  59.            output    VMA,
  60.            output reg E,
  61.            output    AS,
  62.            output    BERR,
  63.        
  64.            output    DSACK1,
  65.            output    AVEC
  66.        );
  67.        
  68. reg DS20DLY = 1'b1;
  69. reg AS20DLY = 1'b1;
  70. reg RW20DLY = 1'b1;
  71. reg CLK7MB2 = 1'b1;
  72. reg BGACKD1 = 1'b1;
  73. reg BGACKD2 = 1'b1;
  74.  
  75. reg [3:0] Q = 'hF;
  76.  
  77. reg DSACK1_SYNC = 1'b1;
  78. reg VMA_SYNC = 1'b1;
  79.  
  80. initial begin
  81.  
  82. E = 'b0;
  83.  
  84. end
  85.  
  86.  
  87. wire CPUSPACE = &FC;
  88.  
  89. wire CPCS = CPUSPACE & ({A[19:16]} === {4'b0010});
  90. wire BKPT = CPUSPACE & ({A[19:16]} === {4'b0000});
  91. wire IACK = CPUSPACE & ({A[19:16]} === {4'b1111});
  92.    
  93. always @(posedge CLK7M) begin
  94.      
  95.     // Delayed Address Strobes
  96.     AS20DLY <= AS20;
  97.     RW20DLY <= RW20;
  98.     DS20DLY <= DS20;
  99.  
  100.     BGACKD1 <= BGACK;
  101.     BGACKD2 <= BGACKD1;
  102.    
  103.     // 7Mhz Clock divided by 2
  104.     CLK7MB2 <= ~CLK7MB2;
  105.      
  106.    if (Q == 'd9) begin
  107.  
  108.       VMA_SYNC <= 1'b1;
  109.       DSACK1_SYNC <= 1'b1;
  110.       Q <= 'd0;
  111.  
  112.    end else begin
  113.  
  114.       Q <= Q + 'd1;
  115.  
  116.       if (Q == 'd4) begin
  117.      E <= 'b1;      
  118.       end
  119.  
  120.       if (Q == 'd8) begin
  121.         E <= 'b0;
  122.       end
  123.  
  124.       if (Q == 'd2) begin
  125.  
  126.          VMA_SYNC <= VPA | CPUSPACE;
  127.          
  128.       end
  129.      
  130.       if (Q == 'd7) begin
  131.          DSACK1_SYNC <= VMA_SYNC;
  132.       end
  133.      
  134.    end
  135.  
  136. end
  137.  
  138.    
  139. //wire HIGHZ = BG20 | //(BG20 & (AS20DLY | AS20)) | CPUSPACE;
  140. wire HIGHZ = (BG20 & (AS20DLY | AS20)) | CPUSPACE;
  141. wire AS_INT = AS20DLY | AS20;
  142. wire UDS_INT = DS20 | DS20DLY | A0;
  143. wire LDS_INT = DS20 | DS20DLY | ({A0, SIZ[1:0]} == 3'b001);  
  144. wire VMA_INT = VMA_SYNC;  
  145.  
  146. assign RW00 = RW20DLY | RW20;      
  147. assign AS = AS_INT;  
  148. assign UDS =  UDS_INT;
  149. assign LDS =   LDS_INT;
  150. assign VMA =  VMA_INT;
  151.  
  152. assign DSACK1 = CPCS | (AS20DLY | AS20 | (DTACK & DSACK1_SYNC));
  153.    
  154. assign BG = BG20 | AS20DLY | AS20;
  155. assign AVEC = IACK & ~VPA;
  156. //assign BERR = CPCS ? 1'b0 : 1'bz;
  157.  
  158. OBUFT #(
  159. .DRIVE(12), // Specify the output drive strength
  160. .IOSTANDARD("DEFAULT"), // Specify the output I/O standard
  161. .SLEW("SLOW") // Specify the output slew rate
  162. ) OBUFT_inst (
  163. .O(BERR), // Buffer output (connect directly to top-level port)
  164. .I(~CPCS), // Buffer input
  165. .T(~CPCS)
  166. );
  167.      
  168. endmodule
Advertisement
Add Comment
Please, Sign In to add comment