1 |
43 |
Revanth |
## The ZAP Soft Processor (ARMv5T Compatible)
|
2 |
26 |
Revanth |
|
3 |
|
|
#### Author : Revanth Kamaraj (revanth91kamaraj@gmail.com)
|
4 |
|
|
|
5 |
43 |
Revanth |
### Introduction
|
6 |
26 |
Revanth |
|
7 |
43 |
Revanth |
The ZAP processor is a 10 stage pipelined processor for FPGA with support for cache and MMU (ARMv5T compliant).
|
8 |
26 |
Revanth |
|
9 |
43 |
Revanth |
#### Features
|
10 |
26 |
Revanth |
|
11 |
43 |
Revanth |
##### ZAP Processor (zap_top.v)
|
12 |
26 |
Revanth |
|
13 |
43 |
Revanth |
The ZAP core is a pipelined ATMv5T processor for FPGA.
|
14 |
26 |
Revanth |
|
15 |
43 |
Revanth |
| Property | Description |
|
16 |
|
|
|-----------------------|-------------------------|
|
17 |
|
|
|HDL | Verilog-2001 |
|
18 |
|
|
|Author | Revanth Kamaraj |
|
19 |
|
|
|ARM v5T ISA Support | Fully compatible |
|
20 |
|
|
|Branch Predictor | Direct mapped bimodal |
|
21 |
|
|
|Write Buffer | Yes |
|
22 |
|
|
|Abort Model | Base Restored |
|
23 |
|
|
|Integrated v5T CP15 | Yes |
|
24 |
|
|
|External Coproc. Bus | No |
|
25 |
|
|
|Cache Interface | 128-Bit custom interface|
|
26 |
|
|
|26-Bit Support | No |
|
27 |
|
|
|L1 Code Cache | Direct mapped virtual |
|
28 |
|
|
|L1 Data Cache | Direct mapped virtual |
|
29 |
|
|
|Cache Write Policy | Writeback |
|
30 |
|
|
|L1 Code TLB | Direct mapped |
|
31 |
|
|
|L1 Data TLB | Direct mapped |
|
32 |
|
|
|Bus Interface | 32-bit Wishbone B3 Linear incrementing burst |
|
33 |
|
|
|Cache/TLB Lock Support | No |
|
34 |
|
|
|CP15 Compliance | v5T (No fine pages) |
|
35 |
|
|
|FCSE Support | Yes |
|
36 |
26 |
Revanth |
|
37 |
43 |
Revanth |
* 10-stage pipeline design. Pipeline has bypass network to resolve dependencies. Most operations execute at a rate of 1 operation per clock.
|
38 |
|
|
* 2 write ports for the register file to allow LDR/STR with writeback to execute as a single instruction.
|
39 |
26 |
Revanth |
|
40 |
43 |
Revanth |
#### CPU Configuration (zap_top.v)
|
41 |
|
|
|
42 |
|
|
| Parameter | Default| Description |
|
43 |
|
|
|--------------------------|--------|-------------|
|
44 |
|
|
| BP_ENTRIES | 1024 | Branch Predictor Settings. Predictor RAM depth. Must be 2^n and > 2 |
|
45 |
|
|
| FIFO_DEPTH | 4 | Branch Predictor Settings. Command FIFO depth. Must be 2^n and > 2 |
|
46 |
|
|
| STORE_BUFFER_DEPTH | 16 | Branch Predictor Settings. Depth of the store buffer. Must be 2^n and > 2 |
|
47 |
|
|
| DATA_SECTION_TLB_ENTRIES | 4 | Data Cache/MMU Configuration. Section TLB entries. Must be 2^n (n > 0) |
|
48 |
|
|
| DATA_LPAGE_TLB_ENTRIES | 8 | Data Cache/MMU Configuration. Large page TLB entries. Must be 2^n (n > 0) |
|
49 |
|
|
| DATA_SPAGE_TLB_ENTRIES | 16 | Data Cache/MMU Configuration. Small page TLB entries. Must be 2^n (n > 0) |
|
50 |
|
|
| DATA_CACHE_SIZE | 1024 | Data Cache/MMU Configuration. Cache size in bytes. Must be at least 256B and 2^n |
|
51 |
|
|
| CODE_SECTION_TLB_ENTRIES | 4 | Instruction Cache/MMU Configuration. Section TLB entries. Must be 2^n (n > 0) |
|
52 |
|
|
| CODE_LPAGE_TLB_ENTRIES | 8 | Instruction Cache/MMU Configuration. Large page TLB entries. Must be 2^n (n > 0) |
|
53 |
|
|
| CODE_SPAGE_TLB_ENTRIES | 16 | Instruction Cache/MMU Configuration. Small page TLB entries. Must be 2^n (n > 0) |
|
54 |
|
|
| CODE_CACHE_SIZE | 1024 | Instruction Cache/MMU Configuration. Cache size in bytes. Must be at least 256B and 2^n |
|
55 |
|
|
|
56 |
|
|
#### CPU IO Interface (zap_top.v)
|
57 |
26 |
Revanth |
|
58 |
|
|
Wishbone B3 compatible 32-bit bus.
|
59 |
|
|
|
60 |
43 |
Revanth |
| Dir | Size | Port | Description |
|
61 |
|
|
|---------------|----------|--------------------|----------------------------------|
|
62 |
|
|
| input | | i_clk | Clock |
|
63 |
|
|
| input | | i_reset | Reset |
|
64 |
|
|
| input | | i_irq | Interrupt. Level Sensitive. |
|
65 |
|
|
| input | | i_fiq | Fast Interrupt. Level Sensitive.|
|
66 |
|
|
| output | | o_wb_cyc | Wishbone B3 Signal |
|
67 |
|
|
| output | | o_wb_stb | WIshbone B3 signal |
|
68 |
|
|
| output | [31:0] | o_wb_adr | Wishbone B3 signal. |
|
69 |
|
|
| output | | o_wb_we | Wishbone B3 signal. |
|
70 |
|
|
| output | [31:0] | o_wb_dat | Wishbone B3 signal. |
|
71 |
|
|
| output | [3:0] | o_wb_sel | Wishbone B3 signal. |
|
72 |
|
|
| output | [2:0] | o_wb_cti | Wishbone B3 signal. Cycle Type Indicator (Supported modes: Incrementing Burst, End of Burst)|
|
73 |
|
|
| output | [1:0] | o_wb_bte | Wishbone B3 signal. Burst Type Indicator (Supported modes: Linear) |
|
74 |
|
|
| input | | i_wb_ack | Wishbone B3 signal. |
|
75 |
|
|
| input | [31:0] | i_wb_dat | Wishbone B3 signal. |
|
76 |
|
|
| output | | o_wb_stb_nxt | IGNORE THIS PORT. LEAVE OPEN. |
|
77 |
|
|
| output | | o_wb_cyc_nxt | IGNORE THIS PORT. LEAVE OPEN. |
|
78 |
|
|
| output | [31:0] | o_wb_adr_nxt | IGNORE THIS PORT. LEAVE OPEN. |
|
79 |
26 |
Revanth |
|
80 |
|
|
|
81 |
43 |
Revanth |
### Getting Started
|
82 |
|
|
*Tested on Ubuntu 16.04 LTS/18.04 LTS*
|
83 |
26 |
Revanth |
|
84 |
43 |
Revanth |
#### Run Sample Tests
|
85 |
26 |
Revanth |
|
86 |
43 |
Revanth |
Let the variable $test_name hold the name of the test. See the src/ts directory for some basic tests pre-installed. Available test names are: factorial, arm_test, thumb_test, uart. New tests can be added using these as starting templates. Please note that these will be run on the SOC platform (chip_top) that consist of the ZAP processor, 2 x UARTs, a VIC and a timer.
|
87 |
42 |
Revanth |
|
88 |
43 |
Revanth |
```bash
|
89 |
|
|
sudo apt-get install sudo apt-get install gcc-arm-none-eabi binutils-arm-none-eabi gdb openocd iverilog gtkwave make perl xterm
|
90 |
|
|
cd $PROJ_ROOT/src/ts/$test_name # $PROJ_ROOT is the project directory.
|
91 |
|
|
make # Runs the test using IVerilog.
|
92 |
|
|
cd $PROJ_ROOT/obj/ts/$test_name # Switch to object folder.
|
93 |
|
|
gvim zap.log.gz # View the log file
|
94 |
|
|
gtkwave zap.vcd.gz # Exists if selected by Config.cfg. See PDF document for more information.
|
95 |
|
|
```
|
96 |
44 |
Revanth |
To use this processor in your SOC, instantiate this top level CPU module in your project: /src/rtl/cpu/zap_top.v
|
97 |
42 |
Revanth |
|
98 |
43 |
Revanth |
### Implementation Specific Details
|
99 |
|
|
|
100 |
|
|
#### FPGA Timing Performance (Vivado, Retime Enabled)
|
101 |
|
|
|
102 |
|
|
| FPGA Part | Speed | Critical Path |
|
103 |
|
|
|--------------------|-------|----------------|
|
104 |
|
|
| xc7a35tiftg256-1L | 80MHz | Cache access |
|
105 |
|
|
|
106 |
|
|
#### Coprocessor #15 Control Registers
|
107 |
|
|
|
108 |
|
|
##### Register 0 : ID Register
|
109 |
|
|
|
110 |
|
|
|Bits | Name | Description |
|
111 |
|
|
|-----|---------|------------------------------------------|
|
112 |
|
|
|31:0 | Various | Processor ID info. |
|
113 |
|
|
|
114 |
|
|
##### Register 1 : Control
|
115 |
|
|
|
116 |
|
|
|Bits | Name | Description |
|
117 |
|
|
|-----|-----------|------------------------------------------|
|
118 |
|
|
|0 | M | MMU Enable. Active high |
|
119 |
|
|
|1 | A | Always 0. Alignment check off |
|
120 |
|
|
|2 | D | Data Cache Enable. Active high |
|
121 |
|
|
|3 | W | Always 1. Write Buffer always on. |
|
122 |
|
|
|4 | P | Always 1. RESERVED |
|
123 |
|
|
|5 | D | Always 1. RESERVED |
|
124 |
|
|
|6 | L | Always 1. RESERVED |
|
125 |
|
|
|7 | B | Always 0. Little Endian |
|
126 |
|
|
|8 | S | The S bit |
|
127 |
|
|
|9 | R | The R bit |
|
128 |
|
|
|11 | Z | Always 1. Branch prediction enabled |
|
129 |
|
|
|12 | I | Instruction Cache Enable. Active high |
|
130 |
|
|
|13 | V | Normal Exception Vectors. Always 0 |
|
131 |
|
|
|14 | RR | Always 1. Direct mapped cache. |
|
132 |
|
|
|15 | L4 | Always 0. Normal behavior. |
|
133 |
|
|
|
134 |
|
|
##### Register 2 : Translation Base Address
|
135 |
|
|
|
136 |
|
|
|Bits | Name | Description |
|
137 |
|
|
|-----|-----------|------------------------------------------|
|
138 |
|
|
|13:0 | M | Preserve value. |
|
139 |
|
|
|31:14| TTB | Upper 18-bits of translation address |
|
140 |
|
|
|
141 |
|
|
##### Register 3 : Domain Access Control (X=0 to X=15)
|
142 |
|
|
|
143 |
|
|
|Bits | Name | Description |
|
144 |
|
|
|---------|-----------|------------------------------------------|
|
145 |
|
|
|2X+1:2X | DX | DX access permission. |
|
146 |
|
|
|
147 |
|
|
##### Register 5 : Fault Status Register
|
148 |
|
|
|
149 |
|
|
|Bits | Name | Description |
|
150 |
|
|
|-----|-----------|------------------------------------------|
|
151 |
|
|
|3:0 | Status | Status. |
|
152 |
|
|
|1:0 | Domain | Domain. |
|
153 |
|
|
|11:8 | SBZ | Always 0. RESERVED |
|
154 |
|
|
|
155 |
|
|
##### Register 6 : Fault Address Register
|
156 |
|
|
|
157 |
|
|
|Bits | Name | Description |
|
158 |
|
|
|-----|-----------|------------------------------------------|
|
159 |
|
|
|31:0 | Addr | Fault Address. |
|
160 |
|
|
|
161 |
|
|
##### Register 7 : Cache Functions
|
162 |
|
|
|
163 |
|
|
| Opcode2 | CRm | Description |
|
164 |
|
|
|-------------|-----------------|-------------------------------------|
|
165 |
|
|
| 000 | 0111 | Flush all caches. |
|
166 |
|
|
| 000 | 0101 | Flush I cache. |
|
167 |
|
|
| 000 | 0110 | Flush D cache. |
|
168 |
|
|
| 000 | 1011 | Clean all caches. |
|
169 |
|
|
| 000 | 1010 | Clean D cache. |
|
170 |
|
|
| 000 | 1111 | Clean and flush all caches. |
|
171 |
|
|
| 000 | 1110 | Clean and flush D cache. |
|
172 |
|
|
| Other | Other | Clean and flush ALL caches |
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
##### Register 8 : TLB Functions
|
176 |
|
|
|
177 |
|
|
|Opcode2 | CRm | Description |
|
178 |
|
|
|--------|---------------|-------------------------|
|
179 |
|
|
| 000 | 0111 | Flush all TLBs |
|
180 |
|
|
| 000 | 0101 | Flush I TLB |
|
181 |
|
|
| 000 | 0110 | Flush D TLB |
|
182 |
|
|
| Other| Other | Flush all TLBs |
|
183 |
|
|
|
184 |
|
|
##### Register 13 : FCSE Extentions
|
185 |
|
|
|
186 |
|
|
| Field | Description |
|
187 |
|
|
|-------|-------------|
|
188 |
|
|
| 31:25 | PID |
|
189 |
|
|
|
190 |
|
|
##### Lockdown Support
|
191 |
|
|
* CPU memory system does not support lockdown.
|
192 |
|
|
|
193 |
|
|
##### Tiny Pages
|
194 |
|
|
* No support for tiny pages (1KB).
|