Add Batch 8 with 1 repos
Browse files- MaxXSoft_Fuxi/.github/workflows/test.yml +92 -0
- MaxXSoft_Fuxi/README.md +106 -0
- MaxXSoft_Fuxi/soc/README.md +30 -0
- MaxXSoft_Fuxi/soc/peripherals/clint/AXIBridge.v +137 -0
- MaxXSoft_Fuxi/soc/peripherals/clint/Clint.v +295 -0
- MaxXSoft_Fuxi/soc/peripherals/ddr/ResetSynchronizer.v +42 -0
- MaxXSoft_Fuxi/soc/peripherals/gpio/confreg.v +851 -0
- MaxXSoft_Fuxi/soc/peripherals/lcd/nt35510_controller/src/nt35510_apb_adapter_v1_0.v +117 -0
- MaxXSoft_Fuxi/soc/peripherals/lcd/nt35510_controller/xgui/nt35510_apb_adapter_v1_0_v1_0.tcl +10 -0
- MaxXSoft_Fuxi/soc/peripherals/lcd/nt35510_controller/xgui/nt35510_controller_v1_0.tcl +10 -0
- MaxXSoft_Fuxi/soc/soc.srcs/sim_1/new/SoC_tb.v +101 -0
- MaxXSoft_Fuxi/soc/soc.srcs/sim_1/new/s25fl128s.v +0 -0
- MaxXSoft_Fuxi/soc/soc.srcs/sources_1/bd/mref/Clint/xgui/Clint_v1_0.tcl +10 -0
- MaxXSoft_Fuxi/soc/soc.srcs/sources_1/bd/mref/FuxiWrapper/xgui/FuxiWrapper_v1_0.tcl +10 -0
- MaxXSoft_Fuxi/soc/soc.srcs/sources_1/bd/mref/ResetSynchronizer/xgui/ResetSynchronizer_v1_0.tcl +40 -0
- MaxXSoft_Fuxi/soc/soc.srcs/sources_1/bd/mref/confreg/xgui/confreg_v1_0.tcl +40 -0
- MaxXSoft_Fuxi/soc/soc.srcs/sources_1/new/SoC.v +220 -0
- MaxXSoft_Fuxi/soc/soc.srcs/sources_1/new/iobuf.v +35 -0
- MaxXSoft_Fuxi/src/test/resources/fib.txt +15 -0
- MaxXSoft_Fuxi/src/test/resources/fib_trace.txt +57 -0
- MaxXSoft_Fuxi/src/test/resources/mdu.txt +13 -0
- MaxXSoft_Fuxi/src/test/resources/mdu_trace.txt +11 -0
- MaxXSoft_Fuxi/src/test/resources/mecall.txt +13 -0
- MaxXSoft_Fuxi/src/test/resources/mecall_trace.txt +8 -0
- MaxXSoft_Fuxi/src/test/resources/secall.txt +24 -0
- MaxXSoft_Fuxi/src/test/resources/secall_trace.txt +14 -0
- MaxXSoft_Fuxi/verilog/FuxiWrapper.v +252 -0
MaxXSoft_Fuxi/.github/workflows/test.yml
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Test
|
| 2 |
+
|
| 3 |
+
permissions:
|
| 4 |
+
contents: read
|
| 5 |
+
|
| 6 |
+
on:
|
| 7 |
+
push:
|
| 8 |
+
branches:
|
| 9 |
+
- master
|
| 10 |
+
pull_request:
|
| 11 |
+
branches:
|
| 12 |
+
- master
|
| 13 |
+
|
| 14 |
+
jobs:
|
| 15 |
+
test:
|
| 16 |
+
runs-on: ubuntu-latest
|
| 17 |
+
if: "!contains(github.event.head_commit.message, 'skip-ci')"
|
| 18 |
+
|
| 19 |
+
steps:
|
| 20 |
+
- name: Checkout Fuxi
|
| 21 |
+
uses: actions/checkout@v6
|
| 22 |
+
|
| 23 |
+
- name: Setup JDK
|
| 24 |
+
uses: actions/setup-java@v5
|
| 25 |
+
with:
|
| 26 |
+
distribution: temurin
|
| 27 |
+
java-version: 17
|
| 28 |
+
cache: sbt
|
| 29 |
+
|
| 30 |
+
- name: Setup sbt
|
| 31 |
+
uses: sbt/setup-sbt@v1
|
| 32 |
+
|
| 33 |
+
# Ubuntu 24.04 ships Verilator 5.020, which mis-simulates the Core
|
| 34 |
+
# CSR-write/xRET sequence exercised by the mecall trace.
|
| 35 |
+
- name: Setup Verilator
|
| 36 |
+
uses: veryl-lang/setup-verilator@b155747595eb4b817473a83045ba1da581c4084b
|
| 37 |
+
with:
|
| 38 |
+
version: 5.048
|
| 39 |
+
|
| 40 |
+
- name: Check Verilator version
|
| 41 |
+
run: verilator --version
|
| 42 |
+
|
| 43 |
+
- name: Generate Verilog
|
| 44 |
+
run: make
|
| 45 |
+
|
| 46 |
+
- name: Lint generated Verilog
|
| 47 |
+
run: |
|
| 48 |
+
verilator --lint-only -Wno-fatal --language 1364-2005 \
|
| 49 |
+
--top-module FuxiWrapper \
|
| 50 |
+
verilog/build/Fuxi.v verilog/FuxiWrapper.v
|
| 51 |
+
|
| 52 |
+
- name: Test BPU
|
| 53 |
+
run: sbt "Test / runMain bpu.BranchPredictorTest"
|
| 54 |
+
|
| 55 |
+
- name: Test CSR
|
| 56 |
+
run: sbt "Test / runMain csr.CsrFileTest"
|
| 57 |
+
|
| 58 |
+
- name: Test LSU
|
| 59 |
+
run: |
|
| 60 |
+
sbt "Test / runMain lsu.AmoExecuteTest"
|
| 61 |
+
sbt "Test / runMain lsu.ExclusiveMonitorTest"
|
| 62 |
+
|
| 63 |
+
- name: Test MDU
|
| 64 |
+
run: |
|
| 65 |
+
sbt "Test / runMain mdu.DividerTest"
|
| 66 |
+
sbt "Test / runMain mdu.MultiplierTest"
|
| 67 |
+
sbt "Test / runMain mdu.MduTest"
|
| 68 |
+
|
| 69 |
+
- name: Test Sim
|
| 70 |
+
run: sbt "Test / runMain sim.RamTest"
|
| 71 |
+
|
| 72 |
+
- name: Test Stages
|
| 73 |
+
run: |
|
| 74 |
+
sbt "Test / runMain core.FetchTest"
|
| 75 |
+
sbt "Test / runMain core.DecoderTest"
|
| 76 |
+
sbt "Test / runMain core.AluTest"
|
| 77 |
+
sbt "Test / runMain core.MemTest"
|
| 78 |
+
sbt "Test / runMain core.WriteBackTest"
|
| 79 |
+
|
| 80 |
+
- name: Test Bus
|
| 81 |
+
run: |
|
| 82 |
+
sbt "Test / runMain bus.TlbTest"
|
| 83 |
+
sbt "Test / runMain bus.MmuTest"
|
| 84 |
+
sbt "Test / runMain bus.UncachedTest"
|
| 85 |
+
sbt "Test / runMain bus.CoreBusTest"
|
| 86 |
+
|
| 87 |
+
- name: Test Core
|
| 88 |
+
run: |
|
| 89 |
+
sbt "Test / runMain core.CoreTest -if src/test/resources/fib.txt -tf src/test/resources/fib_trace.txt"
|
| 90 |
+
sbt "Test / runMain core.CoreTest -if src/test/resources/mdu.txt -tf src/test/resources/mdu_trace.txt"
|
| 91 |
+
sbt "Test / runMain core.CoreTest -if src/test/resources/mecall.txt -tf src/test/resources/mecall_trace.txt"
|
| 92 |
+
sbt "Test / runMain core.CoreTest -if src/test/resources/secall.txt -tf src/test/resources/secall_trace.txt"
|
MaxXSoft_Fuxi/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fuxi
|
| 2 |
+
|
| 3 |
+
[](https://github.com/MaxXSoft/Fuxi)
|
| 4 |
+
|
| 5 |
+
Fuxi (伏羲) is a 32-bit pipelined RISC-V processor written in Chisel.
|
| 6 |
+
|
| 7 |
+

|
| 8 |
+
|
| 9 |
+
## Implemented ISAs
|
| 10 |
+
|
| 11 |
+
* RV32I 2.1
|
| 12 |
+
* Zifencei extension 2.0
|
| 13 |
+
* Zicsr extension 2.0
|
| 14 |
+
* M extension 2.0
|
| 15 |
+
* A extension 2.0
|
| 16 |
+
* Machine-level ISA 1.11
|
| 17 |
+
* Supervisor-level ISA 1.11
|
| 18 |
+
|
| 19 |
+
## Unimplemented Details
|
| 20 |
+
|
| 21 |
+
Fuxi processor is designed for running [GeeOS](https://github.com/MaxXSoft/GeeOS), or other simple operating systems or bare-metal software. Considering the complexity, the following functions has not yet been implemented:
|
| 22 |
+
|
| 23 |
+
* Memory privilege in `mstatus` register: `MPRV` bit and `MXR` bit are hardwired to 0.
|
| 24 |
+
* Virtualization support in `mstatus` register: `TVM` bit, `TW` bit and `TSR` bit are hardwired to 0.
|
| 25 |
+
* Physical Memory Protection: all PMP registers are hardwired to 0.
|
| 26 |
+
|
| 27 |
+
## Performance
|
| 28 |
+
|
| 29 |
+
With default configuration:
|
| 30 |
+
|
| 31 |
+
* **Dhrystone 2.1**: 0.60 DMIPS/MHz.
|
| 32 |
+
* **CoreMark**: 2.15 CoreMark/MHz.
|
| 33 |
+
|
| 34 |
+
## Getting Started
|
| 35 |
+
|
| 36 |
+
Fuxi currently targets Chisel 7.13.0 and Scala 2.13.18. JDK 17 and sbt are
|
| 37 |
+
recommended for building it; running the unit tests also requires Verilator.
|
| 38 |
+
|
| 39 |
+
By issuing the following command lines, you can get generated verilog file in directory `verilog/build`:
|
| 40 |
+
|
| 41 |
+
```
|
| 42 |
+
$ git clone https://github.com/MaxXSoft/Fuxi
|
| 43 |
+
$ cd Fuxi
|
| 44 |
+
$ make
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## Running Tests
|
| 48 |
+
|
| 49 |
+
### Running Unit Tests
|
| 50 |
+
|
| 51 |
+
All unit tests are available in directory `src/test/scala`. For example, unit test for decode stage is available in `core/DecoderTest.scala`, you can run this test by executing the following command lines:
|
| 52 |
+
|
| 53 |
+
```
|
| 54 |
+
$ sbt
|
| 55 |
+
> Test / runMain core.DecoderTest
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
### Running `CoreTest`
|
| 59 |
+
|
| 60 |
+
`CoreTest` is a special unit test provided in this repository, it can run simple RISC-V programs using the Fuxi core. We also provided some programs in directory `src/test/resources`. For example, you can run one of it:
|
| 61 |
+
|
| 62 |
+
```
|
| 63 |
+
$ sbt
|
| 64 |
+
> Test / runMain core.CoreTest -if src/test/resources/fib.txt
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
Trace information during running program `fib.txt` will be printed to the console.
|
| 68 |
+
|
| 69 |
+
`CoreTest` supports the following command line arguments:
|
| 70 |
+
|
| 71 |
+
| Option | Abbreviation | Argument | Description
|
| 72 |
+
| - | - | - | -
|
| 73 |
+
| `--init-file` | `-if` | path to program file | Specify the initialization file of ROM.
|
| 74 |
+
| `--trace-file` | `-tf` | path to trace file | Specify the trace file, default to empty.
|
| 75 |
+
| `--gen-trace` | `-gt` | 0 or other values | Set to 0 for trace comparison, otherwise use Fuxi core to generate trace file. Default to 0.
|
| 76 |
+
|
| 77 |
+
So you can test the core using a trace file generated by other processor or emulator:
|
| 78 |
+
|
| 79 |
+
```
|
| 80 |
+
> Test / runMain core.CoreTest -if src/test/resources/fib.txt -tf src/test/resources/fib_trace.txt
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
For other details, please read [the source file](src/test/scala/core/CoreTest.scala) of `CoreTest.scala`.
|
| 84 |
+
|
| 85 |
+
All provided programs:
|
| 86 |
+
|
| 87 |
+
| Name | Description
|
| 88 |
+
| - | -
|
| 89 |
+
| fib.txt | Generate the first 10 terms of the Fibonacci sequence.
|
| 90 |
+
| mdu.txt | Perform some multiplications and divisions.
|
| 91 |
+
| mecall.txt | Test machine mode environment call.
|
| 92 |
+
| secall.txt | Test supervisor mode environment call.
|
| 93 |
+
|
| 94 |
+
### Running Other Test Benches
|
| 95 |
+
|
| 96 |
+
> This part is under construction.
|
| 97 |
+
|
| 98 |
+
As we see in [the top level module](src/main/scala/Fuxi.scala), the complete Fuxi processor consists of `Core` and `CoreBus`, the latter provides MMU, cache system and AXI4 interface for the `Core` part.
|
| 99 |
+
|
| 100 |
+
All of the unit test cases currently contained in this repository can only test modules in the `Core` part, we are still preparing the test bench the entire processor system. For now, you can build a tiny SoC by yourself based on some AXI4 IP cores to run other test benches you want.
|
| 101 |
+
|
| 102 |
+
## Copyright and License
|
| 103 |
+
|
| 104 |
+
Copyright (C) 2010-2020 MaxXing. License GPLv3.
|
| 105 |
+
|
| 106 |
+
Special thanks to [@Yukiteru Lee](https://github.com/wfly1998/).
|
MaxXSoft_Fuxi/soc/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fuxi SoC
|
| 2 |
+
|
| 3 |
+
Fuxi SoC is a simple system-on-chip based on Fuxi processor. This design can be synthesised and implemented on development board with Xilinx 7 Series FPGA.
|
| 4 |
+
|
| 5 |
+
Fuxi SoC has already been tested on Loongson FPGA development board (with Xilinx XC7A200TFBG676-2).
|
| 6 |
+
|
| 7 |
+
## Requirement
|
| 8 |
+
|
| 9 |
+
* Xilinx Vivado 2018.3.
|
| 10 |
+
* Xilinx FPGA.
|
| 11 |
+
|
| 12 |
+
## Address Space Mapping of Peripherals
|
| 13 |
+
|
| 14 |
+
| Peripheral | Start | End | Length | Type |
|
| 15 |
+
| - | - | - | - | - |
|
| 16 |
+
| On-chip ROM | 0x00000000 | 0x0000FFFF | 64KB | Memory |
|
| 17 |
+
| DDR3 Controller | 0x80000000 | 0x87FFFFFF | 128MB | Memory |
|
| 18 |
+
| CFG Flash Controller | 0x10000000 | 0x10FFFFFF | 16MB | Memory |
|
| 19 |
+
| CLINT | 0x11000000 | 0x11000FFF | 4KB | Register |
|
| 20 |
+
| PLIC | 0x11010000 | 0x1101FFFF | 64KB | Register |
|
| 21 |
+
| SPI Flash Controller | 0x11020000 | 0x11020FFF | 4KB | Register |
|
| 22 |
+
| VGA Controller | 0x11030000 | 0x1103FFFF | 64KB | Register |
|
| 23 |
+
| UART Controller | 0x11040000 | 0x11041FFF | 8KB | Register |
|
| 24 |
+
| LCD Controller | 0x11050000 | 0x11050FFF | 4KB | Register |
|
| 25 |
+
| Ethernet Controller | 0x11060000 | 0x1106FFFF | 64KB | Register |
|
| 26 |
+
| GPIO Controller | 0x11070000 | 0x1107FFFF | 64KB | Register |
|
| 27 |
+
|
| 28 |
+
# References
|
| 29 |
+
|
| 30 |
+
Fuxi SoC is heavily influenced by SoC part of [NonTrivialMIPS](https://github.com/trivialmips/nontrivial-mips) project.
|
MaxXSoft_Fuxi/soc/peripherals/clint/AXIBridge.v
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`timescale 1ns / 1ps
|
| 2 |
+
|
| 3 |
+
module AXIBridge(
|
| 4 |
+
input clk,
|
| 5 |
+
input rst_n,
|
| 6 |
+
// AXI slave interface
|
| 7 |
+
input [5:0] axi_arid,
|
| 8 |
+
input [31:0] axi_araddr,
|
| 9 |
+
input [7:0] axi_arlen,
|
| 10 |
+
input [2:0] axi_arsize,
|
| 11 |
+
input [1:0] axi_arburst,
|
| 12 |
+
input [1:0] axi_arlock,
|
| 13 |
+
input [3:0] axi_arcache,
|
| 14 |
+
input [2:0] axi_arprot,
|
| 15 |
+
input axi_arvalid,
|
| 16 |
+
output axi_arready,
|
| 17 |
+
output [5:0] axi_rid,
|
| 18 |
+
output [31:0] axi_rdata,
|
| 19 |
+
output [1:0] axi_rresp,
|
| 20 |
+
output axi_rlast,
|
| 21 |
+
output axi_rvalid,
|
| 22 |
+
input axi_rready,
|
| 23 |
+
input [5:0] axi_awid,
|
| 24 |
+
input [31:0] axi_awaddr,
|
| 25 |
+
input [7:0] axi_awlen,
|
| 26 |
+
input [2:0] axi_awsize,
|
| 27 |
+
input [1:0] axi_awburst,
|
| 28 |
+
input [1:0] axi_awlock,
|
| 29 |
+
input [3:0] axi_awcache,
|
| 30 |
+
input [2:0] axi_awprot,
|
| 31 |
+
input axi_awvalid,
|
| 32 |
+
output axi_awready,
|
| 33 |
+
input [5:0] axi_wid,
|
| 34 |
+
input [31:0] axi_wdata,
|
| 35 |
+
input [3:0] axi_wstrb,
|
| 36 |
+
input axi_wlast,
|
| 37 |
+
input axi_wvalid,
|
| 38 |
+
output axi_wready,
|
| 39 |
+
output [5:0] axi_bid,
|
| 40 |
+
output [1:0] axi_bresp,
|
| 41 |
+
output axi_bvalid,
|
| 42 |
+
input axi_bready,
|
| 43 |
+
// general peripheral interface
|
| 44 |
+
output gpi_read,
|
| 45 |
+
output gpi_write,
|
| 46 |
+
output [31:0] gpi_addr,
|
| 47 |
+
output [31:0] gpi_wdata,
|
| 48 |
+
input [31:0] gpi_rdata
|
| 49 |
+
);
|
| 50 |
+
|
| 51 |
+
reg busy, write, r_or_w;
|
| 52 |
+
|
| 53 |
+
wire ar_enter = axi_arvalid & axi_arready;
|
| 54 |
+
wire r_retire = axi_rvalid & axi_rready & axi_rlast;
|
| 55 |
+
wire r_valid = busy & r_or_w & !r_retire;
|
| 56 |
+
wire aw_enter = axi_awvalid & axi_awready;
|
| 57 |
+
wire w_enter = axi_wvalid & axi_wready & axi_wlast;
|
| 58 |
+
wire b_retire = axi_bvalid & axi_bready;
|
| 59 |
+
|
| 60 |
+
assign axi_arready = ~busy & (!r_or_w | !axi_awvalid);
|
| 61 |
+
assign axi_awready = ~busy & ( r_or_w | !axi_arvalid);
|
| 62 |
+
|
| 63 |
+
reg [5 :0] buf_id;
|
| 64 |
+
reg [31:0] buf_addr;
|
| 65 |
+
reg [7 :0] buf_len;
|
| 66 |
+
reg [2 :0] buf_size;
|
| 67 |
+
|
| 68 |
+
always @(posedge clk) begin
|
| 69 |
+
if (!rst_n ) busy <= 1'b0;
|
| 70 |
+
else if (ar_enter | aw_enter) busy <= 1'b1;
|
| 71 |
+
else if (r_retire | b_retire) busy <= 1'b0;
|
| 72 |
+
end
|
| 73 |
+
|
| 74 |
+
always @(posedge clk) begin
|
| 75 |
+
if (!rst_n) begin
|
| 76 |
+
r_or_w <= 1'b0;
|
| 77 |
+
buf_id <= 6'b0;
|
| 78 |
+
buf_addr <= 32'h0;
|
| 79 |
+
buf_len <= 8'b0;
|
| 80 |
+
buf_size <= 3'b0;
|
| 81 |
+
end
|
| 82 |
+
else if (ar_enter | aw_enter) begin
|
| 83 |
+
r_or_w <= ar_enter;
|
| 84 |
+
buf_id <= ar_enter ? axi_arid : axi_awid ;
|
| 85 |
+
buf_addr <= ar_enter ? axi_araddr : axi_awaddr;
|
| 86 |
+
buf_len <= ar_enter ? axi_arlen : axi_awlen ;
|
| 87 |
+
buf_size <= ar_enter ? axi_arsize : axi_awsize;
|
| 88 |
+
end
|
| 89 |
+
end
|
| 90 |
+
|
| 91 |
+
reg wready_reg;
|
| 92 |
+
assign axi_wready = wready_reg;
|
| 93 |
+
always @(posedge clk) begin
|
| 94 |
+
if (!rst_n ) wready_reg <= 1'b0;
|
| 95 |
+
else if (aw_enter ) wready_reg <= 1'b1;
|
| 96 |
+
else if (w_enter & axi_wlast) wready_reg <= 1'b0;
|
| 97 |
+
end
|
| 98 |
+
|
| 99 |
+
reg rvalid_reg;
|
| 100 |
+
reg rlast_reg;
|
| 101 |
+
assign axi_rdata = gpi_rdata;
|
| 102 |
+
assign axi_rvalid = rvalid_reg;
|
| 103 |
+
assign axi_rlast = rlast_reg;
|
| 104 |
+
always @(posedge clk) begin
|
| 105 |
+
if (!rst_n) begin
|
| 106 |
+
rvalid_reg <= 1'b0;
|
| 107 |
+
rlast_reg <= 1'b0;
|
| 108 |
+
end
|
| 109 |
+
else if (r_valid) begin
|
| 110 |
+
rvalid_reg <= 1'b1;
|
| 111 |
+
rlast_reg <= 1'b1;
|
| 112 |
+
end
|
| 113 |
+
else if (r_retire) begin
|
| 114 |
+
rvalid_reg <= 1'b0;
|
| 115 |
+
end
|
| 116 |
+
end
|
| 117 |
+
|
| 118 |
+
reg bvalid_reg;
|
| 119 |
+
assign axi_bvalid = bvalid_reg;
|
| 120 |
+
always @(posedge clk) begin
|
| 121 |
+
if (!rst_n ) bvalid_reg <= 1'b0;
|
| 122 |
+
else if (w_enter ) bvalid_reg <= 1'b1;
|
| 123 |
+
else if (b_retire ) bvalid_reg <= 1'b0;
|
| 124 |
+
end
|
| 125 |
+
|
| 126 |
+
assign axi_rid = buf_id;
|
| 127 |
+
assign axi_bid = buf_id;
|
| 128 |
+
assign axi_bresp = 2'b0;
|
| 129 |
+
assign axi_rresp = 2'b0;
|
| 130 |
+
|
| 131 |
+
assign gpi_read = r_valid;
|
| 132 |
+
assign gpi_write = w_enter;
|
| 133 |
+
assign gpi_addr = gpi_read ? axi_araddr :
|
| 134 |
+
gpi_write ? axi_awaddr : 32'h0;
|
| 135 |
+
assign gpi_wdata = axi_wdata;
|
| 136 |
+
|
| 137 |
+
endmodule
|
MaxXSoft_Fuxi/soc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Clint(
|
| 14 |
+
input clk,
|
| 15 |
+
input clk_rtc,
|
| 16 |
+
input rst_n,
|
| 17 |
+
// AXI slave interface
|
| 18 |
+
input [5:0] axi_arid,
|
| 19 |
+
input [31:0] axi_araddr,
|
| 20 |
+
input [7:0] axi_arlen,
|
| 21 |
+
input [2:0] axi_arsize,
|
| 22 |
+
input [1:0] axi_arburst,
|
| 23 |
+
input [1:0] axi_arlock,
|
| 24 |
+
input [3:0] axi_arcache,
|
| 25 |
+
input [2:0] axi_arprot,
|
| 26 |
+
input axi_arvalid,
|
| 27 |
+
output axi_arready,
|
| 28 |
+
output [5:0] axi_rid,
|
| 29 |
+
output [31:0] axi_rdata,
|
| 30 |
+
output [1:0] axi_rresp,
|
| 31 |
+
output axi_rlast,
|
| 32 |
+
output axi_rvalid,
|
| 33 |
+
input axi_rready,
|
| 34 |
+
input [5:0] axi_awid,
|
| 35 |
+
input [31:0] axi_awaddr,
|
| 36 |
+
input [7:0] axi_awlen,
|
| 37 |
+
input [2:0] axi_awsize,
|
| 38 |
+
input [1:0] axi_awburst,
|
| 39 |
+
input [1:0] axi_awlock,
|
| 40 |
+
input [3:0] axi_awcache,
|
| 41 |
+
input [2:0] axi_awprot,
|
| 42 |
+
input axi_awvalid,
|
| 43 |
+
output axi_awready,
|
| 44 |
+
input [5:0] axi_wid,
|
| 45 |
+
input [31:0] axi_wdata,
|
| 46 |
+
input [3:0] axi_wstrb,
|
| 47 |
+
input axi_wlast,
|
| 48 |
+
input axi_wvalid,
|
| 49 |
+
output axi_wready,
|
| 50 |
+
output [5:0] axi_bid,
|
| 51 |
+
output [1:0] axi_bresp,
|
| 52 |
+
output axi_bvalid,
|
| 53 |
+
input axi_bready,
|
| 54 |
+
// interrupt signals
|
| 55 |
+
output intr_timer,
|
| 56 |
+
output intr_soft
|
| 57 |
+
);
|
| 58 |
+
|
| 59 |
+
// address
|
| 60 |
+
localparam ADDR_MSIP = 12'h000;
|
| 61 |
+
localparam ADDR_MTIME = 12'h100, ADDR_MTIMEH = 12'h104;
|
| 62 |
+
localparam ADDR_MTIMECMP = 12'h108, ADDR_MTIMECMPH = 12'h10c;
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
// convert AXI to peripheral interface
|
| 66 |
+
wire gpi_read, gpi_write;
|
| 67 |
+
wire [31:0] gpi_addr, gpi_wdata;
|
| 68 |
+
wire [11:0] gpi_peri_addr;
|
| 69 |
+
reg [31:0] gpi_rdata;
|
| 70 |
+
|
| 71 |
+
assign gpi_peri_addr = gpi_addr[11:0];
|
| 72 |
+
|
| 73 |
+
AXIBridge axi_bridge(
|
| 74 |
+
.clk (clk),
|
| 75 |
+
.rst_n (rst_n),
|
| 76 |
+
|
| 77 |
+
.axi_arid (axi_arid),
|
| 78 |
+
.axi_araddr (axi_araddr),
|
| 79 |
+
.axi_arlen (axi_arlen),
|
| 80 |
+
.axi_arsize (axi_arsize),
|
| 81 |
+
.axi_arburst (axi_arburst),
|
| 82 |
+
.axi_arlock (axi_arlock),
|
| 83 |
+
.axi_arcache (axi_arcache),
|
| 84 |
+
.axi_arprot (axi_arprot),
|
| 85 |
+
.axi_arvalid (axi_arvalid),
|
| 86 |
+
.axi_arready (axi_arready),
|
| 87 |
+
.axi_rid (axi_rid),
|
| 88 |
+
.axi_rdata (axi_rdata),
|
| 89 |
+
.axi_rresp (axi_rresp),
|
| 90 |
+
.axi_rlast (axi_rlast),
|
| 91 |
+
.axi_rvalid (axi_rvalid),
|
| 92 |
+
.axi_rready (axi_rready),
|
| 93 |
+
.axi_awid (axi_awid),
|
| 94 |
+
.axi_awaddr (axi_awaddr),
|
| 95 |
+
.axi_awlen (axi_awlen),
|
| 96 |
+
.axi_awsize (axi_awsize),
|
| 97 |
+
.axi_awburst (axi_awburst),
|
| 98 |
+
.axi_awlock (axi_awlock),
|
| 99 |
+
.axi_awcache (axi_awcache),
|
| 100 |
+
.axi_awprot (axi_awprot),
|
| 101 |
+
.axi_awvalid (axi_awvalid),
|
| 102 |
+
.axi_awready (axi_awready),
|
| 103 |
+
.axi_wid (axi_wid),
|
| 104 |
+
.axi_wdata (axi_wdata),
|
| 105 |
+
.axi_wstrb (axi_wstrb),
|
| 106 |
+
.axi_wlast (axi_wlast),
|
| 107 |
+
.axi_wvalid (axi_wvalid),
|
| 108 |
+
.axi_wready (axi_wready),
|
| 109 |
+
.axi_bid (axi_bid),
|
| 110 |
+
.axi_bresp (axi_bresp),
|
| 111 |
+
.axi_bvalid (axi_bvalid),
|
| 112 |
+
.axi_bready (axi_bready),
|
| 113 |
+
|
| 114 |
+
.gpi_read (gpi_read),
|
| 115 |
+
.gpi_write (gpi_write),
|
| 116 |
+
.gpi_addr (gpi_addr),
|
| 117 |
+
.gpi_wdata (gpi_wdata),
|
| 118 |
+
.gpi_rdata (gpi_rdata)
|
| 119 |
+
);
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
// registers
|
| 123 |
+
reg msip;
|
| 124 |
+
reg [31:0] mtime, mtime_r1, mtime_r2;
|
| 125 |
+
reg [31:0] mtimeh, mtimeh_r1, mtimeh_r2;
|
| 126 |
+
reg [31:0] mtimecmp, mtimecmph;
|
| 127 |
+
wire [63:0] mtime_full, next_mtime_full;
|
| 128 |
+
wire [31:0] next_mtime, next_mtimeh;
|
| 129 |
+
|
| 130 |
+
assign mtime_full = {mtimeh, mtime};
|
| 131 |
+
assign next_mtime_full = mtime_full + 64'b1;
|
| 132 |
+
assign next_mtime = next_mtime_full[31:0];
|
| 133 |
+
assign next_mtimeh = next_mtime_full[63:32];
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
// interrupt signal output
|
| 137 |
+
wire [63:0] mtime_r2_full, mtimecmp_full;
|
| 138 |
+
reg timer_intr;
|
| 139 |
+
|
| 140 |
+
assign mtime_r2_full = {mtimeh_r2, mtime_r2};
|
| 141 |
+
assign mtimecmp_full = {mtimecmph, mtimecmp};
|
| 142 |
+
assign intr_soft = msip;
|
| 143 |
+
assign intr_timer = timer_intr;
|
| 144 |
+
|
| 145 |
+
always @(posedge clk) begin
|
| 146 |
+
timer_intr <= mtime_r2_full >= mtimecmp_full;
|
| 147 |
+
end
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
// peripheral read
|
| 151 |
+
always @(posedge clk) begin
|
| 152 |
+
if (!rst_n) begin
|
| 153 |
+
gpi_rdata <= 32'h0;
|
| 154 |
+
end
|
| 155 |
+
else if (gpi_read) begin
|
| 156 |
+
case (gpi_peri_addr)
|
| 157 |
+
ADDR_MSIP: gpi_rdata <= {31'b0, msip};
|
| 158 |
+
ADDR_MTIME: gpi_rdata <= mtime_r2;
|
| 159 |
+
ADDR_MTIMEH: gpi_rdata <= mtimeh_r2;
|
| 160 |
+
ADDR_MTIMECMP: gpi_rdata <= mtimecmp;
|
| 161 |
+
ADDR_MTIMECMPH: gpi_rdata <= mtimecmph;
|
| 162 |
+
default: gpi_rdata <= 32'h0;
|
| 163 |
+
endcase
|
| 164 |
+
end
|
| 165 |
+
end
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
// software interrupt
|
| 169 |
+
always @(posedge clk) begin
|
| 170 |
+
if (!rst_n) begin
|
| 171 |
+
msip <= 1'b0;
|
| 172 |
+
end
|
| 173 |
+
else if (gpi_write && gpi_peri_addr == ADDR_MSIP) begin
|
| 174 |
+
msip <= gpi_wdata[0];
|
| 175 |
+
end
|
| 176 |
+
end
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
// mtime register write/update
|
| 180 |
+
reg write_mtime_begin, write_mtime_begin_r1;
|
| 181 |
+
reg write_mtime_begin_r2, write_mtime_begin_r3;
|
| 182 |
+
reg write_mtime_end_r1, write_mtime_end_r2;
|
| 183 |
+
reg [31:0] mtime_wdata, mtime_wdata_r1, mtime_wdata_r2;
|
| 184 |
+
wire write_mtime = gpi_write && gpi_peri_addr == ADDR_MTIME;
|
| 185 |
+
|
| 186 |
+
always @(posedge clk) begin
|
| 187 |
+
if (!rst_n) begin
|
| 188 |
+
write_mtime_begin <= 1'b0;
|
| 189 |
+
end
|
| 190 |
+
else if (write_mtime) begin
|
| 191 |
+
write_mtime_begin <= 1'b1;
|
| 192 |
+
mtime_wdata <= gpi_wdata;
|
| 193 |
+
end
|
| 194 |
+
else if (write_mtime_end_r2) begin
|
| 195 |
+
write_mtime_begin <= 1'b0;
|
| 196 |
+
end
|
| 197 |
+
end
|
| 198 |
+
|
| 199 |
+
always @(posedge clk) begin
|
| 200 |
+
write_mtime_end_r1 <= write_mtime_begin_r2;
|
| 201 |
+
write_mtime_end_r2 <= write_mtime_end_r1;
|
| 202 |
+
mtime_r1 <= mtime;
|
| 203 |
+
mtime_r2 <= mtime_r1;
|
| 204 |
+
end
|
| 205 |
+
|
| 206 |
+
always @(posedge clk_rtc) begin
|
| 207 |
+
write_mtime_begin_r1 <= write_mtime_begin;
|
| 208 |
+
write_mtime_begin_r2 <= write_mtime_begin_r1;
|
| 209 |
+
write_mtime_begin_r3 <= write_mtime_begin_r2;
|
| 210 |
+
mtime_wdata_r1 <= mtime_wdata;
|
| 211 |
+
mtime_wdata_r2 <= mtime_wdata_r1;
|
| 212 |
+
end
|
| 213 |
+
|
| 214 |
+
always @(posedge clk_rtc) begin
|
| 215 |
+
if (!rst_n) begin
|
| 216 |
+
mtime <= 32'h0;
|
| 217 |
+
end
|
| 218 |
+
else if (write_mtime_begin_r2 && !write_mtime_begin_r3) begin
|
| 219 |
+
mtime <= mtime_wdata_r2;
|
| 220 |
+
end
|
| 221 |
+
else begin
|
| 222 |
+
mtime <= next_mtime;
|
| 223 |
+
end
|
| 224 |
+
end
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
// mtimeh register write/update
|
| 228 |
+
reg write_mtimeh_begin, write_mtimeh_begin_r1;
|
| 229 |
+
reg write_mtimeh_begin_r2, write_mtimeh_begin_r3;
|
| 230 |
+
reg write_mtimeh_end_r1, write_mtimeh_end_r2;
|
| 231 |
+
reg [31:0] mtimeh_wdata, mtimeh_wdata_r1, mtimeh_wdata_r2;
|
| 232 |
+
wire write_mtimeh = gpi_write && gpi_peri_addr == ADDR_MTIMEH;
|
| 233 |
+
|
| 234 |
+
always @(posedge clk) begin
|
| 235 |
+
if (!rst_n) begin
|
| 236 |
+
write_mtimeh_begin <= 1'b0;
|
| 237 |
+
end
|
| 238 |
+
else if (write_mtimeh) begin
|
| 239 |
+
write_mtimeh_begin <= 1'b1;
|
| 240 |
+
mtimeh_wdata <= gpi_wdata;
|
| 241 |
+
end
|
| 242 |
+
else if (write_mtimeh_end_r2) begin
|
| 243 |
+
write_mtimeh_begin <= 1'b0;
|
| 244 |
+
end
|
| 245 |
+
end
|
| 246 |
+
|
| 247 |
+
always @(posedge clk) begin
|
| 248 |
+
write_mtimeh_end_r1 <= write_mtimeh_begin_r2;
|
| 249 |
+
write_mtimeh_end_r2 <= write_mtimeh_end_r1;
|
| 250 |
+
mtimeh_r1 <= mtimeh;
|
| 251 |
+
mtimeh_r2 <= mtimeh_r1;
|
| 252 |
+
end
|
| 253 |
+
|
| 254 |
+
always @(posedge clk_rtc) begin
|
| 255 |
+
write_mtimeh_begin_r1 <= write_mtimeh_begin;
|
| 256 |
+
write_mtimeh_begin_r2 <= write_mtimeh_begin_r1;
|
| 257 |
+
write_mtimeh_begin_r3 <= write_mtimeh_begin_r2;
|
| 258 |
+
mtimeh_wdata_r1 <= mtimeh_wdata;
|
| 259 |
+
mtimeh_wdata_r2 <= mtimeh_wdata_r1;
|
| 260 |
+
end
|
| 261 |
+
|
| 262 |
+
always @(posedge clk_rtc) begin
|
| 263 |
+
if (!rst_n) begin
|
| 264 |
+
mtimeh <= 32'h0;
|
| 265 |
+
end
|
| 266 |
+
else if (write_mtimeh_begin_r2 && !write_mtimeh_begin_r3) begin
|
| 267 |
+
mtimeh <= mtimeh_wdata_r2;
|
| 268 |
+
end
|
| 269 |
+
else begin
|
| 270 |
+
mtimeh <= next_mtimeh;
|
| 271 |
+
end
|
| 272 |
+
end
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
// mtimecmp register write
|
| 276 |
+
always @(posedge clk) begin
|
| 277 |
+
if (!rst_n) begin
|
| 278 |
+
mtimecmp <= 32'h0;
|
| 279 |
+
end
|
| 280 |
+
else if (gpi_write && gpi_peri_addr == ADDR_MTIMECMP) begin
|
| 281 |
+
mtimecmp <= gpi_wdata;
|
| 282 |
+
end
|
| 283 |
+
end
|
| 284 |
+
|
| 285 |
+
// mtimecmph register write
|
| 286 |
+
always @(posedge clk) begin
|
| 287 |
+
if (!rst_n) begin
|
| 288 |
+
mtimecmph <= 32'h0;
|
| 289 |
+
end
|
| 290 |
+
else if (gpi_write && gpi_peri_addr == ADDR_MTIMECMPH) begin
|
| 291 |
+
mtimecmph <= gpi_wdata;
|
| 292 |
+
end
|
| 293 |
+
end
|
| 294 |
+
|
| 295 |
+
endmodule
|
MaxXSoft_Fuxi/soc/peripherals/ddr/ResetSynchronizer.v
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// from https://github.com/trivialmips/nontrivial-mips
|
| 2 |
+
// modified by: MaxXing, 2019-11
|
| 3 |
+
|
| 4 |
+
`timescale 1ns / 1ps
|
| 5 |
+
|
| 6 |
+
module ResetSynchronizer #(
|
| 7 |
+
parameter RESET_STAGE = 3,
|
| 8 |
+
parameter RESET_POSEDGE = 0
|
| 9 |
+
) (
|
| 10 |
+
input clk,
|
| 11 |
+
input rst_i,
|
| 12 |
+
output rst_o
|
| 13 |
+
);
|
| 14 |
+
|
| 15 |
+
reg [RESET_STAGE - 1:0] reset_sync;
|
| 16 |
+
|
| 17 |
+
assign rst_o = reset_sync[RESET_STAGE - 1];
|
| 18 |
+
|
| 19 |
+
generate
|
| 20 |
+
if (RESET_POSEDGE == 0) begin: reset_negedge
|
| 21 |
+
always @(posedge clk, negedge rst_i) begin
|
| 22 |
+
if (!rst_i) begin
|
| 23 |
+
reset_sync <= {RESET_STAGE{1'b0}};
|
| 24 |
+
end
|
| 25 |
+
else begin
|
| 26 |
+
reset_sync <= {reset_sync[RESET_STAGE - 2:0], 1'b1};
|
| 27 |
+
end
|
| 28 |
+
end
|
| 29 |
+
end
|
| 30 |
+
else begin: reset_posedge
|
| 31 |
+
always @(posedge clk, posedge rst_i) begin
|
| 32 |
+
if (rst_i) begin
|
| 33 |
+
reset_sync <= {RESET_STAGE{1'b1}};
|
| 34 |
+
end
|
| 35 |
+
else begin
|
| 36 |
+
reset_sync <= {reset_sync[RESET_STAGE - 2:0], 1'b0};
|
| 37 |
+
end
|
| 38 |
+
end
|
| 39 |
+
end
|
| 40 |
+
endgenerate
|
| 41 |
+
|
| 42 |
+
endmodule // ResetSynchronizer
|
MaxXSoft_Fuxi/soc/peripherals/gpio/confreg.v
ADDED
|
@@ -0,0 +1,851 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*------------------------------------------------------------------------------
|
| 2 |
+
--------------------------------------------------------------------------------
|
| 3 |
+
Copyright (c) 2016, Loongson Technology Corporation Limited.
|
| 4 |
+
|
| 5 |
+
All rights reserved.
|
| 6 |
+
|
| 7 |
+
Redistribution and use in source and binary forms, with or without modification,
|
| 8 |
+
are permitted provided that the following conditions are met:
|
| 9 |
+
|
| 10 |
+
1. Redistributions of source code must retain the above copyright notice, this
|
| 11 |
+
list of conditions and the following disclaimer.
|
| 12 |
+
|
| 13 |
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
| 14 |
+
this list of conditions and the following disclaimer in the documentation and/or
|
| 15 |
+
other materials provided with the distribution.
|
| 16 |
+
|
| 17 |
+
3. Neither the name of Loongson Technology Corporation Limited nor the names of
|
| 18 |
+
its contributors may be used to endorse or promote products derived from this
|
| 19 |
+
software without specific prior written permission.
|
| 20 |
+
|
| 21 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
| 22 |
+
ANY 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 LOONGSON TECHNOLOGY CORPORATION LIMITED BE LIABLE
|
| 25 |
+
TO ANY PARTY FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
| 26 |
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
| 27 |
+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
| 28 |
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| 29 |
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
| 30 |
+
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 31 |
+
--------------------------------------------------------------------------------
|
| 32 |
+
------------------------------------------------------------------------------*/
|
| 33 |
+
|
| 34 |
+
//*************************************************************************
|
| 35 |
+
// > File Name : confreg.v
|
| 36 |
+
// > Description : Control module of
|
| 37 |
+
// 16 red leds, 2 green/red leds,
|
| 38 |
+
// 7-segment display,
|
| 39 |
+
// switchs,
|
| 40 |
+
// key board,
|
| 41 |
+
// bottom STEP,
|
| 42 |
+
// timer.
|
| 43 |
+
//
|
| 44 |
+
// > Author : LOONGSON
|
| 45 |
+
// > Date : 2017-08-04
|
| 46 |
+
// > Author : Harry Chen
|
| 47 |
+
// > Date : 2019-08
|
| 48 |
+
// > Author : MaxXing
|
| 49 |
+
// > Date : 2019-11
|
| 50 |
+
//*************************************************************************
|
| 51 |
+
`define RANDOM_SEED {7'b1010101,16'h00FF}
|
| 52 |
+
|
| 53 |
+
`define CR0_ADDR 16'h8000 //32'hbfaf_8000
|
| 54 |
+
`define CR1_ADDR 16'h8004 //32'hbfaf_8004
|
| 55 |
+
`define CR2_ADDR 16'h8008 //32'hbfaf_8008
|
| 56 |
+
`define CR3_ADDR 16'h800c //32'hbfaf_800c
|
| 57 |
+
`define CR4_ADDR 16'h8010 //32'hbfaf_8010
|
| 58 |
+
`define CR5_ADDR 16'h8014 //32'hbfaf_8014
|
| 59 |
+
`define CR6_ADDR 16'h8018 //32'hbfaf_8018
|
| 60 |
+
`define CR7_ADDR 16'h801c //32'hbfaf_801c
|
| 61 |
+
|
| 62 |
+
`define LED_ADDR 16'hf000 //32'hbfaf_f000
|
| 63 |
+
`define LED_RG0_ADDR 16'hf004 //32'hbfaf_f004
|
| 64 |
+
`define LED_RG1_ADDR 16'hf008 //32'hbfaf_f008
|
| 65 |
+
`define NUM_ADDR 16'hf010 //32'hbfaf_f010
|
| 66 |
+
`define SWITCH_ADDR 16'hf020 //32'hbfaf_f020
|
| 67 |
+
`define BTN_KEY_ADDR 16'hf024 //32'hbfaf_f024
|
| 68 |
+
`define BTN_STEP_ADDR 16'hf028 //32'hbfaf_f028
|
| 69 |
+
`define SW_INTER_ADDR 16'hf02c //32'hbfaf_f02c
|
| 70 |
+
`define TIMER_ADDR 16'he000 //32'hbfaf_e000
|
| 71 |
+
|
| 72 |
+
`define IO_SIMU_ADDR 16'hffec //32'hbfaf_ffec
|
| 73 |
+
`define VIRTUAL_UART_ADDR 16'hfff0 //32'hbfaf_fff0
|
| 74 |
+
`define SIMU_FLAG_ADDR 16'hfff4 //32'hbfaf_fff4
|
| 75 |
+
`define OPEN_TRACE_ADDR 16'hfff8 //32'hbfaf_fff8
|
| 76 |
+
`define NUM_MONITOR_ADDR 16'hfffc //32'hbfaf_fffc
|
| 77 |
+
module confreg #(
|
| 78 |
+
parameter SIMULATION=1'b0,
|
| 79 |
+
parameter BUS_WIDTH=6
|
| 80 |
+
)
|
| 81 |
+
(
|
| 82 |
+
input aclk,
|
| 83 |
+
input timer_clk,
|
| 84 |
+
input aresetn,
|
| 85 |
+
// read and write from cpu
|
| 86 |
+
//ar
|
| 87 |
+
input [BUS_WIDTH - 1 :0] arid ,
|
| 88 |
+
input [31:0] araddr ,
|
| 89 |
+
input [7 :0] arlen ,
|
| 90 |
+
input [2 :0] arsize ,
|
| 91 |
+
input [1 :0] arburst,
|
| 92 |
+
input [1 :0] arlock ,
|
| 93 |
+
input [3 :0] arcache,
|
| 94 |
+
input [2 :0] arprot ,
|
| 95 |
+
input arvalid,
|
| 96 |
+
output arready,
|
| 97 |
+
//r
|
| 98 |
+
output [BUS_WIDTH - 1 :0] rid ,
|
| 99 |
+
output [31:0] rdata ,
|
| 100 |
+
output [1 :0] rresp ,
|
| 101 |
+
output rlast ,
|
| 102 |
+
output rvalid ,
|
| 103 |
+
input rready ,
|
| 104 |
+
//aw
|
| 105 |
+
input [BUS_WIDTH - 1 :0] awid ,
|
| 106 |
+
input [31:0] awaddr ,
|
| 107 |
+
input [7 :0] awlen ,
|
| 108 |
+
input [2 :0] awsize ,
|
| 109 |
+
input [1 :0] awburst,
|
| 110 |
+
input [1 :0] awlock ,
|
| 111 |
+
input [3 :0] awcache,
|
| 112 |
+
input [2 :0] awprot ,
|
| 113 |
+
input awvalid,
|
| 114 |
+
output awready,
|
| 115 |
+
//w
|
| 116 |
+
input [BUS_WIDTH - 1 :0] wid ,
|
| 117 |
+
input [31:0] wdata ,
|
| 118 |
+
input [3 :0] wstrb ,
|
| 119 |
+
input wlast ,
|
| 120 |
+
input wvalid ,
|
| 121 |
+
output wready ,
|
| 122 |
+
//b
|
| 123 |
+
output [BUS_WIDTH - 1 :0] bid ,
|
| 124 |
+
output [1 :0] bresp ,
|
| 125 |
+
output bvalid ,
|
| 126 |
+
input bready ,
|
| 127 |
+
|
| 128 |
+
//for lab6
|
| 129 |
+
output [4 :0] ram_random_mask ,
|
| 130 |
+
|
| 131 |
+
// read and write to device on board
|
| 132 |
+
output [15:0] led,
|
| 133 |
+
output [1 :0] led_rg0,
|
| 134 |
+
output [1 :0] led_rg1,
|
| 135 |
+
output reg [7 :0] num_csn,
|
| 136 |
+
output reg [6 :0] num_a_g,
|
| 137 |
+
input [7 :0] switch,
|
| 138 |
+
output [3 :0] btn_key_col,
|
| 139 |
+
input [3 :0] btn_key_row,
|
| 140 |
+
input [1 :0] btn_step,
|
| 141 |
+
|
| 142 |
+
// user-defined contents
|
| 143 |
+
output [31:0] user_cr0,
|
| 144 |
+
output [31:0] user_cr1
|
| 145 |
+
);
|
| 146 |
+
reg [31:0] cr0;
|
| 147 |
+
reg [31:0] cr1;
|
| 148 |
+
reg [31:0] cr2;
|
| 149 |
+
reg [31:0] cr3;
|
| 150 |
+
reg [31:0] cr4;
|
| 151 |
+
reg [31:0] cr5;
|
| 152 |
+
reg [31:0] cr6;
|
| 153 |
+
reg [31:0] cr7;
|
| 154 |
+
|
| 155 |
+
reg [31:0] led_data;
|
| 156 |
+
reg [31:0] led_rg0_data;
|
| 157 |
+
reg [31:0] led_rg1_data;
|
| 158 |
+
reg [31:0] num_data;
|
| 159 |
+
wire [31:0] switch_data;
|
| 160 |
+
wire [31:0] sw_inter_data; //switch interleave
|
| 161 |
+
wire [31:0] btn_key_data;
|
| 162 |
+
wire [31:0] btn_step_data;
|
| 163 |
+
reg [31:0] timer_r2;
|
| 164 |
+
reg [31:0] simu_flag;
|
| 165 |
+
reg [31:0] io_simu;
|
| 166 |
+
reg [7 :0] virtual_uart_data;
|
| 167 |
+
reg open_trace;
|
| 168 |
+
reg num_monitor;
|
| 169 |
+
|
| 170 |
+
// user-defined contents
|
| 171 |
+
assign user_cr0 = cr0;
|
| 172 |
+
assign user_cr1 = cr1;
|
| 173 |
+
|
| 174 |
+
//--------------------------{axi interface}begin-------------------------//
|
| 175 |
+
reg busy,write,R_or_W;
|
| 176 |
+
reg s_wready;
|
| 177 |
+
|
| 178 |
+
wire ar_enter = arvalid & arready;
|
| 179 |
+
wire r_retire = rvalid & rready & rlast;
|
| 180 |
+
wire aw_enter = awvalid & awready;
|
| 181 |
+
wire w_enter = wvalid & wready & wlast;
|
| 182 |
+
wire b_retire = bvalid & bready;
|
| 183 |
+
|
| 184 |
+
assign arready = ~busy & (!R_or_W| !awvalid);
|
| 185 |
+
assign awready = ~busy & ( R_or_W| !arvalid);
|
| 186 |
+
|
| 187 |
+
reg [BUS_WIDTH - 1 :0] buf_id;
|
| 188 |
+
reg [31:0] buf_addr;
|
| 189 |
+
reg [7 :0] buf_len;
|
| 190 |
+
reg [2 :0] buf_size;
|
| 191 |
+
|
| 192 |
+
always @(posedge aclk)
|
| 193 |
+
begin
|
| 194 |
+
if(~aresetn) busy <= 1'b0;
|
| 195 |
+
else if(ar_enter|aw_enter) busy <= 1'b1;
|
| 196 |
+
else if(r_retire|b_retire) busy <= 1'b0;
|
| 197 |
+
end
|
| 198 |
+
|
| 199 |
+
always @(posedge aclk)
|
| 200 |
+
begin
|
| 201 |
+
if(~aresetn)
|
| 202 |
+
begin
|
| 203 |
+
R_or_W <= 1'b0;
|
| 204 |
+
buf_id <= 6'b0;
|
| 205 |
+
buf_addr <= 32'b0;
|
| 206 |
+
buf_len <= 8'b0;
|
| 207 |
+
buf_size <= 3'b0;
|
| 208 |
+
end
|
| 209 |
+
else
|
| 210 |
+
if(ar_enter | aw_enter)
|
| 211 |
+
begin
|
| 212 |
+
R_or_W <= ar_enter;
|
| 213 |
+
buf_id <= ar_enter ? arid : awid ;
|
| 214 |
+
buf_addr <= ar_enter ? araddr : awaddr ;
|
| 215 |
+
buf_len <= ar_enter ? arlen : awlen ;
|
| 216 |
+
buf_size <= ar_enter ? arsize : awsize ;
|
| 217 |
+
end
|
| 218 |
+
end
|
| 219 |
+
|
| 220 |
+
reg conf_wready_reg;
|
| 221 |
+
assign wready = conf_wready_reg;
|
| 222 |
+
always@(posedge aclk)
|
| 223 |
+
begin
|
| 224 |
+
if (~aresetn ) conf_wready_reg <= 1'b0;
|
| 225 |
+
else if(aw_enter ) conf_wready_reg <= 1'b1;
|
| 226 |
+
else if(w_enter & wlast) conf_wready_reg <= 1'b0;
|
| 227 |
+
end
|
| 228 |
+
|
| 229 |
+
// read data has one cycle delay
|
| 230 |
+
reg [31:0] conf_rdata_reg;
|
| 231 |
+
reg conf_rvalid_reg;
|
| 232 |
+
reg conf_rlast_reg;
|
| 233 |
+
assign rdata = conf_rdata_reg;
|
| 234 |
+
assign rvalid = conf_rvalid_reg;
|
| 235 |
+
assign rlast = conf_rlast_reg;
|
| 236 |
+
always @(posedge aclk)
|
| 237 |
+
begin
|
| 238 |
+
if(~aresetn)
|
| 239 |
+
begin
|
| 240 |
+
conf_rdata_reg <= 32'd0;
|
| 241 |
+
conf_rvalid_reg <= 1'd0;
|
| 242 |
+
conf_rlast_reg <= 1'd0;
|
| 243 |
+
end
|
| 244 |
+
else if(busy & R_or_W & !r_retire)
|
| 245 |
+
begin
|
| 246 |
+
conf_rvalid_reg <= 1'd1;
|
| 247 |
+
conf_rlast_reg <= 1'd1;
|
| 248 |
+
case (buf_addr[15:0])
|
| 249 |
+
`CR0_ADDR : conf_rdata_reg <= cr0 ;
|
| 250 |
+
`CR1_ADDR : conf_rdata_reg <= cr1 ;
|
| 251 |
+
`CR2_ADDR : conf_rdata_reg <= cr2 ;
|
| 252 |
+
`CR3_ADDR : conf_rdata_reg <= cr3 ;
|
| 253 |
+
`CR4_ADDR : conf_rdata_reg <= cr4 ;
|
| 254 |
+
`CR5_ADDR : conf_rdata_reg <= cr5 ;
|
| 255 |
+
`CR6_ADDR : conf_rdata_reg <= cr6 ;
|
| 256 |
+
`CR7_ADDR : conf_rdata_reg <= cr7 ;
|
| 257 |
+
`LED_ADDR : conf_rdata_reg <= led_data ;
|
| 258 |
+
`LED_RG0_ADDR : conf_rdata_reg <= led_rg0_data ;
|
| 259 |
+
`LED_RG1_ADDR : conf_rdata_reg <= led_rg1_data ;
|
| 260 |
+
`NUM_ADDR : conf_rdata_reg <= num_data ;
|
| 261 |
+
`SWITCH_ADDR : conf_rdata_reg <= switch_data ;
|
| 262 |
+
`BTN_KEY_ADDR : conf_rdata_reg <= btn_key_data ;
|
| 263 |
+
`BTN_STEP_ADDR : conf_rdata_reg <= btn_step_data;
|
| 264 |
+
`SW_INTER_ADDR : conf_rdata_reg <= sw_inter_data;
|
| 265 |
+
`TIMER_ADDR : conf_rdata_reg <= timer_r2 ;
|
| 266 |
+
`SIMU_FLAG_ADDR: conf_rdata_reg <= simu_flag ;
|
| 267 |
+
`IO_SIMU_ADDR : conf_rdata_reg <= io_simu ;
|
| 268 |
+
`VIRTUAL_UART_ADDR : conf_rdata_reg <= {24'd0,virtual_uart_data} ;
|
| 269 |
+
`OPEN_TRACE_ADDR : conf_rdata_reg <= {31'd0,open_trace} ;
|
| 270 |
+
`NUM_MONITOR_ADDR: conf_rdata_reg <= {31'd0,num_monitor} ;
|
| 271 |
+
default : conf_rdata_reg <= 32'd0;
|
| 272 |
+
endcase
|
| 273 |
+
end
|
| 274 |
+
else if(r_retire)
|
| 275 |
+
begin
|
| 276 |
+
conf_rvalid_reg <= 1'b0;
|
| 277 |
+
end
|
| 278 |
+
end
|
| 279 |
+
|
| 280 |
+
//conf write, only support a word write
|
| 281 |
+
wire conf_we;
|
| 282 |
+
wire [31:0] conf_addr;
|
| 283 |
+
wire [31:0] conf_wdata;
|
| 284 |
+
assign conf_we = w_enter;
|
| 285 |
+
assign conf_addr = buf_addr;
|
| 286 |
+
assign conf_wdata= wdata;
|
| 287 |
+
|
| 288 |
+
reg conf_bvalid_reg;
|
| 289 |
+
assign bvalid = conf_bvalid_reg;
|
| 290 |
+
always @(posedge aclk)
|
| 291 |
+
begin
|
| 292 |
+
if (~aresetn) conf_bvalid_reg <= 1'b0;
|
| 293 |
+
else if(w_enter ) conf_bvalid_reg <= 1'b1;
|
| 294 |
+
else if(b_retire) conf_bvalid_reg <= 1'b0;
|
| 295 |
+
end
|
| 296 |
+
|
| 297 |
+
assign rid = buf_id;
|
| 298 |
+
assign bid = buf_id;
|
| 299 |
+
assign bresp = 2'b0;
|
| 300 |
+
assign rresp = 2'b0;
|
| 301 |
+
//---------------------------{axi interface}end--------------------------//
|
| 302 |
+
|
| 303 |
+
//-------------------------{confreg register}begin-----------------------//
|
| 304 |
+
wire write_cr0 = conf_we & (conf_addr[15:0]==`CR0_ADDR);
|
| 305 |
+
wire write_cr1 = conf_we & (conf_addr[15:0]==`CR1_ADDR);
|
| 306 |
+
wire write_cr2 = conf_we & (conf_addr[15:0]==`CR2_ADDR);
|
| 307 |
+
wire write_cr3 = conf_we & (conf_addr[15:0]==`CR3_ADDR);
|
| 308 |
+
wire write_cr4 = conf_we & (conf_addr[15:0]==`CR4_ADDR);
|
| 309 |
+
wire write_cr5 = conf_we & (conf_addr[15:0]==`CR5_ADDR);
|
| 310 |
+
wire write_cr6 = conf_we & (conf_addr[15:0]==`CR6_ADDR);
|
| 311 |
+
wire write_cr7 = conf_we & (conf_addr[15:0]==`CR7_ADDR);
|
| 312 |
+
always @(posedge aclk)
|
| 313 |
+
begin
|
| 314 |
+
cr0 <= !aresetn ? 32'd0 :
|
| 315 |
+
write_cr0 ? conf_wdata : cr0;
|
| 316 |
+
cr1 <= !aresetn ? 32'd0 :
|
| 317 |
+
write_cr1 ? conf_wdata : cr1;
|
| 318 |
+
cr2 <= !aresetn ? 32'd0 :
|
| 319 |
+
write_cr2 ? conf_wdata : cr2;
|
| 320 |
+
cr3 <= !aresetn ? 32'd0 :
|
| 321 |
+
write_cr3 ? conf_wdata : cr3;
|
| 322 |
+
cr4 <= !aresetn ? 32'd0 :
|
| 323 |
+
write_cr4 ? conf_wdata : cr4;
|
| 324 |
+
cr5 <= !aresetn ? 32'd0 :
|
| 325 |
+
write_cr5 ? conf_wdata : cr5;
|
| 326 |
+
cr6 <= !aresetn ? 32'd0 :
|
| 327 |
+
write_cr6 ? conf_wdata : cr6;
|
| 328 |
+
cr7 <= !aresetn ? 32'd0 :
|
| 329 |
+
write_cr7 ? conf_wdata : cr7;
|
| 330 |
+
end
|
| 331 |
+
//--------------------------{confreg register}end------------------------//
|
| 332 |
+
|
| 333 |
+
//-------------------------------{timer}begin----------------------------//
|
| 334 |
+
reg write_timer_begin,write_timer_begin_r1, write_timer_begin_r2,write_timer_begin_r3;
|
| 335 |
+
reg write_timer_end_r1, write_timer_end_r2;
|
| 336 |
+
reg [31:0] conf_wdata_r, conf_wdata_r1,conf_wdata_r2;
|
| 337 |
+
|
| 338 |
+
reg [31:0] timer_r1;
|
| 339 |
+
reg [31:0] timer;
|
| 340 |
+
|
| 341 |
+
wire write_timer = conf_we & (conf_addr[15:0]==`TIMER_ADDR);
|
| 342 |
+
always @(posedge aclk)
|
| 343 |
+
begin
|
| 344 |
+
if (!aresetn)
|
| 345 |
+
begin
|
| 346 |
+
write_timer_begin <= 1'b0;
|
| 347 |
+
end
|
| 348 |
+
else if (write_timer)
|
| 349 |
+
begin
|
| 350 |
+
write_timer_begin <= 1'b1;
|
| 351 |
+
conf_wdata_r <= conf_wdata;
|
| 352 |
+
end
|
| 353 |
+
else if (write_timer_end_r2)
|
| 354 |
+
begin
|
| 355 |
+
write_timer_begin <= 1'b0;
|
| 356 |
+
end
|
| 357 |
+
|
| 358 |
+
write_timer_end_r1 <= write_timer_begin_r2;
|
| 359 |
+
write_timer_end_r2 <= write_timer_end_r1;
|
| 360 |
+
end
|
| 361 |
+
|
| 362 |
+
always @(posedge timer_clk)
|
| 363 |
+
begin
|
| 364 |
+
write_timer_begin_r1 <= write_timer_begin;
|
| 365 |
+
write_timer_begin_r2 <= write_timer_begin_r1;
|
| 366 |
+
write_timer_begin_r3 <= write_timer_begin_r2;
|
| 367 |
+
conf_wdata_r1 <= conf_wdata_r;
|
| 368 |
+
conf_wdata_r2 <= conf_wdata_r1;
|
| 369 |
+
|
| 370 |
+
if(!aresetn)
|
| 371 |
+
begin
|
| 372 |
+
timer <= 32'd0;
|
| 373 |
+
end
|
| 374 |
+
else if (write_timer_begin_r2 && !write_timer_begin_r3)
|
| 375 |
+
begin
|
| 376 |
+
timer <= conf_wdata_r2[31:0];
|
| 377 |
+
end
|
| 378 |
+
else
|
| 379 |
+
begin
|
| 380 |
+
timer <= timer + 1'b1;
|
| 381 |
+
end
|
| 382 |
+
end
|
| 383 |
+
|
| 384 |
+
always @(posedge aclk)
|
| 385 |
+
begin
|
| 386 |
+
timer_r1 <= timer;
|
| 387 |
+
timer_r2 <= timer_r1;
|
| 388 |
+
end
|
| 389 |
+
//--------------------------------{timer}end-----------------------------//
|
| 390 |
+
|
| 391 |
+
//--------------------------{simulation flag}begin-----------------------//
|
| 392 |
+
always @(posedge aclk)
|
| 393 |
+
begin
|
| 394 |
+
if(!aresetn)
|
| 395 |
+
begin
|
| 396 |
+
simu_flag <= {32{SIMULATION}};
|
| 397 |
+
end
|
| 398 |
+
end
|
| 399 |
+
//---------------------------{simulation flag}end------------------------//
|
| 400 |
+
|
| 401 |
+
//---------------------------{io simulation}begin------------------------//
|
| 402 |
+
wire write_io_simu = conf_we & (conf_addr[15:0]==`IO_SIMU_ADDR);
|
| 403 |
+
always @(posedge aclk)
|
| 404 |
+
begin
|
| 405 |
+
if(!aresetn)
|
| 406 |
+
begin
|
| 407 |
+
io_simu <= 32'd0;
|
| 408 |
+
end
|
| 409 |
+
else if(write_io_simu)
|
| 410 |
+
begin
|
| 411 |
+
io_simu <= {conf_wdata[15:0],conf_wdata[31:16]};
|
| 412 |
+
end
|
| 413 |
+
end
|
| 414 |
+
//----------------------------{io simulation}end-------------------------//
|
| 415 |
+
|
| 416 |
+
//-----------------------------{open trace}begin-------------------------//
|
| 417 |
+
wire write_open_trace = conf_we & (conf_addr[15:0]==`OPEN_TRACE_ADDR);
|
| 418 |
+
always @(posedge aclk)
|
| 419 |
+
begin
|
| 420 |
+
if(!aresetn)
|
| 421 |
+
begin
|
| 422 |
+
open_trace <= 1'b1;
|
| 423 |
+
end
|
| 424 |
+
else if(write_open_trace)
|
| 425 |
+
begin
|
| 426 |
+
open_trace <= |conf_wdata;
|
| 427 |
+
end
|
| 428 |
+
end
|
| 429 |
+
//-----------------------------{open trace}end---------------------------//
|
| 430 |
+
|
| 431 |
+
//----------------------------{num monitor}begin-------------------------//
|
| 432 |
+
wire write_num_monitor = conf_we & (conf_addr[15:0]==`NUM_MONITOR_ADDR);
|
| 433 |
+
always @(posedge aclk)
|
| 434 |
+
begin
|
| 435 |
+
if(!aresetn)
|
| 436 |
+
begin
|
| 437 |
+
num_monitor <= 1'b1;
|
| 438 |
+
end
|
| 439 |
+
else if(write_num_monitor)
|
| 440 |
+
begin
|
| 441 |
+
num_monitor <= conf_wdata[0];
|
| 442 |
+
end
|
| 443 |
+
end
|
| 444 |
+
//----------------------------{num monitor}end---------------------------//
|
| 445 |
+
|
| 446 |
+
//---------------------------{virtual uart}begin-------------------------//
|
| 447 |
+
wire [7:0] write_uart_data;
|
| 448 |
+
wire write_uart_valid = conf_we & (conf_addr[15:0]==`VIRTUAL_UART_ADDR);
|
| 449 |
+
assign write_uart_data = conf_wdata[7:0];
|
| 450 |
+
always @(posedge aclk)
|
| 451 |
+
begin
|
| 452 |
+
if(!aresetn)
|
| 453 |
+
begin
|
| 454 |
+
virtual_uart_data <= 8'd0;
|
| 455 |
+
end
|
| 456 |
+
else if(write_uart_valid)
|
| 457 |
+
begin
|
| 458 |
+
virtual_uart_data <= write_uart_data;
|
| 459 |
+
end
|
| 460 |
+
end
|
| 461 |
+
//----------------------------{virtual uart}end--------------------------//
|
| 462 |
+
|
| 463 |
+
//--------------------------{axirandom mask}begin------------------------//
|
| 464 |
+
wire [15:0] switch_led;
|
| 465 |
+
wire [15:0] led_r_n;
|
| 466 |
+
assign led_r_n = ~switch_led;
|
| 467 |
+
|
| 468 |
+
reg [22:0] pseudo_random_23;
|
| 469 |
+
reg no_mask; //if led_r_n is all 1, no mask
|
| 470 |
+
reg short_delay; //memory long delay
|
| 471 |
+
always @ (posedge aclk)
|
| 472 |
+
begin
|
| 473 |
+
if (!aresetn)
|
| 474 |
+
pseudo_random_23 <= simu_flag[0] ? `RANDOM_SEED : {7'b1010101,led_r_n};
|
| 475 |
+
else
|
| 476 |
+
pseudo_random_23 <= {pseudo_random_23[21:0],pseudo_random_23[22] ^ pseudo_random_23[17]};
|
| 477 |
+
|
| 478 |
+
if(!aresetn)
|
| 479 |
+
no_mask <= pseudo_random_23[15:0]==16'h00FF;
|
| 480 |
+
|
| 481 |
+
if(!aresetn)
|
| 482 |
+
short_delay <= pseudo_random_23[7:0]==8'hFF;
|
| 483 |
+
end
|
| 484 |
+
assign ram_random_mask[0] = (pseudo_random_23[10]&pseudo_random_23[20]) & (short_delay|(pseudo_random_23[11]^pseudo_random_23[5]))
|
| 485 |
+
| no_mask;
|
| 486 |
+
assign ram_random_mask[1] = (pseudo_random_23[ 9]&pseudo_random_23[17]) & (short_delay|(pseudo_random_23[12]^pseudo_random_23[4]))
|
| 487 |
+
| no_mask;
|
| 488 |
+
assign ram_random_mask[2] = (pseudo_random_23[ 8]^pseudo_random_23[22]) & (short_delay|(pseudo_random_23[13]^pseudo_random_23[3]))
|
| 489 |
+
| no_mask;
|
| 490 |
+
assign ram_random_mask[3] = (pseudo_random_23[ 7]&pseudo_random_23[19]) & (short_delay|(pseudo_random_23[14]^pseudo_random_23[2]))
|
| 491 |
+
| no_mask;
|
| 492 |
+
assign ram_random_mask[4] = (pseudo_random_23[ 6]^pseudo_random_23[16]) & (short_delay|(pseudo_random_23[15]^pseudo_random_23[1]))
|
| 493 |
+
| no_mask;
|
| 494 |
+
|
| 495 |
+
//---------------------------{axirandom mask}end-------------------------//
|
| 496 |
+
|
| 497 |
+
//--------------------------------{led}begin-----------------------------//
|
| 498 |
+
//led display
|
| 499 |
+
//led_data[31:0]
|
| 500 |
+
wire write_led = conf_we & (conf_addr[15:0]==`LED_ADDR);
|
| 501 |
+
|
| 502 |
+
assign led = led_data[15:0];
|
| 503 |
+
|
| 504 |
+
assign switch_led = {{2{switch[7]}},{2{switch[6]}},{2{switch[5]}},{2{switch[4]}},
|
| 505 |
+
{2{switch[3]}},{2{switch[2]}},{2{switch[1]}},{2{switch[0]}}};
|
| 506 |
+
always @(posedge aclk)
|
| 507 |
+
begin
|
| 508 |
+
if(!aresetn)
|
| 509 |
+
begin
|
| 510 |
+
led_data <= {16'h0,switch_led};
|
| 511 |
+
end
|
| 512 |
+
else if(write_led)
|
| 513 |
+
begin
|
| 514 |
+
led_data <= conf_wdata[31:0];
|
| 515 |
+
end
|
| 516 |
+
end
|
| 517 |
+
//---------------------------------{led}end------------------------------//
|
| 518 |
+
|
| 519 |
+
//-------------------------------{switch}begin---------------------------//
|
| 520 |
+
//switch data
|
| 521 |
+
//switch_data[7:0]
|
| 522 |
+
assign switch_data = {24'd0,switch};
|
| 523 |
+
assign sw_inter_data = {16'd0,
|
| 524 |
+
switch[7],1'b0,switch[6],1'b0,
|
| 525 |
+
switch[5],1'b0,switch[4],1'b0,
|
| 526 |
+
switch[3],1'b0,switch[2],1'b0,
|
| 527 |
+
switch[1],1'b0,switch[0],1'b0};
|
| 528 |
+
//--------------------------------{switch}end----------------------------//
|
| 529 |
+
|
| 530 |
+
//------------------------------{btn key}begin---------------------------//
|
| 531 |
+
//btn key data
|
| 532 |
+
reg [15:0] btn_key_r;
|
| 533 |
+
assign btn_key_data = {16'd0,btn_key_r};
|
| 534 |
+
|
| 535 |
+
//state machine
|
| 536 |
+
reg [2:0] state;
|
| 537 |
+
wire [2:0] next_state;
|
| 538 |
+
|
| 539 |
+
//eliminate jitter
|
| 540 |
+
reg key_flag;
|
| 541 |
+
reg [19:0] key_count;
|
| 542 |
+
reg [ 3:0] state_count;
|
| 543 |
+
wire key_start = (state==3'b000) && !(&btn_key_row);
|
| 544 |
+
wire key_end = (state==3'b111) && (&btn_key_row);
|
| 545 |
+
wire key_sample= key_count[19];
|
| 546 |
+
always @(posedge aclk)
|
| 547 |
+
begin
|
| 548 |
+
if(!aresetn)
|
| 549 |
+
begin
|
| 550 |
+
key_flag <= 1'd0;
|
| 551 |
+
end
|
| 552 |
+
else if (key_sample && state_count[3])
|
| 553 |
+
begin
|
| 554 |
+
key_flag <= 1'b0;
|
| 555 |
+
end
|
| 556 |
+
else if( key_start || key_end )
|
| 557 |
+
begin
|
| 558 |
+
key_flag <= 1'b1;
|
| 559 |
+
end
|
| 560 |
+
|
| 561 |
+
if(!aresetn || !key_flag)
|
| 562 |
+
begin
|
| 563 |
+
key_count <= 20'd0;
|
| 564 |
+
end
|
| 565 |
+
else
|
| 566 |
+
begin
|
| 567 |
+
key_count <= key_count + 1'b1;
|
| 568 |
+
end
|
| 569 |
+
end
|
| 570 |
+
|
| 571 |
+
always @(posedge aclk)
|
| 572 |
+
begin
|
| 573 |
+
if(!aresetn || state_count[3])
|
| 574 |
+
begin
|
| 575 |
+
state_count <= 4'd0;
|
| 576 |
+
end
|
| 577 |
+
else
|
| 578 |
+
begin
|
| 579 |
+
state_count <= state_count + 1'b1;
|
| 580 |
+
end
|
| 581 |
+
end
|
| 582 |
+
|
| 583 |
+
always @(posedge aclk)
|
| 584 |
+
begin
|
| 585 |
+
if(!aresetn)
|
| 586 |
+
begin
|
| 587 |
+
state <= 3'b000;
|
| 588 |
+
end
|
| 589 |
+
else if (state_count[3])
|
| 590 |
+
begin
|
| 591 |
+
state <= next_state;
|
| 592 |
+
end
|
| 593 |
+
end
|
| 594 |
+
|
| 595 |
+
assign next_state = (state == 3'b000) ? ( (key_sample && !(&btn_key_row)) ? 3'b001 : 3'b000 ) :
|
| 596 |
+
(state == 3'b001) ? ( !(&btn_key_row) ? 3'b111 : 3'b010 ) :
|
| 597 |
+
(state == 3'b010) ? ( !(&btn_key_row) ? 3'b111 : 3'b011 ) :
|
| 598 |
+
(state == 3'b011) ? ( !(&btn_key_row) ? 3'b111 : 3'b100 ) :
|
| 599 |
+
(state == 3'b100) ? ( !(&btn_key_row) ? 3'b111 : 3'b000 ) :
|
| 600 |
+
(state == 3'b111) ? ( (key_sample && (&btn_key_row)) ? 3'b000 : 3'b111 ) :
|
| 601 |
+
3'b000;
|
| 602 |
+
assign btn_key_col = (state == 3'b000) ? 4'b0000:
|
| 603 |
+
(state == 3'b001) ? 4'b1110:
|
| 604 |
+
(state == 3'b010) ? 4'b1101:
|
| 605 |
+
(state == 3'b011) ? 4'b1011:
|
| 606 |
+
(state == 3'b100) ? 4'b0111:
|
| 607 |
+
4'b0000;
|
| 608 |
+
wire [15:0] btn_key_tmp;
|
| 609 |
+
always @(posedge aclk) begin
|
| 610 |
+
if(!aresetn) begin
|
| 611 |
+
btn_key_r <= 16'd0;
|
| 612 |
+
end
|
| 613 |
+
else if(next_state==3'b000)
|
| 614 |
+
begin
|
| 615 |
+
btn_key_r <=16'd0;
|
| 616 |
+
end
|
| 617 |
+
else if(next_state == 3'b111 && state != 3'b111) begin
|
| 618 |
+
btn_key_r <= btn_key_tmp;
|
| 619 |
+
end
|
| 620 |
+
end
|
| 621 |
+
|
| 622 |
+
assign btn_key_tmp = (state == 3'b001)&(btn_key_row == 4'b1110) ? 16'h0001:
|
| 623 |
+
(state == 3'b001)&(btn_key_row == 4'b1101) ? 16'h0010:
|
| 624 |
+
(state == 3'b001)&(btn_key_row == 4'b1011) ? 16'h0100:
|
| 625 |
+
(state == 3'b001)&(btn_key_row == 4'b0111) ? 16'h1000:
|
| 626 |
+
(state == 3'b010)&(btn_key_row == 4'b1110) ? 16'h0002:
|
| 627 |
+
(state == 3'b010)&(btn_key_row == 4'b1101) ? 16'h0020:
|
| 628 |
+
(state == 3'b010)&(btn_key_row == 4'b1011) ? 16'h0200:
|
| 629 |
+
(state == 3'b010)&(btn_key_row == 4'b0111) ? 16'h2000:
|
| 630 |
+
(state == 3'b011)&(btn_key_row == 4'b1110) ? 16'h0004:
|
| 631 |
+
(state == 3'b011)&(btn_key_row == 4'b1101) ? 16'h0040:
|
| 632 |
+
(state == 3'b011)&(btn_key_row == 4'b1011) ? 16'h0400:
|
| 633 |
+
(state == 3'b011)&(btn_key_row == 4'b0111) ? 16'h4000:
|
| 634 |
+
(state == 3'b100)&(btn_key_row == 4'b1110) ? 16'h0008:
|
| 635 |
+
(state == 3'b100)&(btn_key_row == 4'b1101) ? 16'h0080:
|
| 636 |
+
(state == 3'b100)&(btn_key_row == 4'b1011) ? 16'h0800:
|
| 637 |
+
(state == 3'b100)&(btn_key_row == 4'b0111) ? 16'h8000:16'h0000;
|
| 638 |
+
//-------------------------------{btn key}end----------------------------//
|
| 639 |
+
|
| 640 |
+
//-----------------------------{btn step}begin---------------------------//
|
| 641 |
+
//btn step data
|
| 642 |
+
reg btn_step0_r; //0:press
|
| 643 |
+
reg btn_step1_r; //0:press
|
| 644 |
+
assign btn_step_data = {30'd0,~btn_step0_r,~btn_step1_r}; //1:press
|
| 645 |
+
|
| 646 |
+
//-----step0
|
| 647 |
+
//eliminate jitter
|
| 648 |
+
reg step0_flag;
|
| 649 |
+
reg [19:0] step0_count;
|
| 650 |
+
wire step0_start = btn_step0_r && !btn_step[0];
|
| 651 |
+
wire step0_end = !btn_step0_r && btn_step[0];
|
| 652 |
+
wire step0_sample= step0_count[19];
|
| 653 |
+
always @(posedge aclk)
|
| 654 |
+
begin
|
| 655 |
+
if(!aresetn)
|
| 656 |
+
begin
|
| 657 |
+
step0_flag <= 1'd0;
|
| 658 |
+
end
|
| 659 |
+
else if (step0_sample)
|
| 660 |
+
begin
|
| 661 |
+
step0_flag <= 1'b0;
|
| 662 |
+
end
|
| 663 |
+
else if( step0_start || step0_end )
|
| 664 |
+
begin
|
| 665 |
+
step0_flag <= 1'b1;
|
| 666 |
+
end
|
| 667 |
+
|
| 668 |
+
if(!aresetn || !step0_flag)
|
| 669 |
+
begin
|
| 670 |
+
step0_count <= 20'd0;
|
| 671 |
+
end
|
| 672 |
+
else
|
| 673 |
+
begin
|
| 674 |
+
step0_count <= step0_count + 1'b1;
|
| 675 |
+
end
|
| 676 |
+
|
| 677 |
+
if(!aresetn)
|
| 678 |
+
begin
|
| 679 |
+
btn_step0_r <= 1'b1;
|
| 680 |
+
end
|
| 681 |
+
else if(step0_sample)
|
| 682 |
+
begin
|
| 683 |
+
btn_step0_r <= btn_step[0];
|
| 684 |
+
end
|
| 685 |
+
end
|
| 686 |
+
|
| 687 |
+
//-----step1
|
| 688 |
+
//eliminate jitter
|
| 689 |
+
reg step1_flag;
|
| 690 |
+
reg [19:0] step1_count;
|
| 691 |
+
wire step1_start = btn_step1_r && !btn_step[1];
|
| 692 |
+
wire step1_end = !btn_step1_r && btn_step[1];
|
| 693 |
+
wire step1_sample= step1_count[19];
|
| 694 |
+
always @(posedge aclk)
|
| 695 |
+
begin
|
| 696 |
+
if(!aresetn)
|
| 697 |
+
begin
|
| 698 |
+
step1_flag <= 1'd0;
|
| 699 |
+
end
|
| 700 |
+
else if (step1_sample)
|
| 701 |
+
begin
|
| 702 |
+
step1_flag <= 1'b0;
|
| 703 |
+
end
|
| 704 |
+
else if( step1_start || step1_end )
|
| 705 |
+
begin
|
| 706 |
+
step1_flag <= 1'b1;
|
| 707 |
+
end
|
| 708 |
+
|
| 709 |
+
if(!aresetn || !step1_flag)
|
| 710 |
+
begin
|
| 711 |
+
step1_count <= 20'd0;
|
| 712 |
+
end
|
| 713 |
+
else
|
| 714 |
+
begin
|
| 715 |
+
step1_count <= step1_count + 1'b1;
|
| 716 |
+
end
|
| 717 |
+
|
| 718 |
+
if(!aresetn)
|
| 719 |
+
begin
|
| 720 |
+
btn_step1_r <= 1'b1;
|
| 721 |
+
end
|
| 722 |
+
else if(step1_sample)
|
| 723 |
+
begin
|
| 724 |
+
btn_step1_r <= btn_step[1];
|
| 725 |
+
end
|
| 726 |
+
end
|
| 727 |
+
//------------------------------{btn step}end----------------------------//
|
| 728 |
+
|
| 729 |
+
//-------------------------------{led rg}begin---------------------------//
|
| 730 |
+
//led_rg0_data[31:0] led_rg0_data[31:0]
|
| 731 |
+
//bfd0_f010 bfd0_f014
|
| 732 |
+
wire write_led_rg0 = conf_we & (conf_addr[15:0]==`LED_RG0_ADDR);
|
| 733 |
+
wire write_led_rg1 = conf_we & (conf_addr[15:0]==`LED_RG1_ADDR);
|
| 734 |
+
assign led_rg0 = led_rg0_data[1:0];
|
| 735 |
+
assign led_rg1 = led_rg1_data[1:0];
|
| 736 |
+
always @(posedge aclk)
|
| 737 |
+
begin
|
| 738 |
+
if(!aresetn)
|
| 739 |
+
begin
|
| 740 |
+
led_rg0_data <= 32'h0;
|
| 741 |
+
end
|
| 742 |
+
else if(write_led_rg0)
|
| 743 |
+
begin
|
| 744 |
+
led_rg0_data <= conf_wdata[31:0];
|
| 745 |
+
end
|
| 746 |
+
|
| 747 |
+
if(!aresetn)
|
| 748 |
+
begin
|
| 749 |
+
led_rg1_data <= 32'h0;
|
| 750 |
+
end
|
| 751 |
+
else if(write_led_rg1)
|
| 752 |
+
begin
|
| 753 |
+
led_rg1_data <= conf_wdata[31:0];
|
| 754 |
+
end
|
| 755 |
+
end
|
| 756 |
+
//--------------------------------{led rg}end----------------------------//
|
| 757 |
+
|
| 758 |
+
//---------------------------{digital number}begin-----------------------//
|
| 759 |
+
//digital number display
|
| 760 |
+
//num_data[31:0]
|
| 761 |
+
wire write_num = conf_we & (conf_addr[15:0]==`NUM_ADDR);
|
| 762 |
+
always @(posedge aclk)
|
| 763 |
+
begin
|
| 764 |
+
if(!aresetn)
|
| 765 |
+
begin
|
| 766 |
+
num_data <= 32'h0;
|
| 767 |
+
end
|
| 768 |
+
else if(write_num)
|
| 769 |
+
begin
|
| 770 |
+
num_data <= conf_wdata[31:0];
|
| 771 |
+
end
|
| 772 |
+
end
|
| 773 |
+
|
| 774 |
+
|
| 775 |
+
reg [19:0] count;
|
| 776 |
+
always @(posedge aclk)
|
| 777 |
+
begin
|
| 778 |
+
if(!aresetn)
|
| 779 |
+
begin
|
| 780 |
+
count <= 20'd0;
|
| 781 |
+
end
|
| 782 |
+
else
|
| 783 |
+
begin
|
| 784 |
+
count <= count + 1'b1;
|
| 785 |
+
end
|
| 786 |
+
end
|
| 787 |
+
//scan data
|
| 788 |
+
reg [3:0] scan_data;
|
| 789 |
+
always @ ( posedge aclk )
|
| 790 |
+
begin
|
| 791 |
+
if ( !aresetn )
|
| 792 |
+
begin
|
| 793 |
+
scan_data <= 4'd0;
|
| 794 |
+
num_csn <= 8'b1111_1111;
|
| 795 |
+
end
|
| 796 |
+
else
|
| 797 |
+
begin
|
| 798 |
+
case(count[19:17])
|
| 799 |
+
3'b000 : scan_data <= num_data[31:28];
|
| 800 |
+
3'b001 : scan_data <= num_data[27:24];
|
| 801 |
+
3'b010 : scan_data <= num_data[23:20];
|
| 802 |
+
3'b011 : scan_data <= num_data[19:16];
|
| 803 |
+
3'b100 : scan_data <= num_data[15:12];
|
| 804 |
+
3'b101 : scan_data <= num_data[11: 8];
|
| 805 |
+
3'b110 : scan_data <= num_data[7 : 4];
|
| 806 |
+
3'b111 : scan_data <= num_data[3 : 0];
|
| 807 |
+
endcase
|
| 808 |
+
|
| 809 |
+
case(count[19:17])
|
| 810 |
+
3'b000 : num_csn <= 8'b0111_1111;
|
| 811 |
+
3'b001 : num_csn <= 8'b1011_1111;
|
| 812 |
+
3'b010 : num_csn <= 8'b1101_1111;
|
| 813 |
+
3'b011 : num_csn <= 8'b1110_1111;
|
| 814 |
+
3'b100 : num_csn <= 8'b1111_0111;
|
| 815 |
+
3'b101 : num_csn <= 8'b1111_1011;
|
| 816 |
+
3'b110 : num_csn <= 8'b1111_1101;
|
| 817 |
+
3'b111 : num_csn <= 8'b1111_1110;
|
| 818 |
+
endcase
|
| 819 |
+
end
|
| 820 |
+
end
|
| 821 |
+
|
| 822 |
+
always @(posedge aclk)
|
| 823 |
+
begin
|
| 824 |
+
if ( !aresetn )
|
| 825 |
+
begin
|
| 826 |
+
num_a_g <= 7'b0000000;
|
| 827 |
+
end
|
| 828 |
+
else
|
| 829 |
+
begin
|
| 830 |
+
case ( scan_data )
|
| 831 |
+
4'd0 : num_a_g <= 7'b1111110; //0
|
| 832 |
+
4'd1 : num_a_g <= 7'b0110000; //1
|
| 833 |
+
4'd2 : num_a_g <= 7'b1101101; //2
|
| 834 |
+
4'd3 : num_a_g <= 7'b1111001; //3
|
| 835 |
+
4'd4 : num_a_g <= 7'b0110011; //4
|
| 836 |
+
4'd5 : num_a_g <= 7'b1011011; //5
|
| 837 |
+
4'd6 : num_a_g <= 7'b1011111; //6
|
| 838 |
+
4'd7 : num_a_g <= 7'b1110000; //7
|
| 839 |
+
4'd8 : num_a_g <= 7'b1111111; //8
|
| 840 |
+
4'd9 : num_a_g <= 7'b1111011; //9
|
| 841 |
+
4'd10: num_a_g <= 7'b1110111; //a
|
| 842 |
+
4'd11: num_a_g <= 7'b0011111; //b
|
| 843 |
+
4'd12: num_a_g <= 7'b1001110; //c
|
| 844 |
+
4'd13: num_a_g <= 7'b0111101; //d
|
| 845 |
+
4'd14: num_a_g <= 7'b1001111; //e
|
| 846 |
+
4'd15: num_a_g <= 7'b1000111; //f
|
| 847 |
+
endcase
|
| 848 |
+
end
|
| 849 |
+
end
|
| 850 |
+
//----------------------------{digital number}end------------------------//
|
| 851 |
+
endmodule
|
MaxXSoft_Fuxi/soc/peripherals/lcd/nt35510_controller/src/nt35510_apb_adapter_v1_0.v
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`define APB_INSTRUCTION_ADDR (3'b000)
|
| 2 |
+
`define APB_DATA_ADDR (3'b100)
|
| 3 |
+
|
| 4 |
+
`define APH_FSM_SETUP (0)
|
| 5 |
+
`define APH_FSM_SETUP_RS (1)
|
| 6 |
+
`define APH_FSM_ACCESS (2)
|
| 7 |
+
`define APH_FSM_READY (3)
|
| 8 |
+
`define APH_FSM_STALL (4)
|
| 9 |
+
|
| 10 |
+
`define NT35510_RD_CYCLE (50)
|
| 11 |
+
`define NT35510_WR_CYCLE (5)
|
| 12 |
+
`define NT35510_RS_CYCLE (3)
|
| 13 |
+
|
| 14 |
+
module nt35510_apb_adapter_v1_0 (
|
| 15 |
+
// Clock and reset
|
| 16 |
+
input wire nrst,
|
| 17 |
+
input wire clk,
|
| 18 |
+
|
| 19 |
+
// APB Bus i/f
|
| 20 |
+
input wire [31:0] APB_paddr,
|
| 21 |
+
input wire APB_psel,
|
| 22 |
+
input wire APB_penable,
|
| 23 |
+
input wire APB_pwrite,
|
| 24 |
+
input wire [31:0] APB_pwdata,
|
| 25 |
+
output wire APB_pready,
|
| 26 |
+
output reg [31:0] APB_prdata,
|
| 27 |
+
output wire APB_pslverr,
|
| 28 |
+
|
| 29 |
+
// NT35510 LCD driver i/f
|
| 30 |
+
output wire LCD_nrst,
|
| 31 |
+
output reg LCD_csel,
|
| 32 |
+
output reg LCD_rs,
|
| 33 |
+
output reg LCD_wr,
|
| 34 |
+
output reg LCD_rd,
|
| 35 |
+
input wire [15:0] LCD_data_in,
|
| 36 |
+
output reg [15:0] LCD_data_out,
|
| 37 |
+
output reg [15:0] LCD_data_z
|
| 38 |
+
);
|
| 39 |
+
|
| 40 |
+
reg [2:0] state;
|
| 41 |
+
reg [8:0] cyclecount;
|
| 42 |
+
reg [8:0] targetcount;
|
| 43 |
+
|
| 44 |
+
assign APB_pslverr = 1'b0;
|
| 45 |
+
assign APB_pready = (state == `APH_FSM_READY) ? 1'b1 : 1'b0;
|
| 46 |
+
|
| 47 |
+
assign LCD_nrst = nrst;
|
| 48 |
+
|
| 49 |
+
always @(posedge clk, negedge nrst) begin
|
| 50 |
+
if (~nrst) begin
|
| 51 |
+
state <= `APH_FSM_SETUP;
|
| 52 |
+
cyclecount <= 0;
|
| 53 |
+
targetcount <= 0;
|
| 54 |
+
LCD_csel <= 1'b1;
|
| 55 |
+
LCD_wr <= 1'b1;
|
| 56 |
+
LCD_rs <= 1'b0;
|
| 57 |
+
LCD_rd <= 1'b1;
|
| 58 |
+
LCD_data_z <= 16'hFFFF;
|
| 59 |
+
end else begin
|
| 60 |
+
case (state)
|
| 61 |
+
`APH_FSM_SETUP: begin
|
| 62 |
+
if (APB_penable&APB_psel) begin
|
| 63 |
+
LCD_rs <= (APB_paddr[2:0] == `APB_INSTRUCTION_ADDR) ? 1'b0 : 1'b1;
|
| 64 |
+
state <= `APH_FSM_SETUP_RS;
|
| 65 |
+
cyclecount <= 0;
|
| 66 |
+
end
|
| 67 |
+
end
|
| 68 |
+
`APH_FSM_SETUP_RS: begin
|
| 69 |
+
cyclecount = cyclecount + 1;
|
| 70 |
+
if (cyclecount == `NT35510_RS_CYCLE) begin
|
| 71 |
+
cyclecount <= 0;
|
| 72 |
+
if (APB_pwrite) begin
|
| 73 |
+
LCD_csel <= 1'b0;
|
| 74 |
+
LCD_data_z <= 16'h0000;
|
| 75 |
+
LCD_data_out <= APB_pwdata[15:0];
|
| 76 |
+
LCD_wr <= 1'b0;
|
| 77 |
+
targetcount <= `NT35510_WR_CYCLE;
|
| 78 |
+
end else begin
|
| 79 |
+
LCD_rd <= 1'b0;
|
| 80 |
+
targetcount <= `NT35510_RD_CYCLE;
|
| 81 |
+
end
|
| 82 |
+
state <= `APH_FSM_ACCESS;
|
| 83 |
+
end
|
| 84 |
+
end
|
| 85 |
+
`APH_FSM_ACCESS: begin
|
| 86 |
+
cyclecount = cyclecount + 1;
|
| 87 |
+
if (cyclecount == targetcount) begin
|
| 88 |
+
if (~APB_pwrite) begin
|
| 89 |
+
APB_prdata <= {16'b0, LCD_data_in};
|
| 90 |
+
end
|
| 91 |
+
LCD_wr <= 1'b1;
|
| 92 |
+
LCD_rd <= 1'b1;
|
| 93 |
+
state <= `APH_FSM_READY;
|
| 94 |
+
end
|
| 95 |
+
end
|
| 96 |
+
`APH_FSM_READY: begin
|
| 97 |
+
if (~(APB_penable&APB_psel)) begin
|
| 98 |
+
cyclecount = 0;
|
| 99 |
+
state <= `APH_FSM_STALL;
|
| 100 |
+
end
|
| 101 |
+
end
|
| 102 |
+
`APH_FSM_STALL: begin
|
| 103 |
+
cyclecount = cyclecount + 1;
|
| 104 |
+
if (cyclecount == targetcount) begin
|
| 105 |
+
state <= `APH_FSM_SETUP;
|
| 106 |
+
LCD_csel <= 1'b1;
|
| 107 |
+
LCD_data_z <= 16'hFFFF;
|
| 108 |
+
end
|
| 109 |
+
end
|
| 110 |
+
default: begin
|
| 111 |
+
state <= `APH_FSM_SETUP;
|
| 112 |
+
end
|
| 113 |
+
endcase
|
| 114 |
+
end
|
| 115 |
+
end
|
| 116 |
+
|
| 117 |
+
endmodule
|
MaxXSoft_Fuxi/soc/peripherals/lcd/nt35510_controller/xgui/nt35510_apb_adapter_v1_0_v1_0.tcl
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Definitional proc to organize widgets for parameters.
|
| 2 |
+
proc init_gui { IPINST } {
|
| 3 |
+
ipgui::add_param $IPINST -name "Component_Name"
|
| 4 |
+
#Adding Page
|
| 5 |
+
ipgui::add_page $IPINST -name "Page 0"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
|
MaxXSoft_Fuxi/soc/peripherals/lcd/nt35510_controller/xgui/nt35510_controller_v1_0.tcl
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Definitional proc to organize widgets for parameters.
|
| 2 |
+
proc init_gui { IPINST } {
|
| 3 |
+
ipgui::add_param $IPINST -name "Component_Name"
|
| 4 |
+
#Adding Page
|
| 5 |
+
ipgui::add_page $IPINST -name "Page 0"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
|
MaxXSoft_Fuxi/soc/soc.srcs/sim_1/new/SoC_tb.v
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`timescale 1ns / 1ps
|
| 2 |
+
|
| 3 |
+
module SoC_tb();
|
| 4 |
+
|
| 5 |
+
reg clk, rst_n;
|
| 6 |
+
wire cfg_si, cfg_so, cfg_ss;
|
| 7 |
+
|
| 8 |
+
SoC soc_inst(
|
| 9 |
+
.clk (clk),
|
| 10 |
+
.rst_n (rst_n),
|
| 11 |
+
|
| 12 |
+
.UART_rxd (1'b0),
|
| 13 |
+
.UART_txd (),
|
| 14 |
+
|
| 15 |
+
.SPI_FLASH_mosi (),
|
| 16 |
+
.SPI_FLASH_miso (),
|
| 17 |
+
.SPI_FLASH_ss (),
|
| 18 |
+
.SPI_FLASH_sck (),
|
| 19 |
+
.SPI_FLASH_io2 (),
|
| 20 |
+
.SPI_FLASH_io3 (),
|
| 21 |
+
|
| 22 |
+
.CFG_FLASH_mosi (cfg_si),
|
| 23 |
+
.CFG_FLASH_miso (cfg_so),
|
| 24 |
+
.CFG_FLASH_ss (cfg_ss),
|
| 25 |
+
|
| 26 |
+
.VGA_r (),
|
| 27 |
+
.VGA_g (),
|
| 28 |
+
.VGA_b (),
|
| 29 |
+
.VGA_hsync (),
|
| 30 |
+
.VGA_vsync (),
|
| 31 |
+
|
| 32 |
+
.led (),
|
| 33 |
+
.led_rg0 (),
|
| 34 |
+
.led_rg1 (),
|
| 35 |
+
.num_csn (),
|
| 36 |
+
.num_a_g (),
|
| 37 |
+
.num_a_g_dp (),
|
| 38 |
+
.btn_key_col (),
|
| 39 |
+
.btn_key_row (4'b0),
|
| 40 |
+
.btn_step (2'b0),
|
| 41 |
+
.switch (8'b0),
|
| 42 |
+
|
| 43 |
+
.DDR3_dq (),
|
| 44 |
+
.DDR3_addr (),
|
| 45 |
+
.DDR3_ba (),
|
| 46 |
+
.DDR3_ras_n (),
|
| 47 |
+
.DDR3_cas_n (),
|
| 48 |
+
.DDR3_we_n (),
|
| 49 |
+
.DDR3_odt (),
|
| 50 |
+
.DDR3_reset_n (),
|
| 51 |
+
.DDR3_cke (),
|
| 52 |
+
.DDR3_dm (),
|
| 53 |
+
.DDR3_dqs_p (),
|
| 54 |
+
.DDR3_dqs_n (),
|
| 55 |
+
.DDR3_ck_p (),
|
| 56 |
+
.DDR3_ck_n (),
|
| 57 |
+
|
| 58 |
+
.MDIO_mdc (),
|
| 59 |
+
.MDIO_mdio (),
|
| 60 |
+
.MII_col (1'b0),
|
| 61 |
+
.MII_crs (1'b0),
|
| 62 |
+
.MII_rst_n (),
|
| 63 |
+
.MII_rx_clk (1'b0),
|
| 64 |
+
.MII_rx_dv (1'b0),
|
| 65 |
+
.MII_rx_er (1'b0),
|
| 66 |
+
.MII_rxd (4'b0),
|
| 67 |
+
.MII_tx_clk (1'b0),
|
| 68 |
+
.MII_tx_en (),
|
| 69 |
+
.MII_tx_er (),
|
| 70 |
+
.MII_txd (),
|
| 71 |
+
|
| 72 |
+
.LCD_data (),
|
| 73 |
+
.LCD_nrst (),
|
| 74 |
+
.LCD_csel (),
|
| 75 |
+
.LCD_rd (),
|
| 76 |
+
.LCD_rs (),
|
| 77 |
+
.LCD_wr (),
|
| 78 |
+
.LCD_lighton ()
|
| 79 |
+
);
|
| 80 |
+
|
| 81 |
+
s25fl128s cfg_flash(
|
| 82 |
+
.SI (cfg_si),
|
| 83 |
+
.SO (cfg_so),
|
| 84 |
+
.SCK (clk),
|
| 85 |
+
.CSNeg (cfg_ss),
|
| 86 |
+
.RSTNeg (1'b1),
|
| 87 |
+
.HOLDNeg (),
|
| 88 |
+
.WPNeg ()
|
| 89 |
+
);
|
| 90 |
+
|
| 91 |
+
always begin
|
| 92 |
+
#5 clk <= ~clk;
|
| 93 |
+
end
|
| 94 |
+
|
| 95 |
+
initial begin
|
| 96 |
+
clk <= 0;
|
| 97 |
+
rst_n <= 0;
|
| 98 |
+
#7 rst_n <= 1;
|
| 99 |
+
end
|
| 100 |
+
|
| 101 |
+
endmodule
|
MaxXSoft_Fuxi/soc/soc.srcs/sim_1/new/s25fl128s.v
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
MaxXSoft_Fuxi/soc/soc.srcs/sources_1/bd/mref/Clint/xgui/Clint_v1_0.tcl
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Definitional proc to organize widgets for parameters.
|
| 2 |
+
proc init_gui { IPINST } {
|
| 3 |
+
ipgui::add_param $IPINST -name "Component_Name"
|
| 4 |
+
#Adding Page
|
| 5 |
+
ipgui::add_page $IPINST -name "Page 0"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
|
MaxXSoft_Fuxi/soc/soc.srcs/sources_1/bd/mref/FuxiWrapper/xgui/FuxiWrapper_v1_0.tcl
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Definitional proc to organize widgets for parameters.
|
| 2 |
+
proc init_gui { IPINST } {
|
| 3 |
+
ipgui::add_param $IPINST -name "Component_Name"
|
| 4 |
+
#Adding Page
|
| 5 |
+
ipgui::add_page $IPINST -name "Page 0"
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
|
MaxXSoft_Fuxi/soc/soc.srcs/sources_1/bd/mref/ResetSynchronizer/xgui/ResetSynchronizer_v1_0.tcl
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Definitional proc to organize widgets for parameters.
|
| 2 |
+
proc init_gui { IPINST } {
|
| 3 |
+
ipgui::add_param $IPINST -name "Component_Name"
|
| 4 |
+
#Adding Page
|
| 5 |
+
set Page_0 [ipgui::add_page $IPINST -name "Page 0"]
|
| 6 |
+
ipgui::add_param $IPINST -name "RESET_POSEDGE" -parent ${Page_0}
|
| 7 |
+
ipgui::add_param $IPINST -name "RESET_STAGE" -parent ${Page_0}
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
proc update_PARAM_VALUE.RESET_POSEDGE { PARAM_VALUE.RESET_POSEDGE } {
|
| 13 |
+
# Procedure called to update RESET_POSEDGE when any of the dependent parameters in the arguments change
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
proc validate_PARAM_VALUE.RESET_POSEDGE { PARAM_VALUE.RESET_POSEDGE } {
|
| 17 |
+
# Procedure called to validate RESET_POSEDGE
|
| 18 |
+
return true
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
proc update_PARAM_VALUE.RESET_STAGE { PARAM_VALUE.RESET_STAGE } {
|
| 22 |
+
# Procedure called to update RESET_STAGE when any of the dependent parameters in the arguments change
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
proc validate_PARAM_VALUE.RESET_STAGE { PARAM_VALUE.RESET_STAGE } {
|
| 26 |
+
# Procedure called to validate RESET_STAGE
|
| 27 |
+
return true
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
proc update_MODELPARAM_VALUE.RESET_STAGE { MODELPARAM_VALUE.RESET_STAGE PARAM_VALUE.RESET_STAGE } {
|
| 32 |
+
# Procedure called to set VHDL generic/Verilog parameter value(s) based on TCL parameter value
|
| 33 |
+
set_property value [get_property value ${PARAM_VALUE.RESET_STAGE}] ${MODELPARAM_VALUE.RESET_STAGE}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
proc update_MODELPARAM_VALUE.RESET_POSEDGE { MODELPARAM_VALUE.RESET_POSEDGE PARAM_VALUE.RESET_POSEDGE } {
|
| 37 |
+
# Procedure called to set VHDL generic/Verilog parameter value(s) based on TCL parameter value
|
| 38 |
+
set_property value [get_property value ${PARAM_VALUE.RESET_POSEDGE}] ${MODELPARAM_VALUE.RESET_POSEDGE}
|
| 39 |
+
}
|
| 40 |
+
|
MaxXSoft_Fuxi/soc/soc.srcs/sources_1/bd/mref/confreg/xgui/confreg_v1_0.tcl
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Definitional proc to organize widgets for parameters.
|
| 2 |
+
proc init_gui { IPINST } {
|
| 3 |
+
ipgui::add_param $IPINST -name "Component_Name"
|
| 4 |
+
#Adding Page
|
| 5 |
+
set Page_0 [ipgui::add_page $IPINST -name "Page 0"]
|
| 6 |
+
ipgui::add_param $IPINST -name "BUS_WIDTH" -parent ${Page_0}
|
| 7 |
+
ipgui::add_param $IPINST -name "SIMULATION" -parent ${Page_0}
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
proc update_PARAM_VALUE.BUS_WIDTH { PARAM_VALUE.BUS_WIDTH } {
|
| 13 |
+
# Procedure called to update BUS_WIDTH when any of the dependent parameters in the arguments change
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
proc validate_PARAM_VALUE.BUS_WIDTH { PARAM_VALUE.BUS_WIDTH } {
|
| 17 |
+
# Procedure called to validate BUS_WIDTH
|
| 18 |
+
return true
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
proc update_PARAM_VALUE.SIMULATION { PARAM_VALUE.SIMULATION } {
|
| 22 |
+
# Procedure called to update SIMULATION when any of the dependent parameters in the arguments change
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
proc validate_PARAM_VALUE.SIMULATION { PARAM_VALUE.SIMULATION } {
|
| 26 |
+
# Procedure called to validate SIMULATION
|
| 27 |
+
return true
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
proc update_MODELPARAM_VALUE.SIMULATION { MODELPARAM_VALUE.SIMULATION PARAM_VALUE.SIMULATION } {
|
| 32 |
+
# Procedure called to set VHDL generic/Verilog parameter value(s) based on TCL parameter value
|
| 33 |
+
set_property value [get_property value ${PARAM_VALUE.SIMULATION}] ${MODELPARAM_VALUE.SIMULATION}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
proc update_MODELPARAM_VALUE.BUS_WIDTH { MODELPARAM_VALUE.BUS_WIDTH PARAM_VALUE.BUS_WIDTH } {
|
| 37 |
+
# Procedure called to set VHDL generic/Verilog parameter value(s) based on TCL parameter value
|
| 38 |
+
set_property value [get_property value ${PARAM_VALUE.BUS_WIDTH}] ${MODELPARAM_VALUE.BUS_WIDTH}
|
| 39 |
+
}
|
| 40 |
+
|
MaxXSoft_Fuxi/soc/soc.srcs/sources_1/new/SoC.v
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// from https://github.com/trivialmips/nontrivial-mips
|
| 2 |
+
// modified by: MaxXing, 2020-05
|
| 3 |
+
|
| 4 |
+
`timescale 1ns / 1ps
|
| 5 |
+
|
| 6 |
+
`include "iobuf.v"
|
| 7 |
+
|
| 8 |
+
module SoC(
|
| 9 |
+
input clk,
|
| 10 |
+
input rst_n,
|
| 11 |
+
// UART
|
| 12 |
+
input UART_rxd,
|
| 13 |
+
output UART_txd,
|
| 14 |
+
// plugable SPI flash
|
| 15 |
+
inout SPI_FLASH_mosi,
|
| 16 |
+
inout SPI_FLASH_miso,
|
| 17 |
+
inout SPI_FLASH_ss,
|
| 18 |
+
inout SPI_FLASH_sck,
|
| 19 |
+
inout SPI_FLASH_io2,
|
| 20 |
+
inout SPI_FLASH_io3,
|
| 21 |
+
// non-plugable CFG SPI flash
|
| 22 |
+
inout CFG_FLASH_mosi,
|
| 23 |
+
inout CFG_FLASH_miso,
|
| 24 |
+
inout CFG_FLASH_ss,
|
| 25 |
+
// VGA (use inout for high-Z output)
|
| 26 |
+
inout [3:0] VGA_r,
|
| 27 |
+
inout [3:0] VGA_g,
|
| 28 |
+
inout [3:0] VGA_b,
|
| 29 |
+
output VGA_hsync,
|
| 30 |
+
output VGA_vsync,
|
| 31 |
+
// GPIO
|
| 32 |
+
output [15:0] led,
|
| 33 |
+
output [1:0] led_rg0,
|
| 34 |
+
output [1:0] led_rg1,
|
| 35 |
+
output [7:0] num_csn,
|
| 36 |
+
output [6:0] num_a_g,
|
| 37 |
+
output num_a_g_dp,
|
| 38 |
+
output [3:0] btn_key_col,
|
| 39 |
+
input [3:0] btn_key_row,
|
| 40 |
+
input [1:0] btn_step,
|
| 41 |
+
input [7:0] switch,
|
| 42 |
+
// DDR3
|
| 43 |
+
inout [15:0] DDR3_dq,
|
| 44 |
+
output [12:0] DDR3_addr,
|
| 45 |
+
output [2:0] DDR3_ba,
|
| 46 |
+
output DDR3_ras_n,
|
| 47 |
+
output DDR3_cas_n,
|
| 48 |
+
output DDR3_we_n,
|
| 49 |
+
output DDR3_odt,
|
| 50 |
+
output DDR3_reset_n,
|
| 51 |
+
output DDR3_cke,
|
| 52 |
+
output [1:0] DDR3_dm,
|
| 53 |
+
inout [1:0] DDR3_dqs_p,
|
| 54 |
+
inout [1:0] DDR3_dqs_n,
|
| 55 |
+
output DDR3_ck_p,
|
| 56 |
+
output DDR3_ck_n,
|
| 57 |
+
// ethernet
|
| 58 |
+
output MDIO_mdc,
|
| 59 |
+
inout MDIO_mdio,
|
| 60 |
+
input MII_col,
|
| 61 |
+
input MII_crs,
|
| 62 |
+
output MII_rst_n,
|
| 63 |
+
input MII_rx_clk,
|
| 64 |
+
input MII_rx_dv,
|
| 65 |
+
input MII_rx_er,
|
| 66 |
+
input [3:0] MII_rxd,
|
| 67 |
+
input MII_tx_clk,
|
| 68 |
+
output MII_tx_en,
|
| 69 |
+
output MII_tx_er,
|
| 70 |
+
output [3:0] MII_txd,
|
| 71 |
+
// LCD
|
| 72 |
+
inout [15:0] LCD_data,
|
| 73 |
+
output LCD_nrst,
|
| 74 |
+
output LCD_csel,
|
| 75 |
+
output LCD_rd,
|
| 76 |
+
output LCD_rs,
|
| 77 |
+
output LCD_wr,
|
| 78 |
+
output LCD_lighton
|
| 79 |
+
);
|
| 80 |
+
|
| 81 |
+
// plugable SPI flash
|
| 82 |
+
`IOBUF_GEN(SPI_FLASH_mosi, SPI_FLASH_io0)
|
| 83 |
+
`IOBUF_GEN(SPI_FLASH_miso, SPI_FLASH_io1)
|
| 84 |
+
`IOBUF_GEN_SIMPLE(SPI_FLASH_io2)
|
| 85 |
+
`IOBUF_GEN_SIMPLE(SPI_FLASH_io3)
|
| 86 |
+
`IOBUF_GEN_SIMPLE(SPI_FLASH_ss)
|
| 87 |
+
`IOBUF_GEN_SIMPLE(SPI_FLASH_sck)
|
| 88 |
+
|
| 89 |
+
// non-plugable CFG SPI flash
|
| 90 |
+
`IOBUF_GEN(CFG_FLASH_mosi, CFG_FLASH_io0)
|
| 91 |
+
`IOBUF_GEN(CFG_FLASH_miso, CFG_FLASH_io1)
|
| 92 |
+
`IOBUF_GEN_SIMPLE(CFG_FLASH_ss)
|
| 93 |
+
|
| 94 |
+
// Ethernet
|
| 95 |
+
`IOBUF_GEN_SIMPLE(MDIO_mdio)
|
| 96 |
+
// not provided in Ethernet Lite
|
| 97 |
+
assign MII_tx_er = 1'b0;
|
| 98 |
+
|
| 99 |
+
// GPIO
|
| 100 |
+
// not provided in confreg IP
|
| 101 |
+
assign num_a_g_dp = 1'b0;
|
| 102 |
+
|
| 103 |
+
// LCD
|
| 104 |
+
`IOBUF_GEN_VEC(16, LCD_data, LCD_data_tri)
|
| 105 |
+
|
| 106 |
+
// VGA
|
| 107 |
+
wire [5:0] VGA_red, VGA_green, VGA_blue;
|
| 108 |
+
genvar VGA_i;
|
| 109 |
+
generate
|
| 110 |
+
for (VGA_i = 0; VGA_i < 4; VGA_i = VGA_i+1) begin : VGA_gen
|
| 111 |
+
// match on-board DAC built by resistor
|
| 112 |
+
assign VGA_r[VGA_i] = VGA_red[VGA_i+2] ? 1'b1 : 1'bZ;
|
| 113 |
+
assign VGA_g[VGA_i] = VGA_green[VGA_i+2] ? 1'b1 : 1'bZ;
|
| 114 |
+
assign VGA_b[VGA_i] = VGA_blue[VGA_i+2] ? 1'b1 : 1'bZ;
|
| 115 |
+
end
|
| 116 |
+
endgenerate
|
| 117 |
+
|
| 118 |
+
// initialize block design
|
| 119 |
+
soc soc_inst(
|
| 120 |
+
.clk (clk),
|
| 121 |
+
.rst_n (rst_n),
|
| 122 |
+
// UART
|
| 123 |
+
.UART_txd (UART_txd),
|
| 124 |
+
.UART_rxd (UART_rxd),
|
| 125 |
+
.UART_ctsn (1'b0),
|
| 126 |
+
.UART_dcdn (1'b0),
|
| 127 |
+
.UART_dsrn (1'b0),
|
| 128 |
+
.UART_ri (1'b1),
|
| 129 |
+
// plugable SPI flash
|
| 130 |
+
.SPI_FLASH_io0_i (SPI_FLASH_io0_i),
|
| 131 |
+
.SPI_FLASH_io0_o (SPI_FLASH_io0_o),
|
| 132 |
+
.SPI_FLASH_io0_t (SPI_FLASH_io0_t),
|
| 133 |
+
.SPI_FLASH_io1_i (SPI_FLASH_io1_i),
|
| 134 |
+
.SPI_FLASH_io1_o (SPI_FLASH_io1_o),
|
| 135 |
+
.SPI_FLASH_io1_t (SPI_FLASH_io1_t),
|
| 136 |
+
.SPI_FLASH_io2_i (SPI_FLASH_io2_i),
|
| 137 |
+
.SPI_FLASH_io2_o (SPI_FLASH_io2_o),
|
| 138 |
+
.SPI_FLASH_io2_t (SPI_FLASH_io2_t),
|
| 139 |
+
.SPI_FLASH_io3_i (SPI_FLASH_io3_i),
|
| 140 |
+
.SPI_FLASH_io3_o (SPI_FLASH_io3_o),
|
| 141 |
+
.SPI_FLASH_io3_t (SPI_FLASH_io3_t),
|
| 142 |
+
.SPI_FLASH_sck_i (SPI_FLASH_sck_i),
|
| 143 |
+
.SPI_FLASH_sck_o (SPI_FLASH_sck_o),
|
| 144 |
+
.SPI_FLASH_sck_t (SPI_FLASH_sck_t),
|
| 145 |
+
.SPI_FLASH_ss_i (SPI_FLASH_ss_i),
|
| 146 |
+
.SPI_FLASH_ss_o (SPI_FLASH_ss_o),
|
| 147 |
+
.SPI_FLASH_ss_t (SPI_FLASH_ss_t),
|
| 148 |
+
// non-plugable CFG SPI flash
|
| 149 |
+
.CFG_FLASH_io0_i (CFG_FLASH_io0_i),
|
| 150 |
+
.CFG_FLASH_io0_o (CFG_FLASH_io0_o),
|
| 151 |
+
.CFG_FLASH_io0_t (CFG_FLASH_io0_t),
|
| 152 |
+
.CFG_FLASH_io1_i (CFG_FLASH_io1_i),
|
| 153 |
+
.CFG_FLASH_io1_o (CFG_FLASH_io1_o),
|
| 154 |
+
.CFG_FLASH_io1_t (CFG_FLASH_io1_t),
|
| 155 |
+
.CFG_FLASH_ss_i (CFG_FLASH_ss_i),
|
| 156 |
+
.CFG_FLASH_ss_o (CFG_FLASH_ss_o),
|
| 157 |
+
.CFG_FLASH_ss_t (CFG_FLASH_ss_t),
|
| 158 |
+
// VGA
|
| 159 |
+
.VGA_hsync (VGA_hsync),
|
| 160 |
+
.VGA_vsync (VGA_vsync),
|
| 161 |
+
.VGA_red (VGA_red),
|
| 162 |
+
.VGA_green (VGA_green),
|
| 163 |
+
.VGA_blue (VGA_blue),
|
| 164 |
+
.VGA_clk (),
|
| 165 |
+
.VGA_de (),
|
| 166 |
+
.VGA_dps (),
|
| 167 |
+
// GPIO
|
| 168 |
+
.led (led),
|
| 169 |
+
.led_rg0 (led_rg0),
|
| 170 |
+
.led_rg1 (led_rg1),
|
| 171 |
+
.num_csn (num_csn),
|
| 172 |
+
.num_a_g (num_a_g),
|
| 173 |
+
.btn_key_col (btn_key_col),
|
| 174 |
+
.btn_key_row (btn_key_row),
|
| 175 |
+
.btn_step (btn_step),
|
| 176 |
+
.switch (switch),
|
| 177 |
+
// DDR3
|
| 178 |
+
.DDR3_dq (DDR3_dq),
|
| 179 |
+
.DDR3_addr (DDR3_addr),
|
| 180 |
+
.DDR3_ba (DDR3_ba),
|
| 181 |
+
.DDR3_ras_n (DDR3_ras_n),
|
| 182 |
+
.DDR3_cas_n (DDR3_cas_n),
|
| 183 |
+
.DDR3_we_n (DDR3_we_n),
|
| 184 |
+
.DDR3_odt (DDR3_odt),
|
| 185 |
+
.DDR3_reset_n (DDR3_reset_n),
|
| 186 |
+
.DDR3_cke (DDR3_cke),
|
| 187 |
+
.DDR3_dm (DDR3_dm),
|
| 188 |
+
.DDR3_dqs_p (DDR3_dqs_p),
|
| 189 |
+
.DDR3_dqs_n (DDR3_dqs_n),
|
| 190 |
+
.DDR3_ck_p (DDR3_ck_p),
|
| 191 |
+
.DDR3_ck_n (DDR3_ck_n),
|
| 192 |
+
// ethernet
|
| 193 |
+
// .MII_tx_er is not connected
|
| 194 |
+
.MDIO_mdc (MDIO_mdc),
|
| 195 |
+
.MDIO_mdio_i (MDIO_mdio_i),
|
| 196 |
+
.MDIO_mdio_o (MDIO_mdio_o),
|
| 197 |
+
.MDIO_mdio_t (MDIO_mdio_t),
|
| 198 |
+
.MII_col (MII_col),
|
| 199 |
+
.MII_crs (MII_crs),
|
| 200 |
+
.MII_rst_n (MII_rst_n),
|
| 201 |
+
.MII_rx_clk (MII_rx_clk),
|
| 202 |
+
.MII_rx_dv (MII_rx_dv),
|
| 203 |
+
.MII_rx_er (MII_rx_er),
|
| 204 |
+
.MII_rxd (MII_rxd),
|
| 205 |
+
.MII_tx_clk (MII_tx_clk),
|
| 206 |
+
.MII_tx_en (MII_tx_en),
|
| 207 |
+
.MII_txd (MII_txd),
|
| 208 |
+
// LCD
|
| 209 |
+
.LCD_data_tri_i (LCD_data_tri_i),
|
| 210 |
+
.LCD_data_tri_o (LCD_data_tri_o),
|
| 211 |
+
.LCD_data_tri_t (LCD_data_tri_t),
|
| 212 |
+
.LCD_nrst (LCD_nrst),
|
| 213 |
+
.LCD_csel (LCD_csel),
|
| 214 |
+
.LCD_rd (LCD_rd),
|
| 215 |
+
.LCD_rs (LCD_rs),
|
| 216 |
+
.LCD_wr (LCD_wr),
|
| 217 |
+
.LCD_lighton (LCD_lighton)
|
| 218 |
+
);
|
| 219 |
+
|
| 220 |
+
endmodule
|
MaxXSoft_Fuxi/soc/soc.srcs/sources_1/new/iobuf.v
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// from https://github.com/trivialmips/nontrivial-mips
|
| 2 |
+
// modified by: MaxXing, 2020-05
|
| 3 |
+
|
| 4 |
+
`ifndef FUXISOC_IOBUF_V_
|
| 5 |
+
`define FUXISOC_IOBUF_V_
|
| 6 |
+
|
| 7 |
+
`define IOBUF_GEN(IN, OUT) \
|
| 8 |
+
wire OUT``_i, OUT``_o, OUT``_t; \
|
| 9 |
+
IOBUF IN``_buf ( \
|
| 10 |
+
.IO(IN), \
|
| 11 |
+
.I(OUT``_o), \
|
| 12 |
+
.O(OUT``_i), \
|
| 13 |
+
.T(OUT``_t) \
|
| 14 |
+
);
|
| 15 |
+
|
| 16 |
+
`define IOBUF_GEN_SIMPLE(IN) `IOBUF_GEN(IN, IN)
|
| 17 |
+
|
| 18 |
+
`define IOBUF_GEN_VEC(BITS, IN, OUT) \
|
| 19 |
+
wire [BITS - 1:0] OUT``_i, OUT``_o, OUT``_t; \
|
| 20 |
+
genvar IN``_gen_var; \
|
| 21 |
+
generate \
|
| 22 |
+
for (IN``_gen_var = 0; IN``_gen_var < BITS; \
|
| 23 |
+
IN``_gen_var = IN``_gen_var + 1) begin: IN``_buf_gen \
|
| 24 |
+
IOBUF IN``_buf ( \
|
| 25 |
+
.IO(IN[IN``_gen_var]), \
|
| 26 |
+
.O(OUT``_i[IN``_gen_var]), \
|
| 27 |
+
.I(OUT``_o[IN``_gen_var]), \
|
| 28 |
+
.T(OUT``_t[IN``_gen_var]) \
|
| 29 |
+
); \
|
| 30 |
+
end \
|
| 31 |
+
endgenerate
|
| 32 |
+
|
| 33 |
+
`define IOBUF_GEN_VEC_SIMPLE(BITS, IN) `IOBUF_GEN_VEC(BITS, IN, IN)
|
| 34 |
+
|
| 35 |
+
`endif // FUXISOC_IOBUF_V_
|
MaxXSoft_Fuxi/src/test/resources/fib.txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00a00413
|
| 2 |
+
00100513
|
| 3 |
+
00100593
|
| 4 |
+
00000613
|
| 5 |
+
00000693
|
| 6 |
+
0086de63
|
| 7 |
+
00b502b3
|
| 8 |
+
00058613
|
| 9 |
+
00050593
|
| 10 |
+
00028513
|
| 11 |
+
00168693
|
| 12 |
+
fe9ff06f
|
| 13 |
+
deadc537
|
| 14 |
+
0de50513
|
| 15 |
+
ff9ff06f
|
MaxXSoft_Fuxi/src/test/resources/fib_trace.txt
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00000200 08 0000000a
|
| 2 |
+
00000204 10 00000001
|
| 3 |
+
00000208 11 00000001
|
| 4 |
+
0000020c 12 00000000
|
| 5 |
+
00000210 13 00000000
|
| 6 |
+
00000218 05 00000002
|
| 7 |
+
0000021c 12 00000001
|
| 8 |
+
00000220 11 00000001
|
| 9 |
+
00000224 10 00000002
|
| 10 |
+
00000228 13 00000001
|
| 11 |
+
00000218 05 00000003
|
| 12 |
+
0000021c 12 00000001
|
| 13 |
+
00000220 11 00000002
|
| 14 |
+
00000224 10 00000003
|
| 15 |
+
00000228 13 00000002
|
| 16 |
+
00000218 05 00000005
|
| 17 |
+
0000021c 12 00000002
|
| 18 |
+
00000220 11 00000003
|
| 19 |
+
00000224 10 00000005
|
| 20 |
+
00000228 13 00000003
|
| 21 |
+
00000218 05 00000008
|
| 22 |
+
0000021c 12 00000003
|
| 23 |
+
00000220 11 00000005
|
| 24 |
+
00000224 10 00000008
|
| 25 |
+
00000228 13 00000004
|
| 26 |
+
00000218 05 0000000d
|
| 27 |
+
0000021c 12 00000005
|
| 28 |
+
00000220 11 00000008
|
| 29 |
+
00000224 10 0000000d
|
| 30 |
+
00000228 13 00000005
|
| 31 |
+
00000218 05 00000015
|
| 32 |
+
0000021c 12 00000008
|
| 33 |
+
00000220 11 0000000d
|
| 34 |
+
00000224 10 00000015
|
| 35 |
+
00000228 13 00000006
|
| 36 |
+
00000218 05 00000022
|
| 37 |
+
0000021c 12 0000000d
|
| 38 |
+
00000220 11 00000015
|
| 39 |
+
00000224 10 00000022
|
| 40 |
+
00000228 13 00000007
|
| 41 |
+
00000218 05 00000037
|
| 42 |
+
0000021c 12 00000015
|
| 43 |
+
00000220 11 00000022
|
| 44 |
+
00000224 10 00000037
|
| 45 |
+
00000228 13 00000008
|
| 46 |
+
00000218 05 00000059
|
| 47 |
+
0000021c 12 00000022
|
| 48 |
+
00000220 11 00000037
|
| 49 |
+
00000224 10 00000059
|
| 50 |
+
00000228 13 00000009
|
| 51 |
+
00000218 05 00000090
|
| 52 |
+
0000021c 12 00000037
|
| 53 |
+
00000220 11 00000059
|
| 54 |
+
00000224 10 00000090
|
| 55 |
+
00000228 13 0000000a
|
| 56 |
+
00000230 10 deadc000
|
| 57 |
+
00000234 10 deadc0de
|
MaxXSoft_Fuxi/src/test/resources/mdu.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
000032b7
|
| 2 |
+
03928293
|
| 3 |
+
00002337
|
| 4 |
+
a8530313
|
| 5 |
+
026283b3
|
| 6 |
+
027303b3
|
| 7 |
+
027303b3
|
| 8 |
+
0262c3b3
|
| 9 |
+
0262e3b3
|
| 10 |
+
0040006f
|
| 11 |
+
deadc537
|
| 12 |
+
0de50513
|
| 13 |
+
ff9ff06f
|
MaxXSoft_Fuxi/src/test/resources/mdu_trace.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00000200 05 00003000
|
| 2 |
+
00000204 05 00003039
|
| 3 |
+
00000208 06 00002000
|
| 4 |
+
0000020c 06 00001a85
|
| 5 |
+
00000210 07 04fed79d
|
| 6 |
+
00000214 07 7a4bf691
|
| 7 |
+
00000218 07 4081d355
|
| 8 |
+
0000021c 07 00000001
|
| 9 |
+
00000220 07 000015b4
|
| 10 |
+
00000228 10 deadc000
|
| 11 |
+
0000022c 10 deadc0de
|
MaxXSoft_Fuxi/src/test/resources/mecall.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00000297
|
| 2 |
+
02428293
|
| 3 |
+
30529073
|
| 4 |
+
00000073
|
| 5 |
+
abcdf537
|
| 6 |
+
f0050513
|
| 7 |
+
deadc537
|
| 8 |
+
0de50513
|
| 9 |
+
ff9ff06f
|
| 10 |
+
341022f3
|
| 11 |
+
00428293
|
| 12 |
+
34129073
|
| 13 |
+
30200073
|
MaxXSoft_Fuxi/src/test/resources/mecall_trace.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00000200 05 00000200
|
| 2 |
+
00000204 05 00000224
|
| 3 |
+
00000224 05 0000020c
|
| 4 |
+
00000228 05 00000210
|
| 5 |
+
00000210 10 abcdf000
|
| 6 |
+
00000214 10 abcdef00
|
| 7 |
+
00000218 10 deadc000
|
| 8 |
+
0000021c 10 deadc0de
|
MaxXSoft_Fuxi/src/test/resources/secall.txt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00000297
|
| 2 |
+
03428293
|
| 3 |
+
34129073
|
| 4 |
+
000102b7
|
| 5 |
+
fff28293
|
| 6 |
+
30229073
|
| 7 |
+
000012b7
|
| 8 |
+
80028293
|
| 9 |
+
3002a073
|
| 10 |
+
30200073
|
| 11 |
+
deadc537
|
| 12 |
+
0de50513
|
| 13 |
+
ff9ff06f
|
| 14 |
+
00000297
|
| 15 |
+
01c28293
|
| 16 |
+
10529073
|
| 17 |
+
00000073
|
| 18 |
+
abcdf537
|
| 19 |
+
f0050513
|
| 20 |
+
fddff06f
|
| 21 |
+
141022f3
|
| 22 |
+
00428293
|
| 23 |
+
14129073
|
| 24 |
+
10200073
|
MaxXSoft_Fuxi/src/test/resources/secall_trace.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
00000200 05 00000200
|
| 2 |
+
00000204 05 00000234
|
| 3 |
+
0000020c 05 00010000
|
| 4 |
+
00000210 05 0000ffff
|
| 5 |
+
00000218 05 00001000
|
| 6 |
+
0000021c 05 00000800
|
| 7 |
+
00000234 05 00000234
|
| 8 |
+
00000238 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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// a Verilog wrapper module of Fuxi
|
| 2 |
+
module FuxiWrapper(
|
| 3 |
+
input clk,
|
| 4 |
+
input rst,
|
| 5 |
+
// interrupt requests
|
| 6 |
+
input irq_timer,
|
| 7 |
+
input irq_soft,
|
| 8 |
+
input irq_extern,
|
| 9 |
+
// debug signals
|
| 10 |
+
output debug_wen,
|
| 11 |
+
output [4:0] debug_waddr,
|
| 12 |
+
output [31:0] debug_wdata,
|
| 13 |
+
output [31:0] debug_pc,
|
| 14 |
+
// instruction AXI4 interface
|
| 15 |
+
input inst_arready,
|
| 16 |
+
output inst_arvalid,
|
| 17 |
+
output [31:0] inst_araddr,
|
| 18 |
+
output [3:0] inst_arid,
|
| 19 |
+
output [2:0] inst_arsize,
|
| 20 |
+
output [7:0] inst_arlen,
|
| 21 |
+
output [1:0] inst_arburst,
|
| 22 |
+
output inst_arlock,
|
| 23 |
+
output [3:0] inst_arcache,
|
| 24 |
+
output [2:0] inst_arprot,
|
| 25 |
+
output inst_rready,
|
| 26 |
+
input inst_rvalid,
|
| 27 |
+
input [31:0] inst_rdata,
|
| 28 |
+
input [3:0] inst_rid,
|
| 29 |
+
input inst_rlast,
|
| 30 |
+
input [1:0] inst_rresp,
|
| 31 |
+
input inst_awready,
|
| 32 |
+
output inst_awvalid,
|
| 33 |
+
output [31:0] inst_awaddr,
|
| 34 |
+
output [3:0] inst_awid,
|
| 35 |
+
output [2:0] inst_awsize,
|
| 36 |
+
output [7:0] inst_awlen,
|
| 37 |
+
output [1:0] inst_awburst,
|
| 38 |
+
output inst_awlock,
|
| 39 |
+
output [3:0] inst_awcache,
|
| 40 |
+
output [2:0] inst_awprot,
|
| 41 |
+
input inst_wready,
|
| 42 |
+
output inst_wvalid,
|
| 43 |
+
output [31:0] inst_wdata,
|
| 44 |
+
output [3:0] inst_wid,
|
| 45 |
+
output inst_wlast,
|
| 46 |
+
output [3:0] inst_wstrb,
|
| 47 |
+
output inst_bready,
|
| 48 |
+
input inst_bvalid,
|
| 49 |
+
input [3:0] inst_bid,
|
| 50 |
+
input [1:0] inst_bresp,
|
| 51 |
+
// data AXI4 interface
|
| 52 |
+
input data_arready,
|
| 53 |
+
output data_arvalid,
|
| 54 |
+
output [31:0] data_araddr,
|
| 55 |
+
output [3:0] data_arid,
|
| 56 |
+
output [2:0] data_arsize,
|
| 57 |
+
output [7:0] data_arlen,
|
| 58 |
+
output [1:0] data_arburst,
|
| 59 |
+
output data_arlock,
|
| 60 |
+
output [3:0] data_arcache,
|
| 61 |
+
output [2:0] data_arprot,
|
| 62 |
+
output data_rready,
|
| 63 |
+
input data_rvalid,
|
| 64 |
+
input [31:0] data_rdata,
|
| 65 |
+
input [3:0] data_rid,
|
| 66 |
+
input data_rlast,
|
| 67 |
+
input [1:0] data_rresp,
|
| 68 |
+
input data_awready,
|
| 69 |
+
output data_awvalid,
|
| 70 |
+
output [31:0] data_awaddr,
|
| 71 |
+
output [3:0] data_awid,
|
| 72 |
+
output [2:0] data_awsize,
|
| 73 |
+
output [7:0] data_awlen,
|
| 74 |
+
output [1:0] data_awburst,
|
| 75 |
+
output data_awlock,
|
| 76 |
+
output [3:0] data_awcache,
|
| 77 |
+
output [2:0] data_awprot,
|
| 78 |
+
input data_wready,
|
| 79 |
+
output data_wvalid,
|
| 80 |
+
output [31:0] data_wdata,
|
| 81 |
+
output [3:0] data_wid,
|
| 82 |
+
output data_wlast,
|
| 83 |
+
output [3:0] data_wstrb,
|
| 84 |
+
output data_bready,
|
| 85 |
+
input data_bvalid,
|
| 86 |
+
input [3:0] data_bid,
|
| 87 |
+
input [1:0] data_bresp,
|
| 88 |
+
// uncached AXI4 interface
|
| 89 |
+
input uncached_arready,
|
| 90 |
+
output uncached_arvalid,
|
| 91 |
+
output [31:0] uncached_araddr,
|
| 92 |
+
output [3:0] uncached_arid,
|
| 93 |
+
output [2:0] uncached_arsize,
|
| 94 |
+
output [7:0] uncached_arlen,
|
| 95 |
+
output [1:0] uncached_arburst,
|
| 96 |
+
output uncached_arlock,
|
| 97 |
+
output [3:0] uncached_arcache,
|
| 98 |
+
output [2:0] uncached_arprot,
|
| 99 |
+
output uncached_rready,
|
| 100 |
+
input uncached_rvalid,
|
| 101 |
+
input [31:0] uncached_rdata,
|
| 102 |
+
input [3:0] uncached_rid,
|
| 103 |
+
input uncached_rlast,
|
| 104 |
+
input [1:0] uncached_rresp,
|
| 105 |
+
input uncached_awready,
|
| 106 |
+
output uncached_awvalid,
|
| 107 |
+
output [31:0] uncached_awaddr,
|
| 108 |
+
output [3:0] uncached_awid,
|
| 109 |
+
output [2:0] uncached_awsize,
|
| 110 |
+
output [7:0] uncached_awlen,
|
| 111 |
+
output [1:0] uncached_awburst,
|
| 112 |
+
output uncached_awlock,
|
| 113 |
+
output [3:0] uncached_awcache,
|
| 114 |
+
output [2:0] uncached_awprot,
|
| 115 |
+
input uncached_wready,
|
| 116 |
+
output uncached_wvalid,
|
| 117 |
+
output [31:0] uncached_wdata,
|
| 118 |
+
output [3:0] uncached_wid,
|
| 119 |
+
output uncached_wlast,
|
| 120 |
+
output [3:0] uncached_wstrb,
|
| 121 |
+
output uncached_bready,
|
| 122 |
+
input uncached_bvalid,
|
| 123 |
+
input [3:0] uncached_bid,
|
| 124 |
+
input [1:0] uncached_bresp
|
| 125 |
+
);
|
| 126 |
+
|
| 127 |
+
Fuxi fuxi(
|
| 128 |
+
.clock (clk),
|
| 129 |
+
.reset (rst),
|
| 130 |
+
// interrupt requests
|
| 131 |
+
.io_irq_timer (irq_timer),
|
| 132 |
+
.io_irq_soft (irq_soft),
|
| 133 |
+
.io_irq_extern (irq_extern),
|
| 134 |
+
// debug signals
|
| 135 |
+
.io_debug_regWen (debug_wen),
|
| 136 |
+
.io_debug_regWaddr (debug_waddr),
|
| 137 |
+
.io_debug_regWdata (debug_wdata),
|
| 138 |
+
.io_debug_pc (debug_pc),
|
| 139 |
+
// instruction AXI4 interface
|
| 140 |
+
.io_inst_readAddr_ready (inst_arready),
|
| 141 |
+
.io_inst_readAddr_valid (inst_arvalid),
|
| 142 |
+
.io_inst_readAddr_bits_addr (inst_araddr),
|
| 143 |
+
.io_inst_readAddr_bits_id (inst_arid),
|
| 144 |
+
.io_inst_readAddr_bits_size (inst_arsize),
|
| 145 |
+
.io_inst_readAddr_bits_len (inst_arlen),
|
| 146 |
+
.io_inst_readAddr_bits_burst (inst_arburst),
|
| 147 |
+
.io_inst_readAddr_bits_lock (inst_arlock),
|
| 148 |
+
.io_inst_readAddr_bits_cache (inst_arcache),
|
| 149 |
+
.io_inst_readAddr_bits_prot (inst_arprot),
|
| 150 |
+
.io_inst_readData_ready (inst_rready),
|
| 151 |
+
.io_inst_readData_valid (inst_rvalid),
|
| 152 |
+
.io_inst_readData_bits_data (inst_rdata),
|
| 153 |
+
.io_inst_readData_bits_id (inst_rid),
|
| 154 |
+
.io_inst_readData_bits_last (inst_rlast),
|
| 155 |
+
.io_inst_readData_bits_resp (inst_rresp),
|
| 156 |
+
.io_inst_writeAddr_ready (inst_awready),
|
| 157 |
+
.io_inst_writeAddr_valid (inst_awvalid),
|
| 158 |
+
.io_inst_writeAddr_bits_addr (inst_awaddr),
|
| 159 |
+
.io_inst_writeAddr_bits_id (inst_awid),
|
| 160 |
+
.io_inst_writeAddr_bits_size (inst_awsize),
|
| 161 |
+
.io_inst_writeAddr_bits_len (inst_awlen),
|
| 162 |
+
.io_inst_writeAddr_bits_burst (inst_awburst),
|
| 163 |
+
.io_inst_writeAddr_bits_lock (inst_awlock),
|
| 164 |
+
.io_inst_writeAddr_bits_cache (inst_awcache),
|
| 165 |
+
.io_inst_writeAddr_bits_prot (inst_awprot),
|
| 166 |
+
.io_inst_writeData_ready (inst_wready),
|
| 167 |
+
.io_inst_writeData_valid (inst_wvalid),
|
| 168 |
+
.io_inst_writeData_bits_data (inst_wdata),
|
| 169 |
+
.io_inst_writeData_bits_id (inst_wid),
|
| 170 |
+
.io_inst_writeData_bits_last (inst_wlast),
|
| 171 |
+
.io_inst_writeData_bits_strb (inst_wstrb),
|
| 172 |
+
.io_inst_writeResp_ready (inst_bready),
|
| 173 |
+
.io_inst_writeResp_valid (inst_bvalid),
|
| 174 |
+
.io_inst_writeResp_bits_id (inst_bid),
|
| 175 |
+
.io_inst_writeResp_bits_resp (inst_bresp),
|
| 176 |
+
// data AXI4 interface
|
| 177 |
+
.io_data_readAddr_ready (data_arready),
|
| 178 |
+
.io_data_readAddr_valid (data_arvalid),
|
| 179 |
+
.io_data_readAddr_bits_addr (data_araddr),
|
| 180 |
+
.io_data_readAddr_bits_id (data_arid),
|
| 181 |
+
.io_data_readAddr_bits_size (data_arsize),
|
| 182 |
+
.io_data_readAddr_bits_len (data_arlen),
|
| 183 |
+
.io_data_readAddr_bits_burst (data_arburst),
|
| 184 |
+
.io_data_readAddr_bits_lock (data_arlock),
|
| 185 |
+
.io_data_readAddr_bits_cache (data_arcache),
|
| 186 |
+
.io_data_readAddr_bits_prot (data_arprot),
|
| 187 |
+
.io_data_readData_ready (data_rready),
|
| 188 |
+
.io_data_readData_valid (data_rvalid),
|
| 189 |
+
.io_data_readData_bits_data (data_rdata),
|
| 190 |
+
.io_data_readData_bits_id (data_rid),
|
| 191 |
+
.io_data_readData_bits_last (data_rlast),
|
| 192 |
+
.io_data_readData_bits_resp (data_rresp),
|
| 193 |
+
.io_data_writeAddr_ready (data_awready),
|
| 194 |
+
.io_data_writeAddr_valid (data_awvalid),
|
| 195 |
+
.io_data_writeAddr_bits_addr (data_awaddr),
|
| 196 |
+
.io_data_writeAddr_bits_id (data_awid),
|
| 197 |
+
.io_data_writeAddr_bits_size (data_awsize),
|
| 198 |
+
.io_data_writeAddr_bits_len (data_awlen),
|
| 199 |
+
.io_data_writeAddr_bits_burst (data_awburst),
|
| 200 |
+
.io_data_writeAddr_bits_lock (data_awlock),
|
| 201 |
+
.io_data_writeAddr_bits_cache (data_awcache),
|
| 202 |
+
.io_data_writeAddr_bits_prot (data_awprot),
|
| 203 |
+
.io_data_writeData_ready (data_wready),
|
| 204 |
+
.io_data_writeData_valid (data_wvalid),
|
| 205 |
+
.io_data_writeData_bits_data (data_wdata),
|
| 206 |
+
.io_data_writeData_bits_id (data_wid),
|
| 207 |
+
.io_data_writeData_bits_last (data_wlast),
|
| 208 |
+
.io_data_writeData_bits_strb (data_wstrb),
|
| 209 |
+
.io_data_writeResp_ready (data_bready),
|
| 210 |
+
.io_data_writeResp_valid (data_bvalid),
|
| 211 |
+
.io_data_writeResp_bits_id (data_bid),
|
| 212 |
+
.io_data_writeResp_bits_resp (data_bresp),
|
| 213 |
+
// uncached AXI4 interface
|
| 214 |
+
.io_uncached_readAddr_ready (uncached_arready),
|
| 215 |
+
.io_uncached_readAddr_valid (uncached_arvalid),
|
| 216 |
+
.io_uncached_readAddr_bits_addr (uncached_araddr),
|
| 217 |
+
.io_uncached_readAddr_bits_id (uncached_arid),
|
| 218 |
+
.io_uncached_readAddr_bits_size (uncached_arsize),
|
| 219 |
+
.io_uncached_readAddr_bits_len (uncached_arlen),
|
| 220 |
+
.io_uncached_readAddr_bits_burst (uncached_arburst),
|
| 221 |
+
.io_uncached_readAddr_bits_lock (uncached_arlock),
|
| 222 |
+
.io_uncached_readAddr_bits_cache (uncached_arcache),
|
| 223 |
+
.io_uncached_readAddr_bits_prot (uncached_arprot),
|
| 224 |
+
.io_uncached_readData_ready (uncached_rready),
|
| 225 |
+
.io_uncached_readData_valid (uncached_rvalid),
|
| 226 |
+
.io_uncached_readData_bits_data (uncached_rdata),
|
| 227 |
+
.io_uncached_readData_bits_id (uncached_rid),
|
| 228 |
+
.io_uncached_readData_bits_last (uncached_rlast),
|
| 229 |
+
.io_uncached_readData_bits_resp (uncached_rresp),
|
| 230 |
+
.io_uncached_writeAddr_ready (uncached_awready),
|
| 231 |
+
.io_uncached_writeAddr_valid (uncached_awvalid),
|
| 232 |
+
.io_uncached_writeAddr_bits_addr (uncached_awaddr),
|
| 233 |
+
.io_uncached_writeAddr_bits_id (uncached_awid),
|
| 234 |
+
.io_uncached_writeAddr_bits_size (uncached_awsize),
|
| 235 |
+
.io_uncached_writeAddr_bits_len (uncached_awlen),
|
| 236 |
+
.io_uncached_writeAddr_bits_burst (uncached_awburst),
|
| 237 |
+
.io_uncached_writeAddr_bits_lock (uncached_awlock),
|
| 238 |
+
.io_uncached_writeAddr_bits_cache (uncached_awcache),
|
| 239 |
+
.io_uncached_writeAddr_bits_prot (uncached_awprot),
|
| 240 |
+
.io_uncached_writeData_ready (uncached_wready),
|
| 241 |
+
.io_uncached_writeData_valid (uncached_wvalid),
|
| 242 |
+
.io_uncached_writeData_bits_data (uncached_wdata),
|
| 243 |
+
.io_uncached_writeData_bits_id (uncached_wid),
|
| 244 |
+
.io_uncached_writeData_bits_last (uncached_wlast),
|
| 245 |
+
.io_uncached_writeData_bits_strb (uncached_wstrb),
|
| 246 |
+
.io_uncached_writeResp_ready (uncached_bready),
|
| 247 |
+
.io_uncached_writeResp_valid (uncached_bvalid),
|
| 248 |
+
.io_uncached_writeResp_bits_id (uncached_bid),
|
| 249 |
+
.io_uncached_writeResp_bits_resp (uncached_bresp)
|
| 250 |
+
);
|
| 251 |
+
|
| 252 |
+
endmodule
|