| 1 | 17 | Agner | //////////////////////////////////////////////////////////////////////////////////
 | 
      
         | 2 |  |  | // Engineer:       Agner Fog
 | 
      
         | 3 |  |  | // 
 | 
      
         | 4 |  |  | // Create Date:    2020-06-06
 | 
      
         | 5 |  |  | // Last modified:  2021-08-06
 | 
      
         | 6 |  |  | // Module Name:    config_r64.vh
 | 
      
         | 7 |  |  | // Project Name:   ForwardCom soft core model A
 | 
      
         | 8 |  |  | // Target Devices: Artix 7
 | 
      
         | 9 |  |  | // Tool Versions:  Vivado v. 2020.1
 | 
      
         | 10 |  |  | // License:        CERN-OHL-W v. 2 or later
 | 
      
         | 11 |  |  | // Description:    Configuration parameters 
 | 
      
         | 12 |  |  | //
 | 
      
         | 13 |  |  | // Configuration for 64 bit registers, 32kB data RAM, 64 kB code RAM
 | 
      
         | 14 |  |  | //
 | 
      
         | 15 |  |  | //////////////////////////////////////////////////////////////////////////////////
 | 
      
         | 16 |  |  |  
 | 
      
         | 17 |  |  | `define NUM_VECTOR_UNITS       0       // number of 64-bit vector units or lanes
 | 
      
         | 18 |  |  |  
 | 
      
         | 19 |  |  | // Decide if we have 64 bits support. We can use less resources and have higher speed with the 32 bit version. 
 | 
      
         | 20 |  |  | // If 32 bits: General purpose registers are 32 bits. Temporary operand buffers are 32 bits.
 | 
      
         | 21 |  |  | // Result buses are 32 bits. Results will be 32 bits, even for 64 bit instructions. 
 | 
      
         | 22 |  |  | // The data write buses to data cache and code cache are still 64 bits, using any part of the bus for smaller operand sizes.
 | 
      
         | 23 |  |  | // If 64 bits: General purpose registers are 64 bits. 64 bit operand size is supported.
 | 
      
         | 24 |  |  |  
 | 
      
         | 25 |  |  | // Uncomment this to support 64-bit operand type:
 | 
      
         | 26 |  |  | `define SUPPORT_64BIT
 | 
      
         | 27 |  |  |  
 | 
      
         | 28 |  |  | `ifdef SUPPORT_64BIT
 | 
      
         | 29 |  |  |     `define RB                    64   // size of general purpose registers, 64 bits
 | 
      
         | 30 |  |  |     `define RB1                   63   // index of most significant bit
 | 
      
         | 31 |  |  | `else
 | 
      
         | 32 |  |  |     `define RB                    32   // size of general purpose registers, 32 bits
 | 
      
         | 33 |  |  |     `define RB1                   31   // index of most significant bit
 | 
      
         | 34 |  |  | `endif
 | 
      
         | 35 |  |  |  
 | 
      
         | 36 |  |  | // number of bits used in mask registers must be TAG_WIDTH < MASKSZ <= RB
 | 
      
         | 37 |  |  | `define MASKSZ                  16
 | 
      
         | 38 |  |  | //`define MASKSZ                    32
 | 
      
         | 39 |  |  | //`define MASKSZ                 `RB
 | 
      
         | 40 |  |  |  
 | 
      
         | 41 |  |  |  
 | 
      
         | 42 |  |  | // Clock frequency
 | 
      
         | 43 |  |  | // Xilinx-specific:
 | 
      
         | 44 |  |  | // To change the clock frequency, click on the clock_generator source to open the
 | 
      
         | 45 |  |  | // Vivado Clocking Wizard and set the requested output frequency.
 | 
      
         | 46 |  |  | // Use the timing summary to check if the design can work with this frequency.
 | 
      
         | 47 |  |  | // The frequency defined below must match the frequency set in the clocking wizard: 
 | 
      
         | 48 |  |  | //`define CLOCK_FREQUENCY   68000000   // max clock frequency for 32-bit version
 | 
      
         | 49 |  |  | `define CLOCK_FREQUENCY    58000000   // max clock frequency for 64-bit version
 | 
      
         | 50 |  |  |  
 | 
      
         | 51 |  |  |  
 | 
      
         | 52 |  |  | // Serial input/output BUAD rate. 8 data bits, no parity, 1 stop bit 
 | 
      
         | 53 |  |  | //`define BAUD_RATE      19200
 | 
      
         | 54 |  |  | `define BAUD_RATE        57600
 | 
      
         | 55 |  |  | //`define BAUD_RATE      115200
 | 
      
         | 56 |  |  |  
 | 
      
         | 57 |  |  | // serial input  buffer size is 2**IN_BUFFER_SIZE_LOG2 bytes
 | 
      
         | 58 |  |  | // serial output buffer size is 2**OUT_BUFFER_SIZE_LOG2 bytes
 | 
      
         | 59 |  |  | `define IN_BUFFER_SIZE_LOG2    10      // 1 kbyte
 | 
      
         | 60 |  |  | `define OUT_BUFFER_SIZE_LOG2   11      // 2 kbytes
 | 
      
         | 61 |  |  |  
 | 
      
         | 62 |  |  | // initial code in 64-bit lines. remember to put the second 32-bit word to the left:
 | 
      
         | 63 |  |  | `define LOADER_FILE "loader.mem"       // filename of hex file of machine code for loader
 | 
      
         | 64 |  |  | `define MAX_LOADER_SIZE 32'H200        // >= size of loader code, in 32-bit words. Must be even
 | 
      
         | 65 |  |  | // Loader entry address is the end of code memory - MAX_LOADER_SIZE
 | 
      
         | 66 |  |  | // Restart address is the same address + 1
 | 
      
         | 67 |  |  |  
 | 
      
         | 68 |  |  | // code ram address lines. Each line has one 32-bit word = 4 bytes
 | 
      
         | 69 |  |  | // code ram size = 2**(CODE_ADDR_WIDTH+2)
 | 
      
         | 70 |  |  | //`define CODE_ADDR_WIDTH 13  // 32 kB
 | 
      
         | 71 |  |  | `define CODE_ADDR_WIDTH 14  // 64 kB
 | 
      
         | 72 |  |  | //`define CODE_ADDR_WIDTH 15  // 128 kB
 | 
      
         | 73 |  |  |  
 | 
      
         | 74 |  |  | // data ram address lines. Each line has 1 byte. 
 | 
      
         | 75 |  |  | // data ram size = (2**DATA_ADDR_WIDTH)
 | 
      
         | 76 |  |  | `define DATA_ADDR_WIDTH 15   // 32 kB
 | 
      
         | 77 |  |  |  
 | 
      
         | 78 |  |  | // total address lines for code and data combined, used when writing code. 
 | 
      
         | 79 |  |  | // Total address space = (2**COMMON_ADDR_WIDTH) bytes
 | 
      
         | 80 |  |  | `define COMMON_ADDR_WIDTH ((`CODE_ADDR_WIDTH+2>`DATA_ADDR_WIDTH) ? `CODE_ADDR_WIDTH+3 : `DATA_ADDR_WIDTH+1)
 | 
      
         | 81 |  |  |  
 | 
      
         | 82 |  |  | // The code address space must start immediately after the data address space if IP-addressed data are used without load-time relocation:  
 | 
      
         | 83 |  |  | `define CODE_ADDR_START `DATA_ADDR_WIDTH   // code write address starts at 2**`CODE_ADDR_START = end of data address space
 | 
      
         | 84 |  |  |  
 | 
      
         | 85 |  |  | // code ram bus width
 | 
      
         | 86 |  |  | `define CODE_DATA_WIDTH 64
 | 
      
         | 87 |  |  |  
 | 
      
         | 88 |  |  | // The number of entries in the call stack size is 2**CALL_STACK_POINTER_BITS - 1
 | 
      
         | 89 |  |  | `define CALL_STACK_POINTER_BITS  10
 | 
      
         | 90 |  |  |  
 | 
      
         | 91 |  |  | // number of system registers that behave as g.p. registers (renamed in flight)
 | 
      
         | 92 |  |  | `define NUM_SYS_REGISTERS    3
 | 
      
         | 93 |  |  |  
 | 
      
         | 94 |  |  | // number of bits in instruction ID tag. 
 | 
      
         | 95 |  |  | // The maximum number of instruction tags in flight is 2**TAG_WIDTH - 1  
 | 
      
         | 96 |  |  | `define TAG_WIDTH  5
 | 
      
         | 97 |  |  |  
 | 
      
         | 98 |  |  | // number of error types distinguished
 | 
      
         | 99 |  |  | `define N_ERROR_TYPES  6
 | 
      
         | 100 |  |  |  
 | 
      
         | 101 |  |  | // Input/output port numbers
 | 
      
         | 102 |  |  | `define INPORT_RS232            8      // input port for RS232 serial input
 | 
      
         | 103 |  |  | `define INPORT_RS232_STATUS     9      // input port to read status of RS232 serial input
 | 
      
         | 104 |  |  | `define OUTPORT_RS232          10      // output port for RS232 serial output
 | 
      
         | 105 |  |  | `define OUTPORT_RS232_STATUS   11      // output port for RS232 serial output status
 | 
      
         | 106 |  |  |  
 |