1 |
15 |
Agner |
//////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Engineer: Agner Fog
|
3 |
|
|
//
|
4 |
|
|
// Create Date: 2020-06-06
|
5 |
|
|
// Last modified: 2021-08-07
|
6 |
|
|
// Module Name: config_r32.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 32 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 |
|
|
// You may experiment with different values here until you chance upon an optimal timing
|
38 |
|
|
`define MASKSZ 18
|
39 |
|
|
//`define MASKSZ 32
|
40 |
|
|
//`define MASKSZ `RB
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
// Clock frequency
|
44 |
|
|
// Xilinx-specific:
|
45 |
|
|
// To change the clock frequency, click on the clock_generator source to open the
|
46 |
|
|
// Vivado Clocking Wizard and set the requested output frequency.
|
47 |
|
|
// Use the timing summary to check if the design can work with this frequency.
|
48 |
|
|
// The frequency defined below must match the frequency set in the clocking wizard:
|
49 |
|
|
`define CLOCK_FREQUENCY 68000000 // max clock frequency for 32-bit version
|
50 |
|
|
//`define CLOCK_FREQUENCY 58000000 // max clock frequency for 64-bit version
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
// Serial input/output BUAD rate. 8 data bits, no parity, 1 stop bit
|
54 |
|
|
//`define BAUD_RATE 19200
|
55 |
|
|
`define BAUD_RATE 57600
|
56 |
|
|
//`define BAUD_RATE 115200
|
57 |
|
|
|
58 |
|
|
// serial input buffer size is 2**IN_BUFFER_SIZE_LOG2 bytes
|
59 |
|
|
// serial output buffer size is 2**OUT_BUFFER_SIZE_LOG2 bytes
|
60 |
|
|
`define IN_BUFFER_SIZE_LOG2 10 // 1 kbyte
|
61 |
|
|
`define OUT_BUFFER_SIZE_LOG2 11 // 2 kbytes
|
62 |
|
|
|
63 |
|
|
// initial code in 64-bit lines. remember to put the second 32-bit word to the left:
|
64 |
|
|
`define LOADER_FILE "loader.mem" // filename of hex file of machine code for loader
|
65 |
|
|
`define MAX_LOADER_SIZE 32'H200 // >= size of loader code, in 32-bit words. Must be even
|
66 |
|
|
// Loader entry address is the end of code memory - MAX_LOADER_SIZE
|
67 |
|
|
// Restart address is the same address + 1
|
68 |
|
|
|
69 |
|
|
// code ram address lines. Each line has one 32-bit word = 4 bytes
|
70 |
|
|
// code ram size = 2**(CODE_ADDR_WIDTH+2)
|
71 |
|
|
//`define CODE_ADDR_WIDTH 13 // 32 kB
|
72 |
|
|
`define CODE_ADDR_WIDTH 14 // 64 kB
|
73 |
|
|
//`define CODE_ADDR_WIDTH 15 // 128 kB
|
74 |
|
|
|
75 |
|
|
// data ram address lines. Each line has 1 byte.
|
76 |
|
|
// data ram size = (2**DATA_ADDR_WIDTH)
|
77 |
|
|
`define DATA_ADDR_WIDTH 15 // 32 kB
|
78 |
|
|
|
79 |
|
|
// total address lines for code and data combined, used when writing code.
|
80 |
|
|
// Total address space = (2**COMMON_ADDR_WIDTH) bytes
|
81 |
|
|
`define COMMON_ADDR_WIDTH ((`CODE_ADDR_WIDTH+2>`DATA_ADDR_WIDTH) ? `CODE_ADDR_WIDTH+3 : `DATA_ADDR_WIDTH+1)
|
82 |
|
|
|
83 |
|
|
// The code address space must start immediately after the data address space if IP-addressed data are used without load-time relocation:
|
84 |
|
|
`define CODE_ADDR_START `DATA_ADDR_WIDTH // code write address starts at 2**`CODE_ADDR_START = end of data address space
|
85 |
|
|
|
86 |
|
|
// code ram bus width
|
87 |
|
|
`define CODE_DATA_WIDTH 64
|
88 |
|
|
|
89 |
|
|
// The number of entries in the call stack size is 2**CALL_STACK_POINTER_BITS - 1
|
90 |
|
|
`define CALL_STACK_POINTER_BITS 10
|
91 |
|
|
|
92 |
|
|
// number of system registers that behave as g.p. registers (renamed in flight)
|
93 |
|
|
`define NUM_SYS_REGISTERS 3
|
94 |
|
|
|
95 |
|
|
// number of bits in instruction ID tag.
|
96 |
|
|
// The maximum number of instruction tags in flight is 2**TAG_WIDTH - 1
|
97 |
|
|
`define TAG_WIDTH 5
|
98 |
|
|
|
99 |
|
|
// number of error types distinguished
|
100 |
|
|
`define N_ERROR_TYPES 6
|
101 |
|
|
|
102 |
|
|
// Input/output port numbers
|
103 |
|
|
`define INPORT_RS232 8 // input port for RS232 serial input
|
104 |
|
|
`define INPORT_RS232_STATUS 9 // input port to read status of RS232 serial input
|
105 |
|
|
`define OUTPORT_RS232 10 // output port for RS232 serial output
|
106 |
|
|
`define OUTPORT_RS232_STATUS 11 // output port for RS232 serial output status
|
107 |
|
|
|