Compare commits

...

1105 commits

Author SHA1 Message Date
Dolu1990
229fecd4a1
Merge pull request #444 from jdavidberger/bugfix/tdata2_rw
Some checks failed
Scala CI / build (push) Has been cancelled
Make TDATA2 RW. Openocd requires this for hw breakpoints
2025-02-14 09:46:50 +01:00
Justin Berger
c559c6d0f9 Make TDATA2 RW. Openocd requires this for hw breakpoints 2025-02-13 22:22:04 -07:00
Dolu1990
9b40a05837
update verilator git
Some checks failed
Scala CI / build (push) Has been cancelled
2025-02-06 09:54:56 +01:00
Dolu1990
19ea858e84
Merge pull request #442 from jdavidberger/add_wb_granularity
Some checks are pending
Scala CI / build (push) Waiting to run
Add address granularity for wishbone
2025-02-06 09:14:08 +01:00
Justin Berger
f3409b240f Add address granularity for wishbone 2025-02-01 10:43:26 -07:00
Dolu1990
35402a2bde Update README.md
Some checks failed
Scala CI / build (push) Has been cancelled
2025-01-24 10:39:25 +01:00
Dolu1990
7f2bccbef2
Merge pull request #434 from goekce/master
Some checks failed
Scala CI / build (push) Has been cancelled
add Murax config with native jtag based on the docs
2024-11-15 11:47:51 +01:00
goekce
41ea95f805 add argument for simulation frequency 2024-11-14 18:12:11 +01:00
goekce
bd39421664 fix indent 2024-11-13 14:25:54 +01:00
goekce
110b2a1e00 make JtagNative signal visible in generated code 2024-11-13 14:22:22 +01:00
goekce
e0f4bacaf4 add Murax config with native jtag 2024-11-13 11:31:17 +01:00
Dolu1990
4cf81af23b
Merge pull request #433 from 7FM/master
Some checks failed
Scala CI / build (push) Has been cancelled
Fix undriven signal
2024-11-11 17:54:46 +01:00
7FM
4b3af464dc
Fix undriven signal 2024-11-11 15:27:27 +01:00
Dolu1990
35cf16ea56
Merge pull request #432 from goekce/master
Some checks failed
Scala CI / build (push) Has been cancelled
Verilator requires at least c++14
2024-10-21 17:25:33 +02:00
goekce
67b2e94f82 Verilator requires at least c++14 2024-10-21 17:14:25 +02:00
Dolu1990
bd9e062abe Fix #429 sifive toolchain link 2024-09-23 08:44:43 +02:00
Dolu1990
83606a9eb0 Fix CsrPlugin FPU access 2024-09-20 15:40:50 +02:00
Dolu1990
8c1e69b872 Fix #430 2024-09-20 11:41:08 +02:00
Dolu1990
fd2d784298
Merge pull request #427 from kivikakk/dbus-wishbone-read-size
DBusSimplePlugin: don't force SEL to 1111 on read.
2024-09-06 11:00:10 +02:00
Asherah Connor
545b8c3770 DBusSimplePlugin: don't force SEL to 1111 on read. 2024-09-04 19:59:39 +03:00
Dolu1990
0af9894e69
Merge pull request #425 from dnltz/WIP/dnltz/bump-scala-and-spinalhdl
build.sbt: Bump SpinalHDL and Scala version
2024-09-02 08:54:12 +02:00
Daniel Schultz
638cd8878d build.sbt: Bump SpinalHDL and Scala version
Bump SpinalHDL to 1.10.2a and Scala to 2.12.

Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
2024-09-02 08:06:18 +02:00
Dolu1990
919f00125d
Merge pull request #423 from craigjb/riscv-jtag-bscane2
Tunneled EmbeddedRiscvJtag without TAP
2024-08-27 09:59:24 +02:00
Craig Bishop
52a2e889d0 Document using EmbeddedRiscvJtag with BSCANE2 2024-08-26 17:46:06 -07:00
Craig Bishop
bd7c4c3281 Add JTAG tunnel without TAP in EmbeddedRiscvJtag 2024-08-26 17:21:42 -07:00
Dolu1990
2073047272
Merge pull request #413 from mrcmry/fix-case-sensitive-MHz
Fix Mhz -> MHz in README, comments and Dhrystone benchmark output
2024-06-21 11:17:14 +02:00
Marc Emery
8968b5a3fa Fix Mhz -> MHz in Dhrystone benchmark report generation 2024-06-17 22:00:19 +02:00
Marc Emery
7beb9887a6 Fix Mhz -> MHz in readme and comments 2024-06-17 21:46:29 +02:00
Dolu1990
8c191a2824 Fix #412 tightly coupled HAS_SIDE_EFFECT fix 2024-06-17 10:05:05 +02:00
Dolu1990
3ee790d25c
Merge pull request #410 from MrJake222/fix-expose-mask
Exposed write mask on default iBus
2024-06-05 15:44:25 +02:00
MrJake222
1175f195df Exposed write mask on default iBus 2024-06-04 23:11:31 +02:00
Dolu1990
457ae5c7e5
Merge pull request #399 from martijnbastiaan/wishbone-err
Handle `ERR` in `toWishbone`
2024-03-29 12:40:17 +01:00
Martijn Bastiaan
5f58e0c7c6 Handle ERR in toWishbone 2024-03-27 20:09:32 +01:00
Dolu1990
6aeb6d4d43
Merge pull request #397 from cherrypiejam/fix-smp-supervisor
Fix SMP compile-time error when disabling supervisor option
2024-03-10 08:52:52 +01:00
Gongqi Huang
26d6f61d49 Fix SMP compile-time error when disabling supervisor
When generating SMP configuration with supervisor disable, the
compiler stucks at waiting for the signal from
`externalSupervisorInterrupt`, which is generated conditionally
based on `withSupervisor` option.
2024-03-09 20:49:37 -05:00
Dolu1990
e52251d88c main.cpp more wno 2024-03-08 12:50:39 +01:00
Dolu1990
25d13df1b4 Fix main.cpp syntax 2024-03-08 12:45:08 +01:00
Dolu1990
55d6b2f597
Merge pull request #394 from PythonLinks/master
Improved the paragraph about available configurations.
2024-03-06 11:31:54 +01:00
PythonLinks
30871d3381
Improved the paragraph about available configurations. 2024-03-05 09:57:41 +01:00
Dolu1990
fe5e6dd95b SpinalHDL 1.10.1 2024-02-01 10:34:37 +01:00
Dolu1990
0effdecbe6 SpinalHDL 1.10.0 2024-01-04 10:11:22 +01:00
Dolu1990
35e5f4cad8
Merge pull request #386 from davine47/add-mill
Add mill to compile and test VexRiscv
2023-12-21 20:13:41 +01:00
Jack Davine
62577a7a11 Add mill to compile and test VexRiscv 2023-12-22 00:36:26 +08:00
Dolu1990
7c6c7a6fe5 implement #373 IBusDBusCachedTightlyCoupledRam hexInit ramOffset args 2023-11-25 14:17:05 +01:00
Dolu1990
b6118e5cc2
Merge pull request #378 from lschuermann/pmp-napot-rename
Rename `PmpPlugin -> PmpPluginNapot`, `PmpPluginOld -> PmpPlugin`
2023-11-14 12:40:29 +01:00
Dolu1990
940fb507a5 fix #376 Uncached dbus ahb, add option to ensure no combinatorial loop 2023-11-14 11:36:05 +01:00
Leon Schuermann
17915162f3 TestIndividualFeatures: test both PmpPlugin and PmpPluginNapot 2023-11-13 13:57:00 -05:00
Leon Schuermann
cdd8454349 Rename PmpPlugin -> PmpPluginNapot, PmpPluginOld -> PmpPlugin 2023-11-13 13:56:13 -05:00
Dolu1990
1849aa4419
Merge pull request #377 from Tectu/feature/fix-jtag
Fix ambiguous function call to bind()
2023-11-13 09:02:50 +01:00
Joel Bodenmann
ec31ed30cf Fix ambiguous function call to bind()
The call to bind() can actually resolve to std::bind() instead of
libc's bind(). Ensure that we're definitely calling the correct one.
2023-11-13 02:59:29 +01:00
Dolu1990
79e2ae248b
Merge pull request #374 from lschuermann/d/pmpold-addr-overflow
PmpPluginOld: fix NAPOT address calculation overflow issue
2023-11-08 15:15:05 +01:00
Dolu1990
53f79b1879
Merge pull request #375 from ekliptik/readme-verilator
Add note about Verilator without GDB+OpenOCD
2023-11-03 14:42:39 +01:00
Emil Tywoniak
00534dc4a8 Add note about Verilator without GDB+OpenOCD 2023-11-03 14:16:05 +01:00
Leon Schuermann
9baba6d11f PmpPluginOld: fix NAPOT address calculation overflow issue
Because pmpaddrX registers are defined to encode the address'
[XLEN + 2 downto 2] bits, the length of a NAPOT region is defined
through the most significant 0 bit in a pmpaddrX register (which in
the case of ~0 is the 33rd non-existant "virtual" bit), and the
VexRiscv PmpOld plugin represents the addresses covered by a region as
[start; end) (bounded inclusively below and exclusively above), the
start and end address registers need to be XLEN + 4 bit wide to avoid
overflows.

If such an overflow occurs, it may be that the region does not cover
any address, an issue uncovered in the Tock LiteX + VexRiscv CI during
a PMP infrastructure redesign in the Tock OS [1].

This commit has been tested on Tock's redesigned PMP infrastructure,
and by inspecting all of the intermediate signals in the PMP address
calculation through a Verilator trace file. It works correctly for
various NAPOT and TOR addresses, and I made sure that the edge cases
of pmpaddrX = [0x00000000, 0x7FFFFFFF, 0xFFFFFFFF] are all handled.

[1]: https://github.com/tock/tock/pull/3597
2023-11-03 09:11:42 -04:00
Dolu1990
b6f6120ec6 Merge branch 'dev' 2023-11-03 11:44:16 +01:00
Dolu1990
e71b1be8a2 demo fix 2023-11-03 11:43:59 +01:00
Dolu1990
f1d64eccc8 Fix demo 2023-11-03 11:41:16 +01:00
Dolu1990
63f1025a15 Fix demo 2023-11-03 11:41:02 +01:00
Dolu1990
4220602ba5 Merge branch 'dev' 2023-11-03 10:46:59 +01:00
Dolu1990
e6998d1cb3 Add GenFullWithOfficialRiscvDebug 2023-11-03 10:46:49 +01:00
Dolu1990
11cc9b1cf2 Add GenFullWithTcmIntegrated example 2023-11-02 12:32:19 +01:00
Dolu1990
beeec94344 Add GenFullWithTcmIntegrated example 2023-11-02 12:31:05 +01:00
Dolu1990
05df181257 Merge branch 'dev' 2023-11-02 11:59:51 +01:00
Dolu1990
0f17b395bd IBusDBusCachedTightlyCoupledRam add missing write mask 2023-11-02 11:59:33 +01:00
Dolu1990
07b0d7788b SpinalHDL 1.9.4 2023-11-01 09:42:59 +01:00
Dolu1990
a2a60bf6bc #373 Add GenFullWithTcm demo 2023-10-31 11:39:10 +01:00
Dolu1990
281818af9c #373 Add GenFullWithTcm demo 2023-10-31 11:05:00 +01:00
Dolu1990
4e051ed2a3
Merge pull request #366 from robindust-ce/master
Add missing parameter jtagHeaderIgnoreWidth
2023-09-26 17:39:49 +02:00
StaubRobin
960f8682ea Add missing parameter jtagHeaderIgnoreWidth 2023-09-25 22:15:50 +02:00
Dolu1990
e21dc6cda5 litex add hardwarebreapoint parameter 2023-09-20 09:08:33 +02:00
Dolu1990
acf6ad3bfd Add doc about official RISC-V debug support 2023-09-13 14:56:07 +02:00
Dolu1990
213e4b863a litex add -expose-time 2023-09-12 10:40:45 +02:00
Dolu1990
220a2733be litex privileged debug stop time now connect to clint 2023-09-08 16:47:54 +02:00
Dolu1990
ff922ec601 Merge branch 'litex-privileged-debug' into dev 2023-09-08 16:26:38 +02:00
Dolu1990
9fd127d6d9 fix naming 2023-09-08 16:26:23 +02:00
Dolu1990
73733dd8b1 litex privileged debug 2023-09-08 16:00:59 +02:00
Dolu1990
3739b9ac88 plic update 2023-08-29 08:58:48 +02:00
Dolu1990
5ef1bc775f SpinalHDL 1.9.3 2023-08-16 09:59:21 +02:00
Dolu1990
badf13be02 SpinalHDL 1.9.2 2023-08-10 09:02:15 +02:00
Dolu1990
1721ac253e SpinalHDL 1.9.0
Merge branch 'dev'
2023-07-21 17:45:18 +02:00
Charles Papon
fd0f23abb6 Merge branch master into dev 2023-07-11 04:19:06 +08:00
Charles Papon
1746af1cfe Fix #352 GenCustomInterrupt demo 2023-07-11 04:16:21 +08:00
Dolu1990
5860dc2321
Update DBusSimplePlugin.scala 2023-06-16 10:07:24 +01:00
Dolu1990
d95c9356fa
Merge pull request #350 from AdDraw/master
Add cmd halfPipe function to DBusSimpleBus
2023-06-16 07:47:40 +01:00
Dolu1990
7f647f9d8d
Update DBusSimplePlugin.scala 2023-06-16 08:47:18 +02:00
AdDraw
050b4d8c62 Add halfPipe function to DBusSimpleBus 2023-06-15 22:57:20 +02:00
Dolu1990
760a0fced5 Update SpinalHDL 2023-05-23 18:18:57 +02:00
Dolu1990
b81029f619 fix fpu underflow rounding (#343) 2023-05-16 16:50:38 +01:00
Dolu1990
ba6dcb1789 Add a few privSpec tests 2023-04-27 14:56:41 +02:00
Dolu1990
8fc5f35d29 DBusCachedPlugin now provide writesPending signal 2023-04-24 13:13:55 +02:00
Dolu1990
7649157946 d$ toBmb increase aggregation timer 2023-04-13 16:52:20 +02:00
Dolu1990
051080e060 CsrPlugin now implement dummy HPM 2023-04-13 16:51:44 +02:00
Dolu1990
d966c4efe1 fix #328 medeleg EBREAK added 2023-04-10 13:02:51 +02:00
Dolu1990
c52433575d
Merge pull request #327 from andreasWallner/remove_sbt_assembly
Remove sbt-assembly dependency
2023-04-08 07:14:48 +01:00
Andreas Wallner
d8f6f28020 Remove sbt-assembly dependency
The plugin is not used in the VexRiscV build and causes issues for users
since repo.scala-sbt.org seems to be down/sunset/?.

See also https://github.com/sbt/sbt/issues/7202

Updating the dependency would also have been an option, but since it's not
used removal is easier.
2023-04-07 18:59:20 +02:00
Dolu1990
320867e135 sync 2023-04-04 18:11:33 +02:00
Dolu1990
f3d7442e2d Merge remote-tracking branch 'origin/dev' 2023-04-04 11:50:11 +02:00
Dolu1990
95e61a7951 Revert CfuPlugin 2023-04-04 11:47:49 +02:00
Dolu1990
cb0bacfce9 implement dummy pmp as 1.10 spec says 2023-03-31 10:12:52 +02:00
Dolu1990
b4d5a315cf CsrPlugin implement dummy pmp if no pmp is there 2023-03-31 10:11:53 +02:00
Dolu1990
9c2e05cce0 Ensure that fence.i wait d$ inflight write and reschedule the next instruction 2023-03-29 14:56:53 +02:00
Dolu1990
e357420d11 CsrPluginConfig more var 2023-03-29 11:10:51 +02:00
Dolu1990
f0bb6e94e4 SpinalHDL 1.8.1 / Merge branch 'dev'
# Conflicts:
#	src/main/scala/vexriscv/plugin/CsrPlugin.scala
2023-03-27 10:02:14 +02:00
Dolu1990
a33380894c sync 2023-03-27 09:57:55 +02:00
Dolu1990
e754c5c3a0 cleanup IBusDBusCachedTightlyCoupledRam 2023-03-27 08:23:32 +02:00
Dolu1990
eeb65ed1c0 VexRiscvBmbGenrator now use relaxedReset 2023-03-24 08:39:07 +01:00
Dolu1990
c69852c0cc ClockDomainResetGeneratorIf introduction 2023-03-23 16:57:10 +01:00
Dolu1990
8195bec788 privSpec now check FPU dirty flag 2023-03-23 11:24:38 +01:00
Dolu1990
8c5071ce42 VexRiscvSmpCluster fullCsr improvement 2023-03-23 08:53:41 +01:00
Dolu1990
b01490b5f3 Implement counteren (1.10+ spec) 2023-03-23 08:53:10 +01:00
Dolu1990
570720fdd8 Cfu add enableInit option 2023-03-22 17:13:47 +01:00
Dolu1990
0e59a56bd1 add privSpec test 2023-03-22 16:25:23 +01:00
Dolu1990
bba022b746 fix a few csr related WARL (minor) 2023-03-22 16:25:03 +01:00
Dolu1990
385a195d16 few more var parameters 2023-03-22 12:58:43 +01:00
Dolu1990
a755d839b3 Add VexRiscvSmpClusterGen csrFull (wip) 2023-03-22 11:07:18 +01:00
Dolu1990
5b47564024 A few plugins config are now var 2023-03-22 11:06:56 +01:00
Dolu1990
4972a27ae9 More verbose main.cpp on failure, fix C.ADDSP regfile initialisation 2023-03-22 11:06:23 +01:00
Charles Papon
0aa8cb11e0 BranchPlugin do not use casez anymore 2023-03-15 17:43:44 +08:00
Charles Papon
13061b8b2e debug unavailable is now BufferCC 2023-03-15 09:50:09 +08:00
Charles Papon
876222d886 Fix FPU access port instanciation when not needed 2023-03-14 15:23:04 +08:00
Charles Papon
25eda80fee FpuTest document how to install berkley testfloat 2023-03-10 14:46:21 +08:00
Charles Papon
94f19032f0 FpuPlugin.access port added
Privileged debug access added
2023-03-10 14:44:14 +08:00
Charles Papon
6be1531d36 Fpu will not trap anymore on debug access if fs==0 2023-03-10 09:17:01 +08:00
Charles Papon
1179c6551f Fix #321 #322 #333 FPU precision removal 2023-03-08 16:00:22 +08:00
Charles Papon
f11c642cd6 CfuPlugin encoding can now specify cmd/rsp less instruction 2023-03-07 16:49:07 +08:00
Charles Papon
3cf8508db1 DBus coupled timings improvement 2023-03-05 20:31:40 +08:00
Charles Papon
153445ff21 Fix CFU / FPU decoder stage fork on illegal instruction 2023-03-05 20:29:53 +08:00
Dolu1990
cf70bc6b1f fix last push 2023-03-03 14:20:12 +01:00
Dolu1990
b03b00a5c4 Improve d$ coupled timings 2023-03-03 14:13:51 +01:00
Dolu1990
5493c55ab0 Alows Fetcher to have multiple debug injection ports 2023-03-03 09:06:20 +01:00
Dolu1990
5f67075e30 Fix FPU with F64 support, not removing mantissa precision from F32 #317 2023-03-01 13:56:25 +01:00
Dolu1990
b29eb542f2
Merge pull request #306 from lschuermann/dev/csr-plugin-formal-halt
CsrPlugin: insert FORMAL_HALT := False
2023-02-27 09:22:46 +01:00
Dolu1990
c655abbb1e
Merge pull request #304 from lschuermann/dev/fetcher-formal-mode
Fetcher: insert FORMAL_MODE encoded from privilegeService
2023-02-27 09:09:58 +01:00
Leon Schuermann
49246e757f CsrPlugin: insert FORMAL_HALT := False 2023-02-26 16:56:00 -05:00
Leon Schuermann
13d66b3ae4 Fetcher: insert FORMAL_MODE encoded from privilegeService
Previously, FORMAL_MODE would simply be hard-coded to "11", indicating
machine mode. However, that's not necessarily true when using the
CsrPlugin, which allows to switch the hart into either User or
optional Supervisor mode. Hence we create a FORMAL_MODE insert in the
fetch-phase (which is generally when the MPP register can take effect)
and generate `rvfi_mode` based on that insert.
2023-02-24 16:40:47 -05:00
Dolu1990
6f76a45e7d update mmu test 2023-02-23 15:54:39 +01:00
Dolu1990
d7e9c726c3 Fix datacache initial flush 2023-02-23 14:42:21 +01:00
Dolu1990
c5689e512c CsrPlugin now provide regression args 2023-02-23 12:00:25 +01:00
Dolu1990
a40d5f19b2 Fix MMU A and D flag handeling 2023-02-23 12:00:08 +01:00
Dolu1990
344b2d4eda TestIndividual supervisor missing CSR=yes 2023-02-23 11:59:13 +01:00
Dolu1990
9605b663bf D$ now support thightly coupled ram.
Add IBusDBusCachedTightlyCoupledRam plugin
2023-02-22 15:26:14 +01:00
Dolu1990
220b599c9a Fix d$ invalidation when the mmu is enabled 2023-02-22 13:16:02 +01:00
Dolu1990
366f09a14a fix too early 2023-02-19 09:51:54 +01:00
Dolu1990
15a665af53 fix too early 2023-02-19 09:51:18 +01:00
Dolu1990
c57da3c7dc fix too early 2023-02-19 09:50:41 +01:00
Dolu1990
d078297496 fix too early 2023-02-19 09:48:59 +01:00
Dolu1990
a780eec616 Merge branch 'debug-debug' into dev 2023-02-13 10:04:41 +01:00
Dolu1990
33e820bdf9 FPU now implement a less pessismitic dirty logic 2023-02-08 15:16:53 +01:00
Dolu1990
3ae51cdeb8 Fix fpu csr access on fs===0 now also trap 2023-02-08 14:44:04 +01:00
Dolu1990
692f604dd5 Fix VexRiscvSmpClusterGen without linux debug minimal features 2023-02-08 11:28:21 +01:00
Dolu1990
cbc89093b3 fpu csr access on fs===0 now also trap 2023-02-07 10:18:08 +01:00
Dolu1990
9acc5ddc1c Fix FPU access trap on fs = 0 #297 2023-02-06 11:44:44 +01:00
Dolu1990
fc9a9d25ed sync 2023-02-06 11:43:49 +01:00
Dolu1990
e83bc5312e Fix RVC decompressor don't care #296 2023-01-18 15:19:59 +01:00
Dolu1990
2bc6e70f03 Fix RVC decompressor don't care #296 2023-01-18 15:19:33 +01:00
Dolu1990
7d3a862183 Fix Litex cluster scopt update 2023-01-16 18:10:51 +01:00
Dolu1990
aea2e90d1e Upgrade to SBT 1.6.0 2023-01-16 17:58:23 +01:00
Dolu1990
94f2ea6dec
Merge pull request #289 from buncram/expose-satp
Expose satp
2023-01-16 12:45:02 +01:00
Dolu1990
0aa6e0573d
shorter satp export 2023-01-16 12:43:01 +01:00
Dolu1990
ed5babaaab
shorter syntax on privilege export 2023-01-16 12:39:55 +01:00
buncram
2297f8aea0 also need to expose privilege state
turns out SATP is not enough to figure out what code you're running,
because the kernel code is mapped into all userspace's virtual memory
areas. You also need the privilege state to be exported.

This creates an option to export those bits.
2023-01-16 02:16:25 +08:00
Dolu1990
0963eb06bd
Merge pull request #294 from chiangkd/master
Fix invalid hyperlink
2023-01-13 16:25:30 +01:00
chiangkd
6650d0549d Fix invalid hyperlink 2023-01-12 20:51:58 +08:00
Dolu1990
c8dff13391
Merge pull request #291 from chiangkd/master
Fix incorrect comment
2023-01-02 09:56:49 +01:00
chiangkd
df52fab7d1 Fix incorrect comment 2022-12-24 20:41:57 +08:00
Dolu1990
8a6a926401
Merge pull request #288 from betrusted-io/expand-satp
Expand SATP register to 22 bits per spec
2022-12-20 16:05:13 +01:00
buncram
11f391eadf Merge remote-tracking branch 'origin/expand-satp' into expose-satp 2022-12-20 19:31:15 +08:00
bunnie
bf3521f86a Expand SATP register to 22 bits per spec
Vex only implements a 32-bit PA which does not take advantage
of the potetnial 32-bit space in Sv32 mode. Very reasonably,
Vex simply discards the top two unused bits.

However, the spec does require that the register occupy all 22
bits and it is possible for the OS to use the extra bits up top
for some bookkeeping purpose. This commit proposes to expand the
register to occupy the full 22 bits in case an OS is written
to utilize the full width of the register as written in the spec.
2022-12-20 19:25:47 +08:00
buncram
b86047901a add flag to expose SATP externally 2022-12-19 19:03:33 +08:00
Dolu1990
51b69a1527 SpinalHDL 1.8.0 2022-12-05 20:10:58 +01:00
Dolu1990
773f268f37 Fix FPU test syntax 2022-12-01 12:04:16 +01:00
Dolu1990
fb084327da Add VexRiscvBmbGenerator CsrPlugin withPrivilegedDebug assert 2022-11-28 16:30:47 +01:00
Dolu1990
eafeb5fe49 Add EmbeddedRiscvJtag.debugCd 2022-11-28 11:04:02 +01:00
Dolu1990
a25ae96d33 comment debug code 2022-11-21 14:02:35 +01:00
Dolu1990
572ca3fcfa Privileged debug fake maskmax to 31 2022-11-21 14:01:28 +01:00
Dolu1990
5a8cdee884 Fix CsrPlugin dcsr.stepie 2022-11-21 11:55:07 +01:00
Dolu1990
4ae7386904 Merge pull request #276 from LYWalker/master
Add ability to debug over Intel Virtual JTAG
2022-11-18 17:38:50 +01:00
Dolu1990
e19e59b55c Clear mprv on xretAwayFromMachine 2022-11-17 15:03:47 +01:00
Dolu1990
663174bc73 Privileged debug now implement stoptime stopcount 2022-11-17 13:58:29 +01:00
Dolu1990
36c3346e51 ensure rvc 0 is detected as a illegal instruction 2022-11-17 11:03:45 +01:00
Dolu1990
5e17ab62d6 Fix RISC-V debug hardware breakpoints 2022-11-14 14:45:11 +01:00
Dolu1990
fe68b8494e Fix a few RISC-V official debug support :
- Disable interrupts in debug mode
- Ensure traps do not change CSR in debug mode
- step will also consider trapEvent
2022-11-11 14:05:38 +01:00
Dolu1990
2504f9b9b9 RISC-V debug havereset implemented 2022-11-10 15:49:07 +01:00
Dolu1990
0bfaf06a4a main.cpp add VEXRISCV_JTAG=yes 2022-11-10 13:43:14 +01:00
Dolu1990
f71234786f Remove rv64 opcode (shift and lwu)
Thanks Milan
2022-10-27 15:44:50 +02:00
Dolu1990
d70794f252 fix regression 2022-10-27 15:38:34 +02:00
Dolu1990
5d0deb20b3 Fix regression compilation 2022-10-27 15:20:55 +02:00
Dolu1990
9f6186cd9a Add GenFullWithRiscvPrivilegedDebugJtag demo 2022-10-27 14:55:40 +02:00
Dolu1990
6289ebcbe4 Merge branch 'riscv-debug' into dev 2022-10-27 14:46:46 +02:00
Dolu1990
a6c29766da CsrPlugin now force privilegeGen when withPrivilegedDebug is enabled 2022-10-26 15:48:34 +02:00
Dolu1990
ab7b2cff3b fix diagram name 2022-10-26 10:48:21 +02:00
Dolu1990
7fd55c7851 Add VexRiscvAxi4LinuxPlicClint diagram drawio 2022-10-26 10:47:23 +02:00
Dolu1990
0e531515ac cleaning 2022-10-26 10:25:50 +02:00
Dolu1990
63dd787bce VexRiscvAxi4Linux now integrate Plic and Clint 2022-10-26 10:15:21 +02:00
Dolu1990
220af95043 Add VexRiscvAxi4Linux (untested, but generate a netlist) 2022-10-24 10:35:59 +02:00
Dolu1990
0979f8ba80 Add whitebox example 2022-10-24 10:24:41 +02:00
Dolu1990
17d52ce58f privileged debug now access data cache with caching enable 2022-10-21 18:58:40 +02:00
Dolu1990
486d17d245 CsrOpensbi now add rvc to misa 2022-10-21 18:58:13 +02:00
Dolu1990
662943522f Fix privileged debug trigger decode break logic 2022-10-21 17:21:13 +02:00
Dolu1990
95c656ceef riscv debug multiple harts 2022-10-21 12:28:17 +02:00
Dolu1990
0313f84419 Fix RISCV debug step 2022-10-20 10:36:30 +02:00
Dolu1990
4cd3f65296 Add official RISC-V debug support (WIP, but can already load / step / run code via openocd telnet) 2022-10-19 12:36:45 +02:00
Dolu1990
87c8822f55 Merge branch 'dev' (fix FPU dirty flag on csr write) 2022-10-13 09:35:55 +02:00
Dolu1990
959e48a353 Fpu now set csr status fs on FPU csr write 2022-10-06 11:13:57 +02:00
Dolu1990
7b9891829a More bus doc #266 2022-09-26 11:39:58 +02:00
Dolu1990
051d140c33 SpinalHDL 1.7.3 2022-09-19 13:27:22 +02:00
Dolu1990
fda7da00c2 add litex --wishbone-force-32b 2022-09-06 11:19:29 +02:00
Dolu1990
e3e21994b4 use SpinalHDL "dev" 2022-07-22 09:33:19 +02:00
Dolu1990
54412bde30 getDrivingReg() update 2022-07-21 09:10:26 +02:00
Dolu1990
24795ef09b SpinalHDL 1.7.1 2022-07-20 11:17:10 +02:00
Dolu1990
a650000f0b SpinalHDL 1.7.2 2022-07-11 12:03:06 +02:00
Dolu1990
b1252f47de csr opensbi now enable ebreak 2022-06-13 16:34:49 +02:00
Dolu1990
1303c0ca7c CfuPlugin.withEnable added 2022-06-09 17:57:31 +02:00
Dolu1990
1ce4c6e493 fix VexRiscvRegressionData url 2022-06-01 09:54:11 +02:00
Dolu1990
8ab9a9b12e fix VexRiscvRegressionData url 2022-06-01 09:53:41 +02:00
Dolu1990
0f6d0f022c VexRiscvBmbGenerator now also report bytesPerLine 2022-05-24 12:37:31 +02:00
Dolu1990
771eaf431e Better cache invalidation doc 2022-05-24 12:15:57 +02:00
Dolu1990
e6dfcac0be Add D$ single line flush support 2022-05-24 12:13:37 +02:00
Dolu1990
4c4913c703 Fix MPP to only retain legal values 2022-05-24 11:14:34 +02:00
Dolu1990
209fc719e8 VexRiscvBmbGenerator export more info 2022-05-24 10:19:35 +02:00
Dolu1990
48cf4120f2 Add VexRiscvSmpCluster forceMisa/forceMscratch 2022-05-23 15:49:32 +02:00
Dolu1990
0872852387 Fix DYNAMIC_TARGET / debug plugin interation corrupting the recoded next pc durring step by step #254 2022-05-17 20:44:17 +02:00
Dolu1990
b39557e226 Fix DYNAMIC_TARGET / debug plugin interation corrupting the recoded next pc durring step by step #254 2022-05-17 20:44:02 +02:00
Dolu1990
a553d3b476 Fix DYNAMIC_TARGET from triggering fetch missprediction while in debug mode #254 2022-05-17 15:27:50 +02:00
Dolu1990
8d0f7781de Fix DYNAMIC_TARGET from triggering fetch missprediction while in debug mode #254 2022-05-17 15:27:36 +02:00
Dolu1990
ba908ebada
Merge pull request #253 from mmicko/micko/riscv_formal
Update to latest risc-v-formal
2022-05-16 11:48:12 +02:00
Dolu1990
9c768be7af Fix CfuPlugin/VfuPlugin fork duplication
https://github.com/google/CFU-Playground/issues/582
2022-05-16 10:37:12 +02:00
Dolu1990
78f0a7f13e Fix CfuPlugin/VfuPlugin fork duplication
https://github.com/google/CFU-Playground/issues/582
2022-05-16 10:36:21 +02:00
Dolu1990
8df2dcbd40 Fix RVC step by step triggering next instruction branch predictor 2022-05-11 14:10:32 +02:00
Dolu1990
4fff62d3fe Fix RVC step by step triggering next instruction branch predictor 2022-05-11 14:10:11 +02:00
Dolu1990
e0eb00573c SpinalHDL 1.7.0a 2022-05-09 11:33:15 +02:00
Dolu1990
6326736401
Update build.sbt 2022-05-04 00:03:54 +02:00
Dolu1990
27772a65dd SpinalHDL 1.7.1 2022-04-29 15:22:34 +02:00
Dolu1990
8d6cb26421 Merge branch 'dev' 2022-04-29 15:20:29 +02:00
Dolu1990
9506b0b8f1 SpianlHDL 1.7.0 2022-04-29 14:16:41 +02:00
Dolu1990
9772e6775d
readme now document FPU / openocd limitations 2022-04-27 16:12:56 +02:00
Dolu1990
5fe1fb07d4
Merge pull request #249 from saahm/master
Add Murax peripheral extension Tutorial
2022-04-26 14:56:11 +02:00
Dolu1990
17007586e8 #241 Fix Murax/Briey TB timeouts 2022-04-26 11:00:40 +02:00
Sallar Ahmadi-Pour
bd74833900 add murax peripheral extension tutorial 2022-04-25 12:21:41 +02:00
Dolu1990
8a8e976493
Merge pull request #248 from dnltz/WIP/dnltz/fix-reg
plugin: caches: Fix "Can't resolve the literal value of"
2022-04-22 11:12:26 +02:00
Daniel Schultz
ea7a18c7f4 plugin: caches: Fix "Can't resolve the literal value of"
Both registers were initialized with unsigned integers without a value.
This triggered:

[error] Exception in thread "main" spinal.core.SpinalExit:
[error]  Can't resolve the literal value of (..._rspCounter :  UInt[32 bits])

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2022-04-20 11:19:34 +02:00
Dolu1990
3b8270b82b #241 Fix Murax/Briey TB timeouts 2022-04-11 11:59:41 +02:00
Dolu1990
53d52692de #240 Code generation now warn against cpu generation without illegal instruction catch and ebreak being disabled, as it may make crash some software, ex : rust 2022-04-08 11:09:48 +02:00
Dolu1990
db34033593 #240 Code generation now warn against cpu generation without illegal instruction catch and ebreak being disabled, as it may make crash some software, ex : rust 2022-04-08 11:09:14 +02:00
Miodrag Milanovic
32a5206541 Update to latest risc-v-formal 2022-04-04 16:37:43 +02:00
Dolu1990
e6c21996a4
Merge pull request #243 from andreasWallner/fix_gen_simd_add_resetvector
Fix reset vector of GenCustomSimdAdd
2022-04-04 10:16:50 +02:00
Andreas Wallner
2d2017465e Fix reset vector of GenCustomSimdAdd
With the old reset vector half of the tests fail since
they expect the CPU to start at 0x80000000.
(e.g. I-IO, I-NOP, I-LUI, etc.)
2022-04-03 02:55:42 +02:00
Dolu1990
ccff48f872 deprecated Data.keep 2022-03-30 16:17:57 +02:00
Dolu1990
4bddb091ae Update CFU example 2022-03-23 18:58:18 +01:00
Dolu1990
5dc91a8be4 Add MuraxCfu 2022-03-23 18:54:18 +01:00
Dolu1990
b2e61caf9e CfuPlugin now implement upstream spec 2022-03-23 18:54:07 +01:00
Dolu1990
9149c42065 DecoderPlugin now implement forceIllegal API 2022-03-23 18:53:43 +01:00
Dolu1990
51b8865b66 Fix VexRiscvSmpClusterGen linux less mhartid 2022-03-18 12:36:05 +01:00
Dolu1990
e1620c68b2 Fix Briey simulation floating rxd blocking the uart #238 2022-02-22 16:15:35 +01:00
Dolu1990
e558b79582 Fix Briey simulation floating rxd blocking the uart #238 2022-02-22 16:15:14 +01:00
Dolu1990
9d3b83366c Merge branch 'master' into dev 2022-02-17 16:27:26 +01:00
Dolu1990
36f57d5eb7
Merge pull request #236 from dnltz/WIP/dnltz/remove-assert
plugin: DBusSimplePlugin: Remove assert
2022-02-17 16:25:45 +01:00
Dolu1990
5b45ddab1b SpinalHDL 1.6.4 2022-02-16 14:26:58 +01:00
Dolu1990
e4fde184d9 SpinalHDL 1.6.5 2022-02-16 14:12:00 +01:00
Daniel Schultz
807aa98d37 plugin: DBusSimplePlugin: Remove assert
This assert triggered sometimes at the beginning of a simulation.
Since it's not really needed anymore, we can remove it.

Signed-off-by: Daniel Schultz <daniel.schultz@aesc-silicon.de>
2022-02-10 19:55:08 +01:00
Dolu1990
77e361e91e Merge branch 'dev' 2022-02-05 12:08:43 +01:00
Dolu1990
5714680278 Merge branch 'master' into dev
# Conflicts:
#	build.sbt
2022-02-05 11:32:40 +01:00
Dolu1990
62c07670af version++ 2022-02-05 11:31:04 +01:00
Dolu1990
4dd650736f verilator++ 2022-02-04 16:36:11 +01:00
Dolu1990
378c0f8723 verilator++ 2022-02-04 16:20:43 +01:00
Dolu1990
8b2f107d46 verilator++ 2022-02-04 15:10:57 +01:00
Dolu1990
7d9a50357f
Merge pull request #233 from dnltz/WIP/dnltz/csr-registers
plugin: CsrPlugin: Init cycle and instret registers
2022-01-27 12:05:43 +01:00
Daniel Schultz
57dd80a566 plugin: CsrPlugin: Init cycle and instret registers
Both counters are initialized with "randBoot()". This is fine for FPGA
designs because the registers can be loaded with default values but
ASIC designs require to load the value during a reset.

Since both counters require to start at 0 (read-only CSR registers),
change both registers from "randBoot()" to "init(0)".

Error:

    reg        [63:0]   CsrPlugin_mcycle = 64'b0000000...00000000000;

           |
  Warning : Ignoring unsynthesizable construct. [VLOGPT-37]

Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
2022-01-26 08:59:03 +01:00
Dolu1990
9c34a1fd2e updated related to JtagInstructionWrapper.ignoreWidth 2022-01-14 09:59:24 +01:00
Dolu1990
b8e904e43f syncronize golden model with dut for lrsc reservation 2022-01-10 19:55:28 +01:00
Dolu1990
6e77f32087 sim golden model lrsc reservation sync 2022-01-10 16:08:38 +01:00
Dolu1990
da53de360f Fix lrsc from last commit 2022-01-10 14:21:20 +01:00
Dolu1990
f46ad43f39
DataCache.withInternalLrSc reserved clearing fix 2022-01-10 13:39:41 +01:00
Dolu1990
349993b235
Merge pull request #230 from OscarShiang/typo
Fix typo in Linux.scala
2022-01-04 11:02:27 +01:00
Oscar Shiang
fe6c391fe4 Fix typo in Linux.scala
Correct "machime" to "machine".
2022-01-04 16:31:23 +08:00
Dolu1990
34e5cafb75 Enable scala 2.13 compatibility 2021-12-20 09:38:35 +01:00
Dolu1990
4824827b7e Enable scala 2.13 compatibility 2021-12-20 09:38:02 +01:00
Dolu1990
a340798840
Update build.properties 2021-12-18 09:11:08 +01:00
Dolu1990
53a3330340
Update build.properties 2021-12-18 09:10:43 +01:00
Dolu1990
dd12047aa7 Merge branch dev (SpinalHDL 1.6.1) 2021-12-15 09:22:46 +01:00
Dolu1990
0539dd7110
SpinalHDL 1.6.2 2021-12-08 23:45:05 +01:00
Dolu1990
6c5908f7a3
Merge pull request #220 from BLangOS/patch-1
Update DebugPlugin.scala: Add optional readback of hardware breakpoint values
2021-11-15 09:25:00 +01:00
B.Lang
411d946a58
Update DebugPlugin.scala
Add readback of the hardware breakpoint values.
A new parameter is added to the plugin to switch readback on and off.
2021-11-11 12:12:23 +01:00
Dolu1990
acf14385d8 #213 disable pmp test with region overlapping 2021-10-22 17:24:51 +02:00
Dolu1990
9df704cad9
Merge pull request #213 from occheung/pmp-fix
PMP Plugin: Fix PMP region size & priority
2021-10-21 10:13:21 +02:00
occheung
a3807660e3 pmp perm: revert to mux for priority 2021-10-19 11:40:39 +08:00
occheung
df03c99ab2 pmp_setter: fix mask generation 2021-10-19 11:39:25 +08:00
Dolu1990
c3c3a94c5d IBusSimplePlugin can now use a Vec based buffer 2021-10-13 16:26:16 +02:00
Dolu1990
97a3c1955b VexRiscvSmpCluster add d$ i$ less arg 2021-10-11 11:57:39 +02:00
Dolu1990
35754a0709 Fix BrieySim (SpinalSim) 2021-09-25 13:28:37 +02:00
Dolu1990
8c0fbcadac Add BrieySim (SpinalSim) 2021-09-25 13:18:55 +02:00
Dolu1990
5f5f4afbf2 Briey revert RVC unwanted addition 2021-09-22 15:01:08 +02:00
Dolu1990
b807254759 Briey and Murax verilators now use FST instead of VCD 2021-09-22 12:57:27 +02:00
Dolu1990
65cda95176 Fix wishbone bridges with datawidth > 32 2021-09-17 09:43:30 +02:00
Dolu1990
c1481ae244 update ScopeProperty usages 2021-09-16 19:08:41 +02:00
Dolu1990
42bb1ab591 d$ / i$ toWishbone bridges can now be bigger than 32 bits
https://github.com/m-labs/VexRiscv-verilog/pull/12
2021-09-15 11:36:51 +02:00
Dolu1990
68e704f309 restore avalon d$ tests 2021-09-02 15:42:33 +02:00
Dolu1990
efd3cd4737 Merge branch 'master' into dev 2021-09-02 14:16:07 +02:00
Dolu1990
cc9f3e753a Fix d$ toAxi bridge 2021-09-02 14:14:42 +02:00
Dolu1990
bc561c30eb Add PmpPluginOld (support TOR) 2021-09-01 11:27:12 +02:00
Dolu1990
5c7e4a0294 #170 wishbone example now set dBusCmdMasterPipe 2021-08-24 23:24:29 +02:00
Dolu1990
3deeab42fd VexRiscvSmpCluster config fix 2021-08-10 12:14:42 +02:00
Dolu1990
805bd56077 Fix VexRiscvBmbGenerator.hardwareBreakpointCount default value 2021-07-30 16:51:07 +02:00
Dolu1990
671bd30953 Update Bmb invalidate/sync parameters 2021-07-28 13:44:04 +02:00
Dolu1990
ba8f5f966a Vfu typo 2021-07-26 15:27:20 +02:00
Dolu1990
b717f228d6 VfuPlugin wip 2021-07-26 15:17:06 +02:00
Dolu1990
c242744d02 CfuPlugin now only fork when the rest of the pipeline is hazard free 2021-07-26 14:45:54 +02:00
Dolu1990
f3f9b79f9a VexRiscvSmpCluster earlyShifterInjection added 2021-07-21 18:34:57 +02:00
Dolu1990
5fc4125763 Merge branch 'dev' 2021-07-20 11:21:11 +02:00
Dolu1990
3028c19389 Fix #191 (data cache toAxi bridge) 2021-07-20 11:20:53 +02:00
Dolu1990
5f2fcc7d0f Merge branch 'dev'
(SpinalHDL 1.6.0)
2021-07-20 10:39:09 +02:00
Dolu1990
66bcd7fca7 readme: add the tom link about JTAG and GDB 2021-07-20 10:14:54 +02:00
Dolu1990
0cdad37fff VexRiscvSmpClusterGen now implement ebreak 2021-07-11 21:55:33 +02:00
Dolu1990
91b3e79485 SpinalHDL version++ 2021-07-11 21:55:13 +02:00
Dolu1990
a4c86130cc Update README.md 2021-07-09 09:35:49 +02:00
Dolu1990
9bc7dce857
Update README.md 2021-07-08 09:47:54 +02:00
Dolu1990
28a75afe7a reduce regression time 2021-07-05 14:17:59 +02:00
Dolu1990
c79357d1b2 VexRiscvSmpClusterGen no support atomic less configs 2021-07-05 12:38:54 +02:00
Dolu1990
a380c3a36c Merge branch 'spinal_1.4.4' into dev 2021-07-05 11:37:53 +02:00
Dolu1990
551e76d244 VexRiscvSmpCluster add a few options 2021-07-02 19:04:30 +02:00
Dolu1990
3702ea03c0 Fix github actions 2021-06-23 11:48:53 +02:00
Dolu1990
df7ac05db9 Update 2.13 compatibility 2021-06-23 11:48:38 +02:00
Dolu1990
cdd8a7e94a add github action 2021-06-23 09:04:35 +02:00
Dolu1990
1017b316b8 version++ 2021-06-15 15:59:09 +02:00
Dolu1990
d67fe72de9 Merge branch 'dev'
# Conflicts:
#	build.sbt
#	src/test/cpp/regression/main.cpp
2021-06-15 15:54:13 +02:00
Dolu1990
1497001ebd Update FpuTest with the new rs1/rs2 store mapping 2021-06-09 13:37:31 +02:00
Dolu1990
1ee45eeb0a More named signals 2021-06-09 11:27:18 +02:00
Dolu1990
0e89ebeced Improve FPU rs1 timings 2021-06-09 11:26:58 +02:00
Dolu1990
e1e1be5797 exception code can now be bigger than 4 bits 2021-06-08 12:19:08 +02:00
Dolu1990
646911a373 Fix pmp write when there is hazard due to the register file. 2021-06-07 17:30:47 +02:00
Dolu1990
87f100dac1
Merge pull request #174 from lindemer/new_pmp
New PMP plugin optimized for FPGAs
2021-06-03 20:16:34 +02:00
Samuel Lindemer
156a84e76f Fix PMP FSM halting logic 2021-06-03 13:12:55 +02:00
Samuel Lindemer
342b06128f Combine all the PMP logic into one FSM 2021-06-02 17:12:10 +02:00
Samuel Lindemer
2a4ca0b249 PMP CSR writes occur in execute stage 2021-06-02 16:01:30 +02:00
Dolu1990
6cde5f9315 Better doc about iorange 2021-06-02 10:27:46 +02:00
Dolu1990
0272d66971 Fix CsrPlugin.redoInterface priority 2021-05-28 16:20:43 +02:00
Samuel Lindemer
3a4ab7ad51 Un-pend PMP CSR writes on pipeline flushes 2021-05-28 16:17:19 +02:00
Samuel Lindemer
4bdeb7731b Merge branch 'new_pmp' of github.com:lindemer/VexRiscv into new_pmp 2021-05-28 14:00:07 +02:00
Samuel Lindemer
243d0ec664 Clarify PMP section in README 2021-05-28 13:59:59 +02:00
Samuel Lindemer
d49f8d1b58
Merge branch 'dev' into new_pmp 2021-05-28 13:56:15 +02:00
Samuel Lindemer
24a534acff All tests passing on new PMP plugin 2021-05-28 13:54:55 +02:00
Dolu1990
4490254d3d Csr/Mmu ensure implement that SFENCE_VMA flush the next instructions
SAT flush reworked a bit too
2021-05-28 13:35:52 +02:00
Samuel Lindemer
4a2dc0ff5f Fix granularity control 2021-05-27 15:50:45 +02:00
Samuel Lindemer
6471014131 Simplify pmpcfg encoding 2021-05-27 14:34:51 +02:00
Dolu1990
4b0763b43d CsrPlugin.csrMapping now give names to inner signals 2021-05-27 10:40:55 +02:00
Samuel Lindemer
a5f66623b7 Add an "allow" property to individual CSRs 2021-05-26 16:34:51 +02:00
Samuel Lindemer
61f68f0729 Refactor for new CSR API (PMP reads still broken) 2021-05-26 15:29:27 +02:00
Dolu1990
6066d8bc26 CsrPlugin add API to implement CSR in a decoupled way. (very low level api) #174 2021-05-26 11:44:46 +02:00
Dolu1990
72328e7bc4 Arty now has RVC enabled ! 2021-05-25 15:59:02 +02:00
Dolu1990
2de35e6116
Merge pull request #184 from allexoll/master
fixed priority of == & != as seemed logical
2021-05-17 23:42:55 +02:00
Alexis Marquet
8122cc9b5e fixed priority of == & != as seemed logical to get less warnings when building 2021-05-17 18:51:33 +02:00
Dolu1990
1c3b9e93a2
Merge pull request #182 from rdolbeau/extra_config
Make the [ID]TLB size configurable from Litex
2021-05-12 13:54:27 +02:00
Dolu1990
91195b1a0a
Merge pull request #181 from pipsoft/master
Improving Documentation on Using BSCANE2 with Murax and OpenOCD
2021-05-12 13:51:17 +02:00
Dolu1990
fe739b907a Bench DecoderPlugin 2021-05-10 10:47:15 +02:00
Romain Dolbeau
1bd33a369e Make the [ID]TLB size configurable from Litex 2021-05-08 07:59:34 -04:00
Frank Poppen
5a7c71259d Removes PDF and xilinx-xc7.cfg and jtagspi.cfg. Enhances README.md to find in OpenOCD. 2021-05-06 17:31:40 +02:00
Frank Poppen
47110a97a3 Updates two missed issues with nativeJtag documentation from previous commit. 2021-05-06 08:49:11 +02:00
Frank Poppen
ac1a6715d7 Improves the documentation for nativeJtag about Murax with BSCANE2 and OpenOCD. 2021-05-06 08:44:05 +02:00
Dolu1990
e78c0546a0 fix #178 2021-05-04 21:09:42 +02:00
Dolu1990
5dd7e6e065
Merge pull request #179 from Pradeep2004/master
Update Readme
2021-05-04 16:11:22 +02:00
Pradeep2004
b1fd24665e
Update Readme 2021-05-03 17:34:50 +02:00
Dolu1990
f1d7c294ee
Update usb_connect.cfg 2021-05-03 10:59:32 +02:00
Dolu1990
a34d6ffb83
update doc/nativeJtag/usb_connect.cfg 2021-05-03 10:59:21 +02:00
Dolu1990
f35d5cd2ba
Merge pull request #177 from Pradeep2004/master
New Readme file to debug Murax SoC without usnig Jtag Adapter
2021-05-03 10:58:24 +02:00
Pradeep2004
1470069dbd
Create soc_init.cfg 2021-04-30 23:15:58 +02:00
Pradeep2004
d194867b19
Create usb_connect.cfg 2021-04-30 23:14:50 +02:00
Pradeep2004
2a5bf9e993
Delete Readme 2021-04-30 22:57:59 +02:00
Pradeep2004
6ca917b5cc
Debugging Murax SoC without using Jtag Adapter 2021-04-30 22:56:47 +02:00
Pradeep2004
d4ab5e971b
Debugging Murax SoC without using Jtag Adapter 2021-04-30 22:55:18 +02:00
Pradeep2004
d72e9fad3f
Delete nativeJtag 2021-04-30 22:44:22 +02:00
Pradeep2004
fb8694aa8d
Create nativeJtag 2021-04-30 22:43:37 +02:00
Pradeep2004
334df7010c
debugging Murax SoC without Jtag Adapter 2021-04-30 22:37:26 +02:00
Pradeep2004
d15f358b44
Update Readme 2021-04-30 22:35:41 +02:00
Pradeep2004
ff2b7c64a4
Debugging Murax SoC without JTAG Adapter 2021-04-30 17:46:16 +02:00
Pradeep2004
f10f9246dd
Create Readme
Debugging Murax SoC without JTAG adapter
2021-04-30 17:45:16 +02:00
Dolu1990
fa2899a1a2 Merge branch 'debugPlugin' into dev 2021-04-26 11:11:38 +02:00
Dolu1990
45e67ccf56 sync 2021-04-26 11:10:55 +02:00
Dolu1990
0a0998fcea #176 fix typo 2021-04-22 14:02:46 +02:00
Dolu1990
32e4ea406f update #176 when DebugPlugin ebreak are enabled it disable CsrPlugin ebreak. Also, DebugPlugin ebreak can be disabled via the debug bus. 2021-04-22 13:59:33 +02:00
Dolu1990
bfe65da1eb implement #176 DebugPlugin.allowEBreak is now disabled until the debug bus is used. 2021-04-20 23:23:18 +02:00
Samuel Lindemer
79bc09e69a Decouple PMP and CSR plugins 2021-04-13 08:35:07 +02:00
Dolu1990
4e41654a84 remove eclipse plugin 2021-04-12 18:28:41 +02:00
Samuel Lindemer
15137742fc
Merge branch 'dev' into new_pmp 2021-04-12 13:23:10 +02:00
Samuel Lindemer
9e65b769cf Update README.md 2021-04-12 13:20:15 +02:00
Samuel Lindemer
b41db0af93 Prevent PMP access from U-mode, fix tests 2021-04-12 13:20:15 +02:00
Samuel Lindemer
bf399cc927 Initial commit of optimized PMP plugin 2021-04-12 13:20:15 +02:00
Dolu1990
21d24eb07f
Merge pull request #171 from tcal-x/cfu-spec
CFU spec -- update immed data sent in place of RS2.
2021-04-03 10:32:55 +02:00
Tim Callahan
36c896f95b Update CFU immed field to use sext([31:24]) to match spec.
Signed-off-by: Tim Callahan <tcal@google.com>
2021-04-02 13:16:53 -07:00
Dolu1990
66f5c3079b CfuPlugin names fixes 2021-04-02 12:50:21 -07:00
Dolu1990
73893ce5d9 CfuPlugin names fixes 2021-04-02 09:20:26 +02:00
Dolu1990
a42c089119 IBusSimplePlugin ensure AHB persistance 2021-03-31 19:03:38 +02:00
Dolu1990
9ac6625ef3 FpuCore improve FMA rounding 2021-03-29 16:31:18 +02:00
Dolu1990
a8721b02de Add AES/FPU doc 2021-03-29 14:55:41 +02:00
Dolu1990
9462496386 Add rvc support and fix rvc with FPU 2021-03-25 14:14:19 +01:00
Dolu1990
6f481f51ef Fetcher.decompressor ensure that the decoded instruction do not mutate when the pipeline is stalled (fix FPU cmd fork for rvc without injector stage) 2021-03-25 14:13:12 +01:00
Dolu1990
21c91c6b70 fpu now lift wfi 2021-03-24 16:21:37 +01:00
Dolu1990
925edd160e RVC implement RVF RVD
Rework RVC_GEN
2021-03-24 12:04:27 +01:00
Dolu1990
704423f27f
Merge pull request #167 from rdolbeau/support_FDwC
Attempt at supporting C (ompressed) and F/D (floating-point) together
2021-03-24 11:59:05 +01:00
Romain Dolbeau
8495fe3dde Attempt at supporting C (ompressed) and F/D (floating-point) together 2021-03-24 11:07:09 +01:00
Dolu1990
da458dea7e litex cluster add cpuPerFpu option 2021-03-23 20:00:50 +01:00
Dolu1990
80f64f0f9f litex better pipelining for better fmax, create one FPU for each 4 cores 2021-03-18 11:10:22 +01:00
Dolu1990
6956db2b21 fpu add schedulerM2sPipe optino 2021-03-18 11:10:22 +01:00
Dolu1990
099dea743b fpu cleanup 2021-03-18 10:54:51 +01:00
Dolu1990
f6e620196d litex add fpu suport 2021-03-17 13:19:41 +01:00
Dolu1990
1a0aa37d6f Merge branch 'fiber' into dev 2021-03-17 10:02:09 +01:00
Dolu1990
530554d19c fix fpu diagram 2021-03-16 14:52:57 +01:00
Dolu1990
e23687c45d Handle ClockDomain improvements 2021-03-16 14:46:30 +01:00
Dolu1990
02c572b6f1 fpu improve FMax and add asyncronus regfile support 2021-03-16 14:45:59 +01:00
Dolu1990
0d628b4706 fpu add doc 2021-03-16 14:44:31 +01:00
Dolu1990
5aa1f2e996 fpu improve pipline cycles 2021-03-15 17:27:14 +01:00
Dolu1990
341c159d06 data cache relax assert into error 2021-03-15 14:43:22 +01:00
Dolu1990
3a34b8dae2 Merge branch 'dev' into fiber
# Conflicts:
#	src/main/scala/vexriscv/demo/smp/VexRiscvSmpCluster.scala
#	src/main/scala/vexriscv/plugin/MulPlugin.scala
2021-03-15 10:35:02 +01:00
Charles Papon
ff4e5e4666 wipe generator 2021-03-11 18:02:02 +01:00
Charles Papon
adc37b269c FpuPlugin.pending is now 6 bits 2021-03-11 13:06:50 +01:00
Charles Papon
845cfcb966 DebugPlugin.fromBscane2 added 2021-03-10 20:35:44 +01:00
Charles Papon
67d2f72a4b fiber sync 2021-03-07 20:43:02 +01:00
Dolu1990
75bbb28ef6
readme update verlator version 2021-03-06 19:49:23 +01:00
Dolu1990
e384bfe145 fiber update 2021-03-05 22:04:20 +01:00
Dolu1990
fd234bbf9e fix cfu gen error 2021-03-05 09:41:05 +01:00
Dolu1990
aee8841438 CFU ensure that CFU_IN_FLIGHT do not produce false positive when the pipeline is stuck 2021-03-05 09:41:05 +01:00
Dolu1990
ec507308e7 fix cfu gen error 2021-03-04 20:29:33 +01:00
Dolu1990
bdc52097b6 CFU ensure that CFU_IN_FLIGHT do not produce false positive when the pipeline is stuck 2021-03-04 20:15:01 +01:00
Dolu1990
0530d22a1d sync 2021-03-04 16:06:18 +01:00
Dolu1990
caf1bde49b Add MuraxAsicBlackBox example 2021-03-04 10:16:45 +01:00
Dolu1990
4bdab667cc fpu fix cmd / commit race condition 2021-03-02 19:39:55 +01:00
Dolu1990
636d53cf63 fpu now track commits using a counter per pipeline per port 2021-03-02 16:13:12 +01:00
Dolu1990
81c193af1f Improve subnormal/normal rounding 2021-02-26 16:32:42 +01:00
Dolu1990
de81da36eb Fpu fix a few div special cases 2021-02-25 19:39:57 +01:00
Dolu1990
de09ed3fcb fpu added exact div/sqrt implementations using iterative approaches 2021-02-25 15:28:38 +01:00
Dolu1990
be81cc1e0e CfuPlugin.response_ok removed 2021-02-23 12:23:48 +01:00
Dolu1990
47673863fb fpu test cleaning 2021-02-22 19:27:55 +01:00
Dolu1990
b1f4c06d4e fpu fix arbitration/lock bugs
add getVexRiscvRegressionArgs
2021-02-22 19:27:26 +01:00
Dolu1990
a6e89fe05c fpu vex regression goldenModel can now assert FPU interface 2021-02-19 17:55:56 +01:00
Dolu1990
3f226b758c fpu fix exception flag handeling 2021-02-19 13:03:48 +01:00
Dolu1990
e504afbf18 fpu integration wip, got mandelbrot to work in linux with no inline (crash when inlined) 2021-02-19 11:26:28 +01:00
Dolu1990
8537d18b16 fpu improve fmax 2021-02-17 16:35:52 +01:00
Dolu1990
1e647f799c fpu Fix VexRiscv integration and add software f64 tests (pass) 2021-02-17 12:33:27 +01:00
Dolu1990
06b7a91de4 MulPlugin fix buffer interraction with partial regfile bypass 2021-02-17 11:35:17 +01:00
Dolu1990
f180ba2fc9 fpu double fixes
DataCache now support wide load/store
2021-02-16 15:38:51 +01:00
Dolu1990
8b2a2afb6f VexRIscvSmpCluster add options 2021-02-16 14:42:31 +01:00
Dolu1990
1752b9e6d6 DataCache.toBmb with aggregation sync path pipelined 2021-02-16 14:17:21 +01:00
Dolu1990
fe690528f7 MulPlugin.outputBuffer feature added 2021-02-16 14:16:57 +01:00
Dolu1990
3b99090879 VexRiscvConfig.get added 2021-02-16 14:15:20 +01:00
Dolu1990
7d3b35c32c fpu f64/f32 pass all tests 2021-02-12 14:48:44 +01:00
Dolu1990
9a25a12879 fpu add FCVT_X_X 2021-02-11 17:40:35 +01:00
Dolu1990
82dfd10dba fpu fix f32 tests for f64 fpu 2021-02-11 16:42:17 +01:00
Dolu1990
b6eda1ad7a fpu f64 load/store/mv/mul seems ok 2021-02-11 16:07:47 +01:00
Dolu1990
e97c2de837 fpu f64 wip 2021-02-10 19:27:26 +01:00
Dolu1990
88dffc21f7 fpu f64 wip 2021-02-10 13:20:17 +01:00
Dolu1990
889cc5fde2 fpu refractoring 2021-02-10 12:16:56 +01:00
Dolu1990
1fe993ad10 fpu fixed corner cases, FpuPlugin coupling, pass rv-test excepted div (accuracy), can run C sinf successfully 2021-02-09 18:35:47 +01:00
Dolu1990
bf6a64b6b5 fpu sgnj / fclass / fmv pass 2021-02-08 15:29:50 +01:00
Dolu1990
bf0829231d fpu min max pass 2021-02-06 14:08:21 +01:00
Dolu1990
008fadeaa9 fpu eq lt le pass testfloat 2021-02-06 13:20:27 +01:00
Dolu1990
6170243283 fpu got exception flag right for add/sub/mul/i2f/f2i 2021-02-05 16:24:14 +01:00
Dolu1990
f278900cbe VexRiscvSmpCluster can now set regfile read kind 2021-02-05 11:09:18 +01:00
Dolu1990
0f1ca72171 fix synthesis bench 2021-02-04 12:43:31 +01:00
Dolu1990
936e5823dc fpu test wip 2021-02-04 12:41:49 +01:00
Dolu1990
3710fd3492 fix synthesis bench 2021-02-04 12:41:31 +01:00
Dolu1990
02b5b9b05c fpu load subnormal and i2f now use single cycle shifter 2021-02-03 16:48:09 +01:00
Dolu1990
8e7e736e3e Merge branch 'dev' into fpu
# Conflicts:
#	src/main/scala/vexriscv/Riscv.scala
#	src/main/scala/vexriscv/ip/fpu/FpuCore.scala
#	src/main/scala/vexriscv/ip/fpu/Interface.scala
#	src/test/scala/vexriscv/ip/fpu/FpuTest.scala
2021-02-03 16:06:17 +01:00
Dolu1990
8eb8356dea fpu wip 2021-02-03 14:28:02 +01:00
Dolu1990
1d0eecdcb0 fpu f2i rounding ok and full shifter 2021-02-03 14:27:52 +01:00
Dolu1990
ef011fa0d4 fpu moved 1 bit from round to mantissa 2021-02-02 11:29:35 +01:00
Dolu1990
a87cb202b1 fpu i2f rounding ok 2021-02-01 16:12:38 +01:00
Dolu1990
d92adfbad0 SpinalHDL version++ 2021-02-01 15:20:57 +01:00
Dolu1990
6ee45a1014 SpinalHDL version++ 2021-02-01 12:28:33 +01:00
Dolu1990
36b3cd9188 Merge branch 'dev' 2021-02-01 12:19:21 +01:00
Dolu1990
98eaeaabc8
fix regression.mk typo 2021-01-30 22:34:54 -01:00
Dolu1990
6aa6191240 Merge branch 'master' into dev
# Conflicts:
#	build.sbt
#	src/main/scala/vexriscv/Riscv.scala
#	src/main/scala/vexriscv/ip/DataCache.scala
#	src/main/scala/vexriscv/plugin/DBusSimplePlugin.scala
#	src/main/scala/vexriscv/plugin/MmuPlugin.scala
#	src/test/cpp/regression/makefile
#	src/test/scala/vexriscv/TestIndividualFeatures.scala
2021-01-30 20:30:21 +01:00
Dolu1990
c51b0fcafe fpu mul now pass all roundings 2021-01-29 22:30:19 +01:00
Dolu1990
0997592768 fpu mul sems all good excepted subnormal rounding 2021-01-29 16:13:49 +01:00
Dolu1990
3c4df1e963 fpu moved overflow rounding to writeback 2021-01-29 14:37:52 +01:00
Dolu1990
fc3e6a6d0a fpu add rounding is ok excepted infinity result 2021-01-28 20:26:43 +01:00
Dolu1990
1ae84ea83b fpu added proper rounding for add (need to manage substraction) 2021-01-28 00:25:16 +01:00
Dolu1990
195e4c422d fpu now integrate f2i shifter withing the subnormal shifter 2021-01-27 12:11:30 +01:00
Dolu1990
444bcdba0a fpu merged i2f with load pipeline 2021-01-26 15:28:09 +01:00
Dolu1990
3334364f5f fpu added more tests for min max sqrt div 2021-01-26 12:50:23 +01:00
Dolu1990
f818fb3ba4 fpu got proper subnormal support, pass add/mul 2021-01-26 10:49:53 +01:00
Dolu1990
d6e8a5ef22 VexRiscvSmpLitex options refractoring 2021-01-23 20:16:58 +01:00
Dolu1990
ce143e06f2 VexRiscvSmpLitex --in-order-decoder --wishbone-memory added 2021-01-23 17:48:34 +01:00
Dolu1990
bdb5bc1180 fpu div implement some special values handeling 2021-01-22 20:47:31 +01:00
Dolu1990
7d79685fe2 fpu mul now support special floats values and better rounding 2021-01-22 18:15:45 +01:00
Dolu1990
4bd637cf88 fpu add now support special floats values and better rounding 2021-01-22 14:55:37 +01:00
Dolu1990
bcd140fc42 Add vexRiscvConfig.withMmu option 2021-01-21 13:28:09 +01:00
Dolu1990
ccd13b7e9e fpu zero/nan wip 2021-01-21 12:13:25 +01:00
Dolu1990
50a69d8d4a
Merge pull request #163 from lindemer/pmp-warl
Make all PMP registers WARL according to specification
2021-01-21 10:50:49 +01:00
Samuel Lindemer
6c13e6458f Remove registers storing PMP region bounds 2021-01-20 14:27:38 +01:00
Dolu1990
ac5844f393 fpu add signed i2f/f2i 2021-01-20 13:15:29 +01:00
Dolu1990
15d79ef330 fpu implement fclass and args for sub, fma, max, fcmp, fsgnj 2021-01-20 12:01:08 +01:00
Samuel Lindemer
828ea96006 PMP registers are now WARL 2021-01-20 09:27:35 +01:00
Dolu1990
11349a71fa fpu FpuPlugin now implement all instructions.
Remains the FPuCore to implement cmd.arg and floating point corner cases
2021-01-19 17:57:41 +01:00
Dolu1990
9f18045329 fpu add sstatus.fs 2021-01-19 16:06:16 +01:00
Dolu1990
a7d148d0ff fpu add vex csr 2021-01-19 15:53:11 +01:00
Dolu1990
f826a2ce51 fpu completion interface added + refractoring 2021-01-19 15:13:13 +01:00
Dolu1990
8c4fae8bf2 fpu add min/sgnj/fmv 2021-01-19 13:27:42 +01:00
Dolu1990
ed68c8cf04
Merge pull request #162 from lindemer/paging
Distinguish between page faults from MMU and access faults from PMP
2021-01-18 22:18:06 +01:00
Dolu1990
d7220031d4 fpu vex i2f works 2021-01-18 17:18:01 +01:00
Dolu1990
d4b877d415 fpu vex cmp/fle works 2021-01-18 15:09:30 +01:00
Dolu1990
6cb498cdb2 fpu merge load/commit 2021-01-18 13:09:08 +01:00
Dolu1990
a9d8c0a19f fpu wip 2021-01-18 11:38:26 +01:00
Dolu1990
3cda7c1f1b fpu wip 2021-01-15 14:03:37 +01:00
Dolu1990
04499c0b76 FPU sqrt functional 2021-01-14 18:33:24 +01:00
Dolu1990
85dd5dbf8e fpu div functional, sqrt wip 2021-01-14 15:56:56 +01:00
Samuel Lindemer
5e6c645461 Distinguish between page faults from MMU and access faults from PMP 2021-01-14 09:45:38 +01:00
Dolu1990
8761d0d9ee FpuCore can add/mul/fma/store/load 2021-01-13 18:28:26 +01:00
Dolu1990
6e0be6e18c Cfu add state index and cfu index 2021-01-11 13:44:04 +01:00
Dolu1990
930bdf9dda DataCache increase syncPendingMax to 32 and use a sync queue instead of async one 2021-01-04 10:59:21 +01:00
Dolu1990
780ad01ac0 Add AES-instruction support 2020-12-21 11:52:55 +01:00
Dolu1990
d2855fcfca
Merge pull request #147 from lindemer/pmp
Physical Memory Protection (PMP) plugin
2020-12-11 15:22:28 +01:00
Dolu1990
c59499ec03 typo 2020-12-11 14:13:33 +01:00
Dolu1990
eaff52b264 Add comments to the AesPlugin 2020-12-11 13:51:10 +01:00
Dolu1990
6da09967f8 Add comments to the AesPlugin 2020-12-11 13:46:55 +01:00
Samuel Lindemer
7d699dcc13 Remove PMP from MachineOs test defaults 2020-12-10 09:42:27 +01:00
Samuel Lindemer
f2ce2eab00 PMP plugin passes regression tests 2020-12-07 12:04:45 +01:00
Samuel Lindemer
763eebeeba Add TOR support, tests pass on GenZephyr 2020-12-04 17:13:31 +01:00
Samuel Lindemer
5cb5061d9b PMP passes test with GenZephyr, but pipeline flushes have been disabled 2020-12-03 17:29:31 +01:00
Dolu1990
9a6931a54c CfuPlugin improve writeback buffering 2020-12-03 16:21:52 +01:00
Samuel Lindemer
987de8fb6a Lock PMP address registers in golden model 2020-12-02 14:18:17 +01:00
Samuel Lindemer
14c39a0070 Merge remote-tracking branch 'upstream/master' into pmp 2020-12-02 14:08:32 +01:00
Samuel Lindemer
872aa19d83 Add PMP to golden model 2020-12-02 12:27:26 +01:00
Samuel Lindemer
d5b1a8f565 Add PMP test to regression suite 2020-12-01 18:38:06 +01:00
Dolu1990
45ff78d068 VexRiscvSmpClusterGen.dBusCmdMasterPipe option added 2020-12-01 13:51:10 +01:00
Samuel Lindemer
c5023ad973 Add PMP regression test 2020-12-01 09:10:24 +01:00
Dolu1990
1b65a9e523
remove libts-dev from readme 2020-11-30 16:11:00 +01:00
Samuel Lindemer
2d0ebf1ef5 Flush pipeline after PMP CSR writes 2020-11-25 15:38:34 +01:00
Dolu1990
e0ae46e794 Fix Csr ReadWrite interration with DBusCachedPlugin execute halt
# Conflicts:
#	src/main/scala/vexriscv/plugin/CsrPlugin.scala
2020-11-18 14:43:24 +01:00
Dolu1990
832218dbec DBusCachedPlugin increase pendingMax to 64 to hide memory latency when saving a full context 2020-11-16 12:38:29 +01:00
Dolu1990
ba523c627a Fix Csr ReadWrite interration with DBusCachedPlugin execute halt 2020-11-16 12:37:48 +01:00
Dolu1990
dae633aa7d
Merge pull request #150 from banahogg/patch-1
Update GCC prebuild instructions for sifive.com reorg
2020-11-15 11:25:50 +01:00
banahogg
d1691e9478
Update GCC prebuild instructions for sifive.com reorg 2020-11-14 17:31:50 -08:00
Dolu1990
c1b0869c21 AesPlugin is now little endian 2020-11-12 15:07:27 +01:00
Dolu1990
1b2a2ebaca DBusCachedPlugin miss decoded aquire fix 2020-11-12 15:07:07 +01:00
Dolu1990
05e725174c AesPlugin added, work with dropbear encryption, seem ok for decryption (barmetal) 2020-11-02 17:14:52 +01:00
Dolu1990
9abe19317d RegFilePlugin.x0Init do less assumption on other plugin behaviour 2020-11-02 17:01:17 +01:00
Samuel Lindemer
97fe279f7b Enable PMP register lock 2020-10-29 13:37:21 +01:00
Dolu1990
dc9246715d Do not allow jtag ebreak outside machine mode 2020-10-28 13:00:16 +01:00
Dolu1990
4209dc2792 Fix CsrPlugin privilege crossing 2020-10-28 13:00:15 +01:00
Dolu1990
576e21d75d Do not allow jtag ebreak outside machine mode 2020-10-28 12:58:24 +01:00
Dolu1990
abebeaea1f Fix CsrPlugin privilege crossing 2020-10-28 12:57:20 +01:00
Samuel Lindemer
fc2c8a7c37 Initial commit of PMP plugin 2020-10-27 09:38:58 +01:00
Dolu1990
fe342c347c CfuBusParameter has now a few default values 2020-10-23 11:06:24 +02:00
Dolu1990
d490f903ea
Merge pull request #145 from zeldin/bigendian2
Update big endian instruction encoding
2020-10-21 12:56:56 +02:00
Marcus Comstedt
6c8e97f825 Update big endian instruction encoding
Between draft-20181101-ebe1ca4 and draft-20190622-6993896 of the
RISC-V Instruction Set Manual, the wording was changed from requiring
"natural endianness" of instruction parcels to require them to be
little endian.

Update the big endian instruction pipe to reflect the newer requirement.
2020-10-20 18:05:31 +02:00
Dolu1990
4ece59385d DataCache split redo / refilling execute stage halt 2020-10-19 18:12:20 +02:00
Dolu1990
e58daee088 SpinalHDL++ 2020-10-16 11:25:25 +02:00
Dolu1990
ec55187033 improve LightShifterPlugin arbitration halt timings 2020-10-09 11:37:48 +02:00
Dolu1990
bbaa0520c0
Fix UserInterruptPlugin interrupt enable 2020-10-09 10:45:23 +02:00
Dolu1990
8bd1785233
Merge pull request #141 from betrusted-io/dev-asid
Dev asid
2020-10-04 15:20:02 +02:00
bunnie
72f85ef6c0 Merge remote-tracking branch 'origin/dev' into dev-asid 2020-10-04 19:53:29 +08:00
Dolu1990
b7e7faebad sbt update 2020-10-04 09:57:34 +02:00
bunnie
65e6f6054b Add ASID field to SATP
ASID field is missing from the SATP which causes compatibility
issues with Xous.

While this patch resolves the Xous issue, it has not been tested
on Linux.
2020-10-04 15:34:58 +08:00
Dolu1990
98de02051e
Merge pull request #135 from zeldin/bigendian
Add support for big endian byte ordering
2020-10-01 16:43:00 +02:00
Dolu1990
9d35e75fb5
Update README.md 2020-10-01 16:41:24 +02:00
Dolu1990
3f5e771a5c dbus mmu access improvement 2020-09-17 22:06:29 +02:00
Dolu1990
de820daf74 add earlyBranch option to Smp config 2020-09-13 18:33:06 +02:00
Dolu1990
49488d19af pipeline data cache unaligned access check 2020-09-07 12:01:11 +02:00
Dolu1990
775b336ee0
Merge pull request #136 from zeldin/rv32e
Add support for RV32E in RegFilePlugin
2020-09-06 22:23:24 +02:00
Marcus Comstedt
8e466dd13c Add support for RV32E in RegFilePlugin
The RV32E extension removes registers x16-x31 from the ISA.  This
is useful when compiling with -mem2reg to save on BRAMs.  On iCE40
HX8K this option saves 1285 LC:s, which also improves the routing
situation, when using -mem2reg.

Note that the illegal instruction exception required by the RV32E
specification for accesses to registers x16-x31 is not implemented.
2020-09-06 17:05:31 +02:00
Dolu1990
4c3cad97d3 fix CfuPlugin generation 2020-09-04 10:36:12 +02:00
Marcus Comstedt
c489143442 Add support for big endian byte ordering 2020-08-30 15:17:09 +02:00
Dolu1990
7dcaa0c390 VexRiscvSmpCluster now avoid useless decoder for plic/clint 2020-08-13 11:26:11 +02:00
Dolu1990
69d5ba239a Smp config now initialise regfile using logic 2020-07-28 16:15:17 +02:00
Dolu1990
cc423cbe49 Litex cluster add DMA sel feature 2020-07-21 19:42:27 +02:00
Dolu1990
15bda15bc9 Litex cluster can now set cache layout 2020-07-21 19:35:56 +02:00
Dolu1990
9f62f37538 improve LitexCluster area for single core configuration 2020-07-21 15:45:02 +02:00
Dolu1990
da666ade49 Add VexRiscvLitexSmpClusterCmdGen 2020-07-21 15:07:32 +02:00
Dolu1990
fe5401f835 BmbGenerators refractoring (bus -> ctrl) 2020-07-16 13:04:25 +02:00
Dolu1990
da73317912 Cleanup BmbGenerators 2020-07-15 20:51:46 +02:00
Dolu1990
5f0aec7570 BmbInterconnectGenerator refractoring 2020-07-15 17:03:05 +02:00
Dolu1990
4f5ba6b044 Merge branch 'bmbRework' into dev 2020-07-10 13:06:20 +02:00
Dolu1990
f6931784a5 Merge branch 'smp' into dev 2020-07-10 13:00:50 +02:00
Dolu1990
d0a572de98 Add openroad config 2020-07-08 01:37:10 +02:00
Dolu1990
32f778613f DBusCachedPlugin now support asyncTagMemory 2020-07-08 01:36:58 +02:00
Dolu1990
60ee7e2b4c Better VexRiscvSmpCluster config 2020-07-08 01:36:40 +02:00
Dolu1990
51070d0e69 Fix MmuPlugin when used in multi stage config 2020-07-05 13:17:39 +02:00
Dolu1990
06584518da Remove CsrPlugin redoInterface combinatorial depedency from execut_isStuck 2020-07-05 13:17:07 +02:00
Dolu1990
a404078117 Few fixes 2020-07-05 13:16:39 +02:00
Dolu1990
c51e25f8c4 Litex SoC add coherent DMA master 2020-07-05 13:15:44 +02:00
Dolu1990
32539dfe6d Got VexRiscvSmpLitexCluster refractoring to work 2020-06-30 22:29:33 +02:00
Dolu1990
0da94ac66f Bring back smp cluster parameters 2020-06-29 15:49:01 +02:00
Dolu1990
062509deee Update Bmb brides and comment out SmpCluster for now 2020-06-29 11:44:10 +02:00
Dolu1990
c12f9a378d Fix inv regression 2020-06-20 13:18:46 +02:00
Dolu1990
f0f2cf61da D$ inv/ack are now fragment, which ease serialisation of wider invalidations 2020-06-19 15:57:56 +02:00
Dolu1990
c18bc12cb2 Fix DebugPlugin.fromBmb 2020-06-19 15:57:21 +02:00
Dolu1990
490c1f6b02 cleanup of old todo 2020-06-19 15:56:45 +02:00
Dolu1990
b0cd88c462 SmpCluster now with proper jtag and plic 2020-06-12 16:18:41 +02:00
Dolu1990
2e8a059c77 Fix travis verilator 2020-06-07 11:33:24 +02:00
Dolu1990
cb5597818d Fix d$ generation crash 2020-06-07 11:29:07 +02:00
Dolu1990
1f9fce6388 Fix d$ uncached writes exception handeling 2020-06-06 22:12:37 +02:00
Dolu1990
760d2f74d0 Update litex cluster to implement utime 2020-06-05 13:31:24 +02:00
Dolu1990
d6455817e7 smp cluster now have 2w*4KB of d$ , no more rdtime emulation 2020-06-05 10:43:03 +02:00
Dolu1990
71760ea372 CsrPlugin now support utime csr to avoid emulation 2020-06-05 10:43:03 +02:00
Dolu1990
3dafe8708b Cfu update 2020-06-05 10:43:03 +02:00
Dolu1990
0668046407 More smp cluster profiling 2020-06-05 10:40:51 +02:00
Dolu1990
97c2dc270c Fix typo 2020-06-04 10:11:30 +02:00
Dolu1990
89c13bedbd Fix litex smp cluster sim 2020-06-03 16:31:54 +02:00
Dolu1990
73f88e47cb Fix BmbToLitexDram coherency 2020-06-03 16:31:54 +02:00
Dolu1990
db50f04653 Add litexMpCluster 2020-06-03 16:31:54 +02:00
Dolu1990
08189ee907 DebugPlugin now support Bmb 2020-06-02 19:13:55 +02:00
Dolu1990
2942d0652a fix Briey verilator 2020-06-01 11:18:25 +02:00
Dolu1990
5e5c730959 Add LitexSmpDevCluster with per cpu dedicated litedram ports 2020-05-29 10:56:55 +02:00
Dolu1990
bc4a2c3747 Fix SmpCluster jtag 2020-05-27 14:19:37 +02:00
Dolu1990
18cce053a3 Improve SingleInstructionLimiterPlugin to also include fetch stages 2020-05-27 14:19:17 +02:00
Dolu1990
a64fd9cf3b Add CsrPlugin external hartid
d$ rsp/sync now decrement pendings by signal amount
2020-05-20 13:49:10 +02:00
Dolu1990
380afa3130 SpinalHDL 1.4.2 2020-05-20 13:45:52 +02:00
Dolu1990
c3540bc6e0
SpinalHDL 1.4.2 2020-05-20 10:37:52 +02:00
Dolu1990
24b676ce30
Merge pull request #124 from tomverbeure/uinstret
Add uinstret support.
2020-05-20 10:35:42 +02:00
Tom Verbeure
b901651ab5 Add default value of NONE to uinstret CSR. 2020-05-19 14:48:35 -07:00
Tom Verbeure
c74b03b4de Add uinstret support. 2020-05-19 13:40:46 -07:00
Dolu1990
cf60989ae1 Litex smp cluster now blackboxify d$ data ram 2020-05-14 00:05:54 +02:00
Dolu1990
42fef8bbcd Smp cluster now use i$ reduceBankWidth 2020-05-12 23:59:38 +02:00
Dolu1990
685c914227 Add i$ reduceBankWidth to take advantage of multi way by remaping the data location to reduce on chip ram data width 2020-05-12 23:59:38 +02:00
Dolu1990
0471c7ad76 Fix machineCsr test 2020-05-12 23:55:47 +02:00
Dolu1990
cb44a474fc more smp cluster profiling 2020-05-12 13:25:55 +02:00
Dolu1990
63511b19a2 smp cluster add more profiling 2020-05-11 10:35:24 +02:00
Charles Papon
b592b0bff8 Add regression TRACE_SPORADIC, LINUX_SOC_SMP
regression golden model now properly sync dut exceptions
2020-05-09 17:00:13 +02:00
Dolu1990
0a159f06b2 update smp config 2020-05-07 22:50:36 +02:00
Dolu1990
0e76cf9ac8 i$ now support multi cycle MMU 2020-05-07 22:50:25 +02:00
Dolu1990
41ee8fd226 MmuPlugin now support multiple stages, D$ can now take advantage of that 2020-05-07 13:37:53 +02:00
Dolu1990
8e025aeeaa more litex smp cluster pipelining 2020-05-07 13:18:11 +02:00
Dolu1990
fc0f3a2020 cleanup mmu interface 2020-05-06 18:05:20 +02:00
Dolu1990
6323caf265 MMU now allow $ to match tag against tlb pyhsical values directly
D$ retiming
D$ directTlbHit feature added for better timings
2020-05-06 17:09:46 +02:00
Dolu1990
ed4a89e4af more pipelineing in Litex SMP cluster interconnect 2020-05-06 17:06:45 +02:00
Dolu1990
8043feebd5 More VexRiscv smp cluster probes 2020-05-06 17:06:17 +02:00
Dolu1990
09724e907b play around with CSR synthesis impact on design size 2020-05-05 00:32:59 +02:00
Dolu1990
c16f2ed787 Add probes in SmpCluster sim 2020-05-04 12:54:28 +02:00
Dolu1990
b0f7f37ac8 D$ now support memDataWidth > 32 2020-05-04 12:54:16 +02:00
Dolu1990
93b386e16e litex smp cluster now use OO decoder 2020-05-02 23:44:58 +02:00
Dolu1990
f0745eb0d9 update SMP line size to 64 bytes 2020-05-02 23:44:27 +02:00
Dolu1990
09ac23b78f Fix SMP fence lock when 4 stages CPU 2020-05-01 12:45:16 +02:00
Dolu1990
f5f30615ba Got litex SMP cluster to work on FPGA 2020-05-01 11:14:52 +02:00
Dolu1990
dc0da9662a Update SMP fence (final) 2020-05-01 11:14:11 +02:00
Dolu1990
7c50fa6d55 SmpCluster now use i$ line of 64 bytes 2020-04-29 14:03:00 +02:00
Dolu1990
9e9d28bfa6 d$ now implement consistancy hazard by using writeback redo 2020-04-29 14:02:41 +02:00
Dolu1990
86e0cbc1f3 I$ with memDataWidth > cpuDataWidth now mux memWords into cpuWords before the decode stage by default. Add twoCycleRamInnerMux option to move that to the decode stage 2020-04-29 13:59:43 +02:00
Dolu1990
7b80e1fc30 Set SMP workspace to use i$ memDataWidth of 128 bits 2020-04-28 22:11:41 +02:00
Dolu1990
eee9927baf IBusCachedPlugin now support memory data width multiple of 32 2020-04-28 22:10:56 +02:00
Dolu1990
23b8c40cab update travis verilator 2020-04-28 16:19:00 +02:00
Dolu1990
03a0445775 Fix SMP for configuration without writeback stage.
Include SMP core into the single core tests regressions
2020-04-28 15:50:20 +02:00
Dolu1990
4a49b23636 Fix regression 2020-04-28 14:38:27 +02:00
Dolu1990
3ba509931c Add VexRiscvSmpLitexCluster with the required pipelining to get proper FMax 2020-04-27 17:38:06 +02:00
Dolu1990
5fd0b220cd CsrPlugin add openSbi config 2020-04-27 17:37:30 +02:00
Dolu1990
0c59dd9ed3 SMP fence now ensure ordering for all kinds of memory transfers 2020-04-27 17:37:15 +02:00
Dolu1990
3fb123a64a fix withStall 2020-04-21 21:20:54 +02:00
Dolu1990
3885e52bb7 Merge remote-tracking branch 'origin/dev' into smp 2020-04-21 17:21:48 +02:00
Dolu1990
4016b1fc52 Add sbt assembly 2020-04-21 17:18:08 +02:00
Dolu1990
056bf63866 Add more consistancy tests 2020-04-21 16:03:03 +02:00
Dolu1990
b389878d23 Add smp consistency check, fix VexRiscv invalidation read during write hazard logic 2020-04-21 12:18:10 +02:00
Dolu1990
0e55caacab deduplicae VexRiscv wishbone 2020-04-21 10:33:51 +02:00
Dolu1990
b383b4b98b Add commented usage of fromXilinxBscane2 2020-04-20 12:13:12 +02:00
Dolu1990
8e8b64feaa Got full linux / buildroot to boot in 4 cpu config 2020-04-19 19:49:26 +02:00
Dolu1990
a1b6353d6b workaround AMO LR/SC consistancy issue, but that need a proper fix 2020-04-19 19:48:57 +02:00
Dolu1990
ad2d2e411a Add tap less debug plugin bridges 2020-04-19 17:56:33 +02:00
Dolu1990
af128ec9eb revert to 4 cpu 2020-04-18 01:27:35 +02:00
Dolu1990
4a49e6d91f initialize the clint in sim 2020-04-18 01:26:31 +02:00
Dolu1990
befecc7ed6 cleaning 2020-04-18 00:51:57 +02:00
Dolu1990
8c0e534c6b Add openSBI test, seem to work fine 2020-04-18 00:51:47 +02:00
Dolu1990
ebe070f9dd
Update README.md 2020-04-17 19:58:54 +02:00
Dolu1990
d5a52caab8 fix smp test barrier 2020-04-16 17:27:27 +02:00
Dolu1990
d88d04dbc4 More SMP tests (barrier via AMO and LRSC) 2020-04-16 15:23:25 +02:00
Dolu1990
fd52f9ba50 Add smp.bin 2020-04-16 02:22:18 +02:00
Dolu1990
73c21177e5 Add VexRiscvSmpCluster, seem to work on simple case 2020-04-16 01:30:03 +02:00
Dolu1990
b9ceabf128 few fixes 2020-04-16 01:29:13 +02:00
Dolu1990
46207abbc4 dataCache now implement invalidation sync 2020-04-16 01:28:38 +02:00
Dolu1990
a00605b10c fix Briey verilator 2020-04-13 13:01:12 +02:00
Dolu1990
467a2bc488 refactor DBus invalidation, and add invalidation enable 2020-04-11 19:06:22 +02:00
Dolu1990
abbfaf6bcf regression : restore normal invalidation setup 2020-04-10 18:58:03 +02:00
Dolu1990
4a9b8c1f72 improve invalidation read during write hazard logic 2020-04-10 14:44:28 +02:00
Dolu1990
0ad0f5ed3f Add d$ invalidation tests
fix d$ invalidation, linux OK
2020-04-10 14:28:16 +02:00
Dolu1990
f71f360e32 Add SMP synthesis 2020-04-10 14:27:39 +02:00
Dolu1990
296cb44bc4 Add hardware AMO support using LR/SC exclusive 2020-04-09 20:12:37 +02:00
Dolu1990
1d0e180e1d Add GenTwoStage config and UltraScale synthesis 2020-04-09 20:11:56 +02:00
Dolu1990
861df664cf clean some AMO stuff 2020-04-08 18:48:01 +02:00
Dolu1990
6922f80a87 DataCache now implement fence operations 2020-04-08 18:12:13 +02:00
Dolu1990
9e1817a280 fix DataCache for config without invalidation 2020-04-07 20:05:24 +02:00
Dolu1990
0c8ea4a368 DataCache add invalidation feature 2020-04-07 19:18:20 +02:00
Dolu1990
1ef099e308 Merge branch 'dev' into smp 2020-04-07 12:29:58 +02:00
Dolu1990
5eaa5ba4db Update README.md 2020-04-07 12:29:40 +02:00
Dolu1990
6e239fb280 Update README.md 2020-04-07 12:29:40 +02:00
Dolu1990
f20eb4d541 Merge pull request #115 from antmicro/fix_emulator
emulator: Use external hw/common.h from LiteX
2020-04-07 12:29:40 +02:00
Dolu1990
ddc59bc404 Fix DebugPlugin step by step 2020-04-07 12:27:52 +02:00
Dolu1990
5aa0b86d96 Fix DebugPlugin step by step 2020-04-07 12:13:40 +02:00
Dolu1990
a52b833727 fix weird regression testbench memory bug 2020-04-06 21:42:44 +02:00
Dolu1990
a107e45116 fix non smp regression 2020-04-06 06:43:28 +02:00
Dolu1990
ca72a421be LrSc align software model to the hardware. Linux OK 2020-04-05 21:45:45 +02:00
Dolu1990
2eec18de65 LrSc SMP, linux crash in userspace 2020-04-05 16:28:46 +02:00
Dolu1990
f2ef8e95ab Implement external LrSc 2020-04-05 11:38:57 +02:00
Dolu1990
ff074459ad Fix LrSc for configs without mmu 2020-04-04 22:54:35 +02:00
Dolu1990
c9bbf0d12a update LrSc reservation logic to match the spec 2020-04-04 21:21:35 +02:00
Dolu1990
31d2aaa05b
Update README.md 2020-03-28 15:38:32 +01:00
Dolu1990
2dac7dae32 Fix BranchPlugin.jumpInterface priority to avoid conflicts with other instructions on DYNAMIC_TARGET missprediction 2020-03-28 14:36:06 +01:00
Dolu1990
b3215e8beb Make things generated in a deterministic order 2020-03-24 13:11:07 +01:00
Dolu1990
31667b18d8
Update README.md 2020-03-20 11:26:38 +01:00
Dolu1990
97258c214a
Merge pull request #115 from antmicro/fix_emulator
emulator: Use external hw/common.h from LiteX
2020-03-18 12:02:27 +01:00
Dolu1990
c122365a52 Smp spec update, add Interface subsets (writeOnly, readOnly) 2020-03-11 14:20:13 +01:00
Dolu1990
95237b23ea SpinalHDL 1.4.0
Merge branch 'dev'
2020-03-09 13:49:06 +01:00
Dolu1990
ab2f4cd2b7 Merge branch 'master' into dev
# Conflicts:
#	README.md
#	build.sbt
2020-03-09 13:41:23 +01:00
Dolu1990
5f90702b2f SpinalHDL update 2020-03-09 13:14:16 +01:00
Dolu1990
defe3c5558 DataCache relax flush timings 2020-03-08 12:35:24 +01:00
Dolu1990
04bf1a4ced Fix build.sbt 2020-03-08 00:23:19 +01:00
Dolu1990
7a5afb86a5 Fix build.sbt 2020-03-07 19:09:33 +01:00
Dolu1990
97db4f02a0 Merge branch 'rework_fetch' into dev 2020-03-07 18:22:46 +01:00
Dolu1990
44005ebf31 update Synthesis results 2020-03-07 18:22:01 +01:00
Charles Papon
2c6076ba97 improve smp spec 2020-03-07 13:35:21 +01:00
Charles Papon
b7ae902bbc smp spec improvements, no more read abort 2020-03-05 00:14:11 +01:00
Charles Papon
58af94269e add CsrPlugin.csrOhDecoder 2020-03-05 00:13:04 +01:00
Charles Papon
50ec0a1917 update readme perf 2020-03-05 00:12:46 +01:00
Charles Papon
505d0b700a MulDivPlugin now give names to div stages 2020-03-04 19:58:54 +01:00
Dolu1990
0a212c91fd update synthesisBench paths 2020-03-04 18:13:56 +01:00
Dolu1990
ff5cfc0dde Fix DebugPlugin step 2020-03-03 18:27:53 +01:00
Dolu1990
12463e40a4 improve debugPlugin step logic 2020-03-03 15:59:30 +01:00
Charles Papon
fd37962a58 typo 2020-03-03 10:56:12 +01:00
Dolu1990
ef5398ce21 Fix #117 DataCache mem blackboxing 2020-03-02 14:24:27 +01:00
Dolu1990
54581f6d9e Fix #117 DataCache mem blackboxing 2020-03-02 14:23:59 +01:00
Dolu1990
78d4660282 Merge branch 'dev' into rework_fetch
# Conflicts:
#	src/test/scala/vexriscv/TestIndividualFeatures.scala
2020-03-01 22:58:25 +01:00
Dolu1990
ea5464ea26 TestIndividualFeatures is now multithreaded 2020-03-01 21:40:53 +01:00
Dolu1990
02545b9bea typo 2020-03-01 13:03:40 +01:00
Dolu1990
559260020b Improve testing infrastructure with more options and better readme
https://github.com/litex-hub/linux-on-litex-vexriscv/issues/112
2020-03-01 13:02:08 +01:00
Dolu1990
0c7556ad7f
Update README.md 2020-02-29 23:46:21 +01:00
Charles Papon
25d880f6c7 Fix synthesis bench 2020-02-28 18:20:08 +01:00
Charles Papon
c94d8f1c6c Fetcher and IBusSimplePlugin flush reworked 2020-02-28 17:23:44 +01:00
Charles Papon
492310e6fa DBusCachedPlugin fix noWriteBack redo priority 2020-02-28 17:21:59 +01:00
Charles Papon
76d063f20a Fix MulPlugin keep attribute 2020-02-24 22:43:08 +01:00
Mateusz Holenko
f88b259eba emulator: Use external hw/common.h from LiteX
Remove code copied from `hw/common.h` and use
the header from the LiteX repository provided
using `LITEX_BASE` environment variable.

Content of `common.h` is now evolving (new functions
are added, some are removed) and syncing it
between repos would be cumbersome.
2020-02-24 14:27:45 +01:00
Charles Papon
999a868c14 Update readme VexRiscv perf numbers 2020-02-24 00:07:14 +01:00
Charles Papon
485b4a5838 Improve maxPerf configs 2020-02-23 23:52:43 +01:00
Charles Papon
fad09e805f Add Fetcher.predictionBuffer option to pipeline BRANCH_TARGET, higher FMax, about 1 ns critical path gain on Arty7 => 5 ns 2020-02-23 23:18:27 +01:00
Charles Papon
67d2071a32 typo 2020-02-23 23:17:02 +01:00
Charles Papon
c8016e90a4 MulPlugin now add KEEP attribute on RS1 and RS2 to force Vivado to not retime it with the DSP 2020-02-23 20:25:31 +01:00
Charles Papon
01e5112680 Fetcher RVC ensure redo keep PC(1)
Fix BranchTarget RVC inibition
2020-02-23 10:44:44 +01:00
Charles Papon
5ea0b57d1b Fix BRANCH_TARGET with RVC patch 2020-02-22 11:53:47 +01:00
Charles Papon
41008551c1 CsrPlugin redo interface do not need next pc calculation 2020-02-21 20:01:35 +01:00
Charles Papon
4ad1215873 Fix iBusSimplePlugin MMU integration 2020-02-21 13:28:42 +01:00
Charles Papon
befc54a444 No more Fetcher flush() API as it can now be done via the decoder.flushNext 2020-02-21 13:28:29 +01:00
Charles Papon
32fade50e5 Fix fetcher decompressor when driving decode stage 2020-02-21 02:03:29 +01:00
Charles Papon
59508d5b57 Fix target branch prediction for RVC, all default configs pass dhrystone 2020-02-20 02:27:57 +01:00
Charles Papon
a684d5e4d1 Rework/clean decompressor logic 2020-02-19 01:20:52 +01:00
Charles Papon
a7440426fd Fix FetchPlugin redo gen condition
Fix injectorFailure reset
2020-02-18 01:00:11 +01:00
Charles Papon
f63c4db469 Fix CsrPlugin pipeline liberator 2020-02-18 00:59:39 +01:00
Charles Papon
53a29e35e9 fix deleg external interrupt propagation time failure 2020-02-17 23:27:17 +01:00
Charles Papon
e0cd9a6e06 clean iBusRsp redo 2020-02-17 22:45:34 +01:00
Charles Papon
0e0a568743 Apply DYNAMIC_TARGET correction all the time 2020-02-17 21:43:02 +01:00
Charles Papon
e23295f06e Fix Fetcher pcValid pipeline 2020-02-17 19:29:41 +01:00
Charles Papon
9e75e2cb58 IBusFetcher disable pcRegReusedForSecondStage when using fetch prediction.
Fix some fetch flush
DYNAMIC_PREDICTION start to work again
2020-02-17 14:36:08 +01:00
Charles Papon
8be50b8e3d IBusFetcher now support proper iBusRsp.redo/flush 2020-02-17 12:50:12 +01:00
Charles Papon
ebfa9e6577 Merge branch 'dev' into rework_fetch 2020-02-16 18:52:31 +01:00
Charles Papon
29f85a7ae2 Remove INSTRUCTION_READY
Add proper Fetcher.ibusRsp.flush
prediction are disabled yet
much is broken for sure, WIP
2020-02-16 18:44:10 +01:00
Charles Papon
0c255e2404 Merge branch 'compiler_plugin' into dev 2020-02-16 14:34:26 +01:00
Charles Papon
3d34d754a9 Remove usages of implicit string to B/U/S 2020-02-15 10:11:00 +01:00
Charles Papon
d241f35625 Remove usages of implicit string to B/U/S 2020-02-15 10:10:04 +01:00
Charles Papon
f1959ff830 smp spec typo 2020-02-15 00:26:11 +01:00
Charles Papon
6edab1eb34 Add SMP spec draft 2020-02-15 00:24:33 +01:00
Dolu1990
b728b60051
Merge pull request #113 from japm48/patch-2
Murax on arty_a7: fix inferred memory type
2020-02-12 23:27:51 +01:00
japm48
6547eefffd
Murax on arty_a7: fix mkdir error 2020-02-11 18:58:43 +01:00
Dolu1990
ecee7122a5
Merge pull request #112 from japm48/patch-1
Readme: fix spelling and made some clarifications
2020-02-11 18:51:45 +01:00
japm48
163611bd11
Murax on arty_a7: fix RAMB type on soc_mmi.tcl 2020-02-11 18:49:56 +01:00
japm48
fd961dccb5
Readme: fix spelling and made some clarifications 2020-02-11 18:18:39 +01:00
Charles Papon
10da093422 Fix sbt 2020-02-06 21:07:40 +01:00
Charles Papon
38a573a48c Update build.sbt 2020-02-03 13:35:55 +01:00
Charles Papon
ee36c36fdd Merge branch 'masterPrerelease' 2020-01-31 11:37:04 +01:00
Charles Papon
390645e581 SpinalHDL 1.3.8 2020-01-29 23:20:35 +01:00
Charles Papon
5b8febb977 Revert "Revert "Merge branch 'master' into dev""
This reverts commit c01c256757.

Fix dBusCachedPlugin relaxedMemoryTranslationRegister when mmu translation is done in the execute stage
2020-01-29 22:37:09 +01:00
Charles Papon
c01c256757 Revert "Merge branch 'master' into dev"
This reverts commit b5374433a5, reversing
changes made to f01da9c73b.
2020-01-29 15:20:13 +01:00
Charles Papon
b5374433a5 Merge branch 'master' into dev 2020-01-29 12:50:41 +01:00
Dolu1990
ac79cc6fe6
Merge pull request #109 from sebastien-riou/arty
missing tcl files for Murax on Arty
2020-01-17 12:07:54 +01:00
sebastien-riou
badc38d645 Merge remote-tracking branch 'origin/master' into arty 2020-01-17 00:54:19 +01:00
sebastien-riou
1fb1e358bb fix makefile clean target 2020-01-17 00:49:35 +01:00
sebastien-riou
2bcddd333d forced the commit of missing TCL files 2020-01-17 00:33:02 +01:00
Dolu1990
95ec47e5b8
Merge pull request #108 from sebastien-riou/arty
Murax on Arty A7-35
2020-01-16 23:21:29 +01:00
sebastien-riou
97b2838d18 Murax on Digilent Arty A7-35 2020-01-16 21:58:55 +01:00
sebastien-riou
195318b665
Merge pull request #1 from sebastien-riou/VXIP
Murax_xip: better pin names in scala, bootloader without magic word
2020-01-13 22:06:31 +01:00
sebastien-riou
de9f704de2 better pin names in scala, bootloader without magic word 2020-01-13 21:58:08 +01:00
Charles Papon
f01da9c73b CsrPlugin add printCsr 2020-01-13 20:44:55 +01:00
sebastien-riou
49f502aef4 Merge branch 'master' of github.com:sebastien-riou/VexRiscv 2020-01-12 19:52:59 +01:00
sebastien-riou
bfb0b54f9b readme for XIP on Murax improved 2020-01-12 19:52:27 +01:00
Dolu1990
b66de1a3c0
Merge branch 'master' into master 2020-01-12 17:38:16 +01:00
sebastien-riou
b866dcb07f XIP on Murax improvements 2020-01-12 16:08:14 +01:00
Dolu1990
061ebd1b2c
Fix murax xip bootloader 2020-01-12 13:27:45 +01:00
Charles Papon
4c7025b964 Fix xtval when no exception and read_only 2020-01-06 20:07:23 +01:00
Charles Papon
2a06907902 fix compilation 2019-12-24 01:09:55 +01:00
Charles Papon
3b494e97cd Moved KeepAttribute to spinal.lib 2019-12-24 00:43:36 +01:00
Charles Papon
052c8dd602 Fix inWfi naming, fix regressions 2019-12-20 00:21:55 +01:00
Charles Papon
0702f97806 CsrPlugin add wfiOutput 2019-12-19 22:55:17 +01:00
Charles Papon
e25dfb4fbf CsrPlugin now make SATP write rescheduling the next instruction 2019-12-09 22:23:07 +01:00
Charles Papon
744b040c70 Sync CFU progress 2019-11-29 11:50:00 +01:00
Charles Papon
7ae218704e CsrPlugin now implement a IWake interface
DebugPlugin now wake the CPU if a halt is asked to flush the pipeline
2019-11-19 18:36:53 +01:00
Dolu1990
b290b25f7a
Merge pull request #95 from MarekPikula/patch-1
Update index links in README
2019-11-09 15:02:56 +01:00
Charles Papon
6d0d70364c Add BranchPlugin.decodeBranchSrc2 for branch target configs 2019-11-08 14:01:53 +01:00
Charles Papon
4fe7fa56c7 GenCustomInterrupt demo now enabled vectored interrupt 2019-11-07 19:55:26 +01:00
Charles Papon
bb405e705b Add UserInterruptPlugin 2019-11-07 19:52:45 +01:00
Marek Pikuła
f6e707a639
Update index links in README
Eclipse links in index were incorrect.
2019-11-07 14:47:36 +01:00
Charles Papon
8839f8a8e9 Fix DBus AXI bridges from writePending counter deadlock 2019-11-03 16:45:24 +01:00
Charles Papon
2bf6a536c9 Fix DBus AXI bridges from writePending counter deadlock 2019-11-03 16:44:09 +01:00
Charles Papon
bd2787b562 RegFilePlugin project X0 against boot glitches if no x0Init but zeroBoot 2019-11-01 16:24:07 +01:00
Charles Papon
f2a5134621 Merge remote-tracking branch 'origin/rpls-mul16' 2019-10-23 22:29:35 +02:00
Charles Papon
bb9261773b Fix MulDiveIterative plugin when RSx have hazard in the execute stage 2019-10-23 00:02:08 +02:00
Charles Papon
67028cdb48 Add Mul16Plugin to regression tests
Fix missing MulSimplePlugin in regressions tests
2019-10-21 12:53:53 +02:00
Charles Papon
8091a872f3 Fix muldiv plugin for CPU configs without memory/writeback stages 2019-10-21 12:53:03 +02:00
Richard Petri
2d56c6738c Multiplication Plugin using 16-bit DSPs 2019-10-20 22:24:19 +02:00
Charles Papon
b4c75d4898 Merge remote-tracking branch 'origin/dev' into dev 2019-10-11 00:25:37 +02:00
Charles Papon
a2b49ae000 Fix CFU arbitration, add CFU decoder, CFU now redirect custom-0 with func3 2019-10-11 00:25:22 +02:00
Charles Papon
310c325eaa IBusCached add Keep attribut on the line loader to avoid Artix7 block ram merge, but do not seem to have effect 2019-10-11 00:24:21 +02:00
Charles Papon
711eed1e77 MulPlugin add withInputBuffer feature and now use RSx instead of SRCx 2019-10-11 00:23:29 +02:00
Charles Papon
3fc0a74102 Add Keep attribut on dBusCached relaxedMemoryTranslationRegister feature 2019-10-11 00:22:44 +02:00
Charles Papon
51d22d4a8c Merge remote-tracking branch 'origin/cfu' into dev 2019-10-10 15:00:43 +02:00
Charles Papon
319d162f67 Merge remote-tracking branch 'origin/tigthlyCoupled' into dev 2019-10-03 12:33:27 +02:00
Charles Papon
5df56bea79 Allow getDrivingReg to properly see i$ decode.input(INSTRUCTION) register
(used to inject instruction from the debug plugin)
2019-10-03 00:20:33 +02:00
Charles Papon
ca228a392e Merge branch 'short-pipeline-fixes' 2019-09-26 10:25:11 +02:00
Charles Papon
8d8c301662 Merge branch 'short-pipeline-fixes-xobs' into short-pipeline-fixes 2019-09-23 15:22:27 +02:00
Charles Papon
49944643d2 Add regression for data cache without writeback stage, seem to pass tests, including linux ones 2019-09-23 15:20:51 +02:00
Charles Papon
bf82829e9e Data cache can now be used without writeback stage 2019-09-23 15:20:20 +02:00
Charles Papon
ace963b542 Hazard on memory stage do not need to know if that's bypassable if the memory stage is the last one 2019-09-21 14:13:28 +02:00
Charles Papon
e1795e59d5 Enable RF bypass on MUL DIV with pipeline wihout writeback/memory stages 2019-09-21 13:00:54 +02:00
Charles Papon
e8236dfebe Add MulSimplePlugin regressions 2019-09-21 12:49:46 +02:00
Charles Papon
be18d8fa5a CSR access enables are also impacted by the MMU memory access 2019-09-21 10:28:52 +02:00
Sean Cross
b8b053e706 muldiviterative: fix build for short pipelines
Signed-off-by: Sean Cross <sean@xobs.io>
2019-09-20 08:36:01 +08:00
Sean Cross
fdc95debef dbuscached: fix build for short pipelines
Signed-off-by: Sean Cross <sean@xobs.io>
2019-09-20 08:35:49 +08:00
Sean Cross
0b79c637b6 mulsimpleplugin: fix build for short pipelines
Signed-off-by: Sean Cross <sean@xobs.io>
2019-09-20 08:35:23 +08:00
Charles Papon
fe385da850 Fix Artix7 FMax, my apologies for that, was due to a bad scripting using Kintex 7 instead 2019-09-16 14:27:41 +02:00
Charles Papon
88eb8e4e47 Fix Artix7 FMax, my apologies for that, was due to a bad scripting using Kintex 7 instead 2019-09-16 14:22:33 +02:00
Charles Papon
6ed41f7361 Improve CSR FMax 2019-09-16 13:53:55 +02:00
Charles Papon
d94cee13f0 Add dummy decoding, exception code/tval
Add Cpu generation code
Add support for always ready rsp
2019-09-05 19:06:28 +02:00
Charles Papon
5ac443b745 Manage cases where a rsp buffer is required 2019-09-05 10:41:45 +02:00
Dolu1990
6951f5b8e6 CfuPlugin addition 2019-09-05 10:41:45 +02:00
Dolu1990
84602f89b0 Merge pull request #80 from antmicro/fix_litex_target
Fix handling LiteX uart and timer.
2019-09-05 10:41:45 +02:00
Dolu1990
0efcaa505d Merge pull request #79 from antmicro/litex_target
Litex target
2019-09-05 10:41:45 +02:00
Mateusz Holenko
86f5af5ca9 Fix handling LiteX uart and timer. 2019-09-05 10:41:45 +02:00
Charles Papon
94f1707d65 Merge branch 'dev' 2019-09-05 10:41:45 +02:00
Mateusz Holenko
8813e071bc Add litex target
Use configuration from the `csr.h` file
generated dynamically when building a LiteX platform.
2019-09-05 10:41:45 +02:00
Mateusz Holenko
64a2815544 Create makefile targets
Allow to change build target without modifiying the sources.
In order to keep compatibilty `sim` target is built by default.
2019-09-05 10:41:45 +02:00
Mateusz Holenko
e76435c6c6 Allow to set custom DTB/OS_CALL addresses
Setting those from command line during compilation allows
to create a custom setup without the need of modifying the
sources.
2019-09-05 10:41:45 +02:00
Mateusz Holenko
c8280a9a88 Allow to set custom RAM base address for emulator
This is needed when loading the emulator to RAM
with an offset.
2019-09-05 10:41:45 +02:00
Charles Papon
b65ef189eb sync with SpinalHDL SDRAM changes 2019-08-29 16:03:20 +02:00
Sean Cross
b91df10b21 Merge branch 'master' of github.com:SpinalHDL/VexRiscv into HEAD 2019-07-27 21:27:16 +08:00
Sean Cross
b0199297fd caches: work without writeBack stage
In the case of an MMU miss, the data caches will create a retry branch port.
These currently implicitly go into the memory/writeBack stage, however
not all CPUs have this stage.

Place the retry branch port into the correct stage.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-07-27 10:08:53 +08:00
Sean Cross
955e70206c MmuPlugin: fix generation without writeBack stage
If there is no writeBack stage, the elaboration step would hit a
NullPointerException when trying to insert into the writeBack stage.

Instead, pull from the most recent stage, which is where MMU access
should reside.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-07-27 10:08:30 +08:00
Dolu1990
5f0c7a7faf
Merge pull request #80 from antmicro/fix_litex_target
Fix handling LiteX uart and timer.
2019-07-24 19:17:23 +02:00
Mateusz Holenko
5085877eed Fix handling LiteX uart and timer. 2019-07-24 16:09:21 +02:00
Dolu1990
6124ec7b14
Merge pull request #79 from antmicro/litex_target
Litex target
2019-07-20 02:59:42 +03:00
Mateusz Holenko
6a2584b840 Add litex target
Use configuration from the `csr.h` file
generated dynamically when building a LiteX platform.
2019-07-11 15:56:48 +02:00
Mateusz Holenko
39c3f408e5 Create makefile targets
Allow to change build target without modifiying the sources.
In order to keep compatibilty `sim` target is built by default.
2019-07-11 15:50:15 +02:00
Mateusz Holenko
423355ecbf Allow to set custom DTB/OS_CALL addresses
Setting those from command line during compilation allows
to create a custom setup without the need of modifying the
sources.
2019-07-11 14:09:06 +02:00
Mateusz Holenko
28a11976da Allow to set custom RAM base address for emulator
This is needed when loading the emulator to RAM
with an offset.
2019-07-11 14:06:24 +02:00
Charles Papon
a2569e76c0 Update sdram ctrl package 2019-07-08 11:23:48 +02:00
Charles Papon
624c641af5 xip refractoring 2019-06-28 10:23:39 +02:00
Charles Papon
b2e06ae198 Back into unreleased SpinalHDL 2019-06-17 17:19:11 +02:00
Charles Papon
20cbd4012f Merge branch 'dev' 2019-06-16 20:50:43 +02:00
Charles Papon
1257b056dc Revert "test only dynamic_target for intensive test"
This reverts commit 635ef51f82.
2019-06-16 18:24:59 +02:00
Charles Papon
12c3ab16ae Update readme perf 2019-06-16 18:07:04 +02:00
Charles Papon
635ef51f82 test only dynamic_target for intensive test 2019-06-16 17:43:07 +02:00
Charles Papon
9656604848 rework dynamic_target failure correction 2019-06-16 17:42:39 +02:00
Charles Papon
4cf7e5b98f SpinalHDL 1.3.6 2019-06-16 00:42:59 +02:00
Charles Papon
60c9c094a7 Merge remote-tracking branch 'origin/rework_jump_flush' into dev 2019-06-15 18:09:38 +02:00
Charles Papon
46e9d5566a Merge branch 'rework_jump_flush' 2019-06-15 18:05:04 +02:00
Charles Papon
7c3c4e8c81 Update readme benches 2019-06-15 14:23:09 +02:00
Charles Papon
a3a0c402bc Remove broken freertos test and add zephyr instead 2019-06-15 10:46:10 +02:00
Charles Papon
617f4742cd Fix dynamic branch prediction correction on misspredicted fetch which are done on a 32 bits instruction crossing two words in configs which have at least 2 cycle latency fetch 2019-06-14 08:13:22 +02:00
Charles Papon
d603de1bfe Fix recent changes 2019-06-13 16:55:24 +02:00
Charles Papon
c8ab99cd0b Cleaning and remove BlockQ regression 2019-06-12 00:00:38 +02:00
Charles Papon
21ec368927 Fix DYNAMIC_TARGET by fixing decode PC updates 2019-06-11 19:56:33 +02:00
Charles Papon
afbf0ea777 Fix regression makefile 2019-06-11 01:05:49 +02:00
Charles Papon
066ddc23e6 Add regression concurrent os executions flag to avoid running debug plugin tests 2019-06-11 00:22:38 +02:00
Charles Papon
21c8933bbb Fix DYNAMIC_TARGET prediction correction in BranchPlugin 2019-06-11 00:12:29 +02:00
Charles Papon
5b53440d27 DYNAMIC_TARGET prediction datapath/control path are now splited 2019-06-10 22:20:32 +02:00
Charles Papon
0e95154869 individual regression : more env control 2019-06-10 21:01:41 +02:00
Charles Papon
bd46dd88aa Fix RVC fetcher pc branches 2019-06-10 20:48:04 +02:00
Charles Papon
24e1e3018c Fix exception handeling 2019-06-09 23:40:37 +02:00
Charles Papon
5243e46ffb Fix BranchPlugin when SRC can have hazard in execute stage 2019-06-09 20:15:36 +02:00
Charles Papon
af0755d8cf rework flush with flushNext and flushIt
static branch prediction jump do not depend on stage fireing anymore
2019-06-09 15:44:05 +02:00
Charles Papon
0e2d40c37f Merge remote-tracking branch 'origin/pipelinedInterrupt' 2019-06-09 12:29:20 +02:00
Charles Papon
357681a5c6 csrPlugin add pipelinedInterrupt, set by default 2019-06-08 22:22:16 +02:00
Charles Papon
0df4ec45ad Merge remote-tracking branch 'origin/master' into dev
# Conflicts:
#	build.sbt
2019-06-05 00:35:41 +02:00
Charles Papon
56f7c27d18 Fix WFI. Not sensitive anymore to global interrupt enables, delegation and privilege 2019-06-05 00:32:38 +02:00
Dolu1990
64e8919e89
Update README.md
Add litex repo
2019-05-28 11:28:07 +02:00
Charles Papon
38a464a829 DataCache now allocate ways randomly 2019-05-25 00:28:30 +02:00
Charles Papon
4a40184b35 Add cache Bandwidth counter, previous commit was about random instruction cache way allocation 2019-05-25 00:22:27 +02:00
Charles Papon
94606d38e2 Add cache bandwidth counter 2019-05-25 00:21:48 +02:00
Charles Papon
206c7ca638 Fix Bmb datacache bridge 2019-05-24 00:22:58 +02:00
Charles Papon
f6f94ad7c1 Fix InstructionCache Bmb bridge 2019-05-22 19:03:26 +02:00
Charles Papon
9b49638654 Allow CsrPlugin config access 2019-05-22 17:27:47 +02:00
Charles Papon
8abc06c8f2 Add Bmb support for i$/d$ 2019-05-22 17:04:36 +02:00
Charles Papon
49b4b61a1a Update Bmb bridges 2019-05-20 14:14:42 +02:00
Charles Papon
f249bbc60a Merge remote-tracking branch 'origin/tmp' 2019-05-18 20:35:28 +02:00
Charles Papon
b40dc06b29 SpinalHDL 1.3.5 2019-05-18 19:56:03 +02:00
Charles Papon
0301ced000 Fix dBusSimplePlugin to bmb bridge 2019-05-16 19:49:13 +02:00
Charles Papon
4ce9d805b4 Switch to unreleased SpinalHDL 2019-05-14 00:41:14 +02:00
Charles Papon
3753f64429 Fix Bmb compilation 2019-05-13 23:44:20 +02:00
Dolu1990
abb7bd99ab
Merge pull request #75 from SpinalHDL/dev
Merge dev (SpinalHDL 1.3.4)
2019-05-10 17:28:09 +02:00
Charles Papon
8201cff7ff SpinalHDL 1.3.4 2019-05-10 14:27:14 +02:00
Charles Papon
db307075cf Merge branch 'AHB' into dev
# Conflicts:
#	src/main/scala/vexriscv/plugin/DBusSimplePlugin.scala
#	src/main/scala/vexriscv/plugin/IBusSimplePlugin.scala
2019-05-07 17:21:52 +02:00
Charles Papon
01db217ab9 Add supervisor support in the ExternalInterruptArrayPlugin 2019-05-06 16:23:43 +02:00
Dolu1990
3094f8b349 Merge remote-tracking branch 'origin/dBusCachedRelaxMmuTranslation' 2019-05-06 01:36:56 +02:00
Dolu1990
91f6bf5139 Merge branch 'dBusCachedRelaxMmuTranslation'
# Conflicts:
#	src/test/scala/vexriscv/TestIndividualFeatures.scala
2019-05-06 01:36:11 +02:00
Charles Papon
d27fa4766d DBusCachedPlugin add earlyWaysHits in regressions 2019-05-06 00:05:40 +02:00
Charles Papon
d12decde80 Remove test which had issues with the testbench ref checks because of getting passed delayed 2019-05-05 22:46:46 +02:00
Charles Papon
8f1b980337 Revert "Add DBusCachedPlugin.relaxedMemoryTranslationRegister option"
This reverts commit 5f18705358.
2019-05-05 22:29:33 +02:00
Charles Papon
5f18705358 Add DBusCachedPlugin.relaxedMemoryTranslationRegister option 2019-05-05 21:19:48 +02:00
Charles Papon
c738246610 Remove the legacy pipelining from Axi4 cacheless bridges 2019-05-01 12:03:01 +02:00
Charles Papon
7d99a70e9c Switch to released SpinalHDL 2019-05-01 12:02:27 +02:00
Charles Papon
02db756b21 Merge remote-tracking branch 'origin/master' into dev 2019-04-29 16:56:04 +02:00
Dolu1990
fa13e46e87
Merge pull request #71 from xobs/mmu-2-stage
Mmu 2 stage
2019-04-26 14:25:29 +02:00
Sean Cross
d1e215e312 caches: work without writeBack stage
In the case of an MMU miss, the data caches will create a retry branch port.
These currently implicitly go into the memory/writeBack stage, however
not all CPUs have this stage.

Place the retry branch port into the correct stage.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-26 18:02:43 +08:00
Sean Cross
b2f387ccac MmuPlugin: fix generation without writeBack stage
If there is no writeBack stage, the elaboration step would hit a
NullPointerException when trying to insert into the writeBack stage.

Instead, pull from the most recent stage, which is where MMU access
should reside.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-04-26 18:01:35 +08:00
Dolu1990
6fc5406901 Merge branch 'linux' 2019-04-25 23:20:01 +02:00
Dolu1990
0edc781b36 Add some coremark results 2019-04-25 23:18:45 +02:00
Charles Papon
10255f2f81 Update readme 2019-04-25 21:11:23 +02:00
Charles Papon
d64589cc48 Add configs without memory/writeback stages in regressions
Add rfReadInExecute configs in regressions
Fix ShiftPluginLight and DBusSimplePlugin for configs with rfReadInExecute stage configs
2019-04-25 17:36:13 +02:00
Charles Papon
431bec84fb Switch to SpinalHDL 1.3.3 (release) 2019-04-24 22:17:46 +02:00
Charles Papon
017e17f9fa Update synthesis results in the readme 2019-04-24 12:32:57 +02:00
Charles Papon
74e5cc49f9 Add the linux config into the synthesis bench 2019-04-24 12:32:37 +02:00
Charles Papon
a331f35724 Icestorm flow now use nextpnr 2019-04-24 12:32:24 +02:00
Charles Papon
b654d824ad remove DebugPlugin from linux.scala, and set static branch prediction 2019-04-23 21:55:54 +02:00
Charles Papon
266bdccc2e update Riscv software model lrsc implementation 2019-04-23 21:55:54 +02:00
Charles Papon
4078f84e8f Dhrystone regression now also run coremark 2019-04-23 21:55:54 +02:00
Charles Papon
c6dbaa52f6 Longer linux regression timeout for very slow configs 2019-04-21 22:16:42 +02:00
Charles Papon
633e057d11 Split machine os regression in two smaller parts 2019-04-21 20:30:58 +02:00
Charles Papon
14efe6ffda Riscv software model now implement interrupt priority accordingly to 496c59d064 (diff-a38d447c5232bd448697af4c6c8adb1a) changes 2019-04-21 20:01:39 +02:00
Charles Papon
d7ca153c8b remove interrupt assertion 2019-04-21 19:45:24 +02:00
Charles Papon
0e10c460c3 Update Zephyr tests, the mem_pool_threadsafe one was bugy by the past, and now it is just too long 2019-04-21 17:58:42 +02:00
Charles Papon
4cbb93cfc8 Look like zephyr mem_pool_threadsafe is a broken test 2019-04-21 17:48:08 +02:00
Dolu1990
1c86bf7514 Increase liveness trigger to allow large instruction cache flush 2019-04-21 15:25:39 +02:00
Charles Papon
4efa3b0d45 Update readme 2019-04-21 14:41:27 +02:00
Dolu1990
d18dcc0540
Update regression.mk
reduce linux regression time a bit
2019-04-21 13:49:05 +02:00
Dolu1990
fc4c078f17
Update regression.mk
Reduce machine os time
2019-04-21 13:36:25 +02:00
Charles Papon
7e91b5e446 Fix travis 2019-04-21 12:55:01 +02:00
Charles Papon
963805ad48 Bring freertos back in tests
Better travis test range
2019-04-21 12:50:28 +02:00
Charles Papon
edde3e3011 Add zephyr tests 2019-04-21 02:56:44 +02:00
Charles Papon
5cd74d2845 Merge remote-tracking branch 'origin/linuxDev' into linux 2019-04-20 15:33:30 +02:00
Charles Papon
3b0f2e9551 better travis timings
travis job naming
reduce verilator cache size
Fix dcache test timeout
travis cleaning
travis wip
verilator wip
fix java 10 compilation
Travis wip
travis rework
2019-04-20 14:56:56 +02:00
Charles Papon
06e63252e4 Merge branch 'linux' into linuxDev 2019-04-19 21:12:35 +02:00
Charles Papon
b49076ecab add missing coremark patch 2019-04-19 19:41:05 +02:00
Charles Papon
ac5517f199 Travis : Bring back random regressions 2019-04-19 18:33:04 +02:00
Charles Papon
728a5ff20f Fix coremark binaries (no csr) 2019-04-19 18:28:46 +02:00
Charles Papon
a496638c72 fix travis 2019-04-19 17:38:51 +02:00
Charles Papon
e47b76fa67 #60 Added automated linux regression in travis
Fix DBusCached plugin access sharing for the MMU deadlock when exception is in the decode stage
Fix IBusSimplePlugin issues with used with non regular configs + MMU
Bring back the LinuxGen config into a light one
2019-04-19 17:35:48 +02:00
Charles Papon
2810ff05b0 Fix emulator instruction emulation trap redirection to supervisor.
Impact only AMO less configs
2019-04-19 02:31:39 +02:00
Charles Papon
b79b02152b #60 Fix SFENCE_VMA deadlock 2019-04-18 18:33:06 +02:00
Dolu1990
d2b324e32b Add jtag and vhdl option 2019-04-15 11:01:51 +02:00
Charles Papon
6f04c02cd2 TestInduvidualFeatures now use the linux config + MMU 2019-04-14 23:06:04 +02:00
Charles Papon
8c7407967e Fix non RVC fetcher exception PC capture 2019-04-14 23:04:30 +02:00
Charles Papon
61d25e931e #60 Add sim error message on RVC instruction without RVC capabilities 2019-04-13 10:44:06 +02:00
Charles Papon
5d1ec604b2 Make regression sim great again 2019-04-13 10:41:15 +02:00
Charles Papon
9ac1d3d59e riscv software model without RVC now trap on RVC instruction before pcWrite + 2 2019-04-13 10:40:53 +02:00
Charles Papon
a12ca43284 README.md Update eclipse install 2019-04-12 17:41:15 +02:00
Charles Papon
3301a1b364 Add CsrPlugin.userGen option which now remove privilegeReg when not set 2019-04-12 16:37:34 +02:00
Charles Papon
d5723968da Merge remote-tracking branch 'origin/master' into linux
# Conflicts:
#	src/main/scala/vexriscv/plugin/IBusSimplePlugin.scala
#	src/test/cpp/regression/main.cpp
2019-04-12 16:26:08 +02:00
Charles Papon
8421328ee1 restore freertos tests 2019-04-12 16:09:20 +02:00
Charles Papon
13b774b535 #69 Relax address calculation of decode branch predictor by adding KEEP synthesis attribut 2019-04-12 15:56:22 +02:00
Charles Papon
41ff87f83b Remove jalr from decode branch prediction missaligned inibition 2019-04-12 15:27:10 +02:00
Charles Papon
63cd5f42af Fix #69 discoverd fmax issue with decode stage branch predictions 2019-04-12 15:24:33 +02:00
Dolu1990
fdd2194c8f
Merge pull request #69 from tomverbeure/micro_warnings
GenMicro with warnings
2019-04-12 14:58:17 +02:00
Charles Papon
b329ee85ad #60 Fix missing ecallGen flag 2019-04-11 15:30:54 +02:00
Charles Papon
ece1e73547 Default linux config is now without RVC
Remove all linux usless CSR from the config
Remove verilator instruction fetch check
2019-04-11 01:18:15 +02:00
Charles Papon
caa37a8028 Reduce machine mode emulator CSR requirements and emulate more CSR (in the case they aren't supporter in hardware) 2019-04-10 19:04:52 +02:00
Charles Papon
6b22594961 Flush MMU line with exception on context switching instead than on cmd fire 2019-04-10 15:42:39 +02:00
Charles Papon
926b74a203 shorter coremark 2019-04-10 15:41:58 +02:00
Charles Papon
189cadfbb3 Add coremark 2019-04-10 15:41:38 +02:00
Charles Papon
d7f6c18c0a Fix DebugPlugin -> force machine mode, force uncached memory load 2019-04-10 00:35:15 +02:00
Charles Papon
9b6b65b8b4 Fix icache test when dynamic target branch prediction is enabled 2019-04-09 19:37:18 +02:00
Charles Papon
a6dc530441 Added lrsc/amo tests 2019-04-09 19:27:42 +02:00
Charles Papon
fd42e7701e Add hardware AMO, require AMO=yes in sim and withAmo=true in linux.scala 2019-04-09 01:22:32 +02:00
Charles Papon
21cb8615fd Clean and fix things to get all the non-linux configs and machine only configs working 2019-04-08 16:06:05 +02:00
Charles Papon
32921491b8 #60 Fix instruction cache refill 2019-04-08 14:24:37 +02:00
Charles Papon
fd15a938c5 #60 Fix machine mode emulator atomic emulation. Do not write regfile if the page was set as read only. 2019-04-08 13:20:56 +02:00
Charles Papon
c2595273ec Add a busy flag from MMU ports
iBus/dBus now halt on MMU busy, which avoid looping forever on page fault
2019-04-08 11:38:40 +02:00
Charles Papon
f89ee0d422 #60 Fix MMU holding invalid tlb, while linux is assuming it isn't doing so. 2019-04-07 15:44:25 +02:00
Tom Verbeure
4fd36454d7 Complain about wrong earlyBranch settings. 2019-04-06 12:58:19 -07:00
Tom Verbeure
39a4aa5e26 GenMicroNoCsr: no memory stage, no write-back stage 2019-04-06 12:38:54 -07:00
Charles Papon
ffafc27104 Merge branch 'linuxDev' into linux 2019-04-06 02:01:08 +02:00
Charles Papon
6df3e57843 workaround Verilator comparaison linting 2019-04-06 02:00:47 +02:00
Charles Papon
21b4ae8f2f update todo, nothing todo ? everything done ? 2019-04-06 01:42:01 +02:00
Charles Papon
e7f3dd5553 Rework CsrPlugin exception delegation 2019-04-05 23:40:39 +02:00
Charles Papon
ddf0f06834 Add more delegation tests
Reduce dcache test duration
2019-04-05 22:56:12 +02:00
Charles Papon
acaa931e11 Rework CsrPlugin interrupt delegation 2019-04-05 22:55:42 +02:00
Charles Papon
9e72971ff0 Move user mode page fault checkes from iBus/dBus plugin into the MmuPlugin
SUM was in fact already supported
2019-04-05 21:34:44 +02:00
Charles Papon
82c894932a update todolist 2019-04-05 20:04:28 +02:00
Charles Papon
aeb418a99e Add dcache tests 2019-04-05 20:03:22 +02:00
Charles Papon
5a6665e57f Fix DataCache flush on the last line 2019-04-05 20:02:57 +02:00
Charles Papon
8459d423b8 add icache flush test 2019-04-05 18:11:33 +02:00
Charles Papon
60a41bfc75 rework i$ flush 2019-04-05 18:11:10 +02:00
Charles Papon
f5d4e745c7 Look like precise fence.i isn't required in practice 2019-04-05 18:08:25 +02:00
Charles Papon
446e9625af Centralised all todo in linux.scala
Sorted out fence fence.i instruction in iBus/dBus plugins.
Fixed MMU permitions while in used mode and bypassing the MMU
2019-04-05 12:17:29 +02:00
Charles Papon
888e1c0b8a Fix RVC instruction cache xtval allignement 2019-04-05 01:08:57 +02:00
Charles Papon
8e6010fd71 Got the debug plugin working with the linux config (had to disable CSR ebreak) 2019-04-05 00:25:27 +02:00
Charles Papon
4f0a02594c Change LR/SC to reserve the whole memory
Fix MPP access from other plugins
Got all the common configuration to compile and pass regression excepted the debugger one
First synthesis results
2019-04-04 20:34:35 +02:00
Charles Papon
f8b438d9dc cleaning 2019-04-04 12:59:08 +02:00
Charles Papon
de1c9c6fea Removing D$ reports 2019-04-03 14:47:00 +02:00
Charles Papon
3f7a859e07 Got multiway I$ D$ running linux fine. 2019-04-03 14:33:35 +02:00
Charles Papon
922c18ee49 Add data cache flush feature 2019-04-03 15:56:58 +02:00
Charles Papon
066f562c5e Got the MMU refilling itself with datacache cached memory access instead of io accesses 2019-04-03 14:32:21 +02:00
Charles Papon
8be40e637b #60 Got the new data cache design passing all tests and running linux 2019-04-02 23:44:53 +02:00
Charles Papon
fd4da77084 #60 Got the new instruction cache design passing the standard regressions 2019-04-02 00:26:53 +02:00
Charles Papon
bc0af02c97 #60 Got instruction cache running linux :D 2019-04-01 11:59:04 +02:00
Charles Papon
1dff9aff8a #60 Fix interrupt causing fetch privilege issues 2019-04-01 10:47:54 +02:00
Charles Papon
e74a5a71eb Better simulation console integration 2019-04-01 10:31:55 +02:00
Charles Papon
369a3d0f5f #60 Sync everything, added much comment on the top of Linux.scala to help reproduce 2019-03-31 23:43:56 +02:00
Charles Papon
c7314cc606 Got buildroot login, userspace, commands working
Moved location of DTB, initrd. Will move again
Added getChar SBI in emulator
Added an QEMU mode in the emulator config.h, work with qemu riscv32 virt
2019-03-31 15:17:45 +02:00
Dolu1990
de500ad8f9 Add qemu command 2019-03-30 18:29:17 +01:00
Dolu1990
9383445e0b Add a qemu option (wip) 2019-03-30 18:26:44 +01:00
Charles Papon
1a36f2689d #60 Fix software model. Forgot physical address for on RVC instruction 2019-03-30 11:24:29 +01:00
Charles Papon
29980016f3 #60 Fix instruction fetch exception PC by forcing LSB to be zero 2019-03-30 10:10:25 +01:00
Dolu1990
9fff419346 Better fix 2019-03-29 09:18:44 +01:00
Dolu1990
391cff69d3 #60 should fix the first instruction fetch privilege after interrupt 2019-03-29 09:02:44 +01:00
Dolu1990
0c48729611 Sync impact less changes (asfar i know) 2019-03-29 08:43:15 +01:00
Dolu1990
ad27007c3c DBusSimplePlugin AHB bridge add hazard checking, pass tests 2019-03-28 11:41:49 +01:00
Dolu1990
53c05c31c7 IBusSimplePlugin AHB bridge fix, pass tests 2019-03-28 10:12:42 +01:00
Dolu1990
b0522cb491 Add AhbLite3 simulation config 2019-03-28 08:32:12 +01:00
Tom Verbeure
6038730e53 Merge branch 'master' of https://github.com/SpinalHDL/VexRiscv 2019-03-27 19:49:09 -07:00
Dolu1990
9ac4998478 Fix emulator nested exception redirection privilege 2019-03-28 00:38:38 +01:00
Dolu1990
ac06111163 Fix MMU MPRV, Fix emulator nested exception 2019-03-27 22:58:30 +01:00
Dolu1990
0bed511a6c Fix cacheless LR/SC xtval, did some SRC/ADD_SUB/ALU redesign 2019-03-27 18:58:02 +01:00
Dolu1990
43c3922a3d Add prerequired stuff 2019-03-27 10:55:20 +01:00
Dolu1990
f113946e66 Added a neutral LINUX_SOC for sim purposes 2019-03-27 10:53:41 +01:00
Dolu1990
b69c474fa2 #60 user space reached
/sbin/init: error while loading shared libraries: libm.so.6: cannot stat shared object: Error 38
2019-03-27 00:26:51 +01:00
Dolu1990
7a9f7c4fb9 Untested cacheless buses to AHB bridges 2019-03-26 16:30:53 +01:00
Dolu1990
94fc2c3ecf Fix some models missmatch
Add more SBI
Add hardware LR/SC support in dbus cacheless
2019-03-26 01:25:18 +01:00
Dolu1990
1c3fd5c38b Fix mprv and add it into the softare model 2019-03-25 12:03:32 +01:00
Dolu1990
1ec11dc03d Fix mprv 2019-03-25 11:47:56 +01:00
Dolu1990
c34f5413a3 Add MMU MPRIV for easier machinemode emulation #60 2019-03-25 10:30:13 +01:00
Dolu1990
d63c6818df
Merge pull request #67 from tomverbeure/manual
Some minor updated to the manual
2019-03-25 02:07:42 +01:00
Dolu1990
9d55283b3b Machine mode emulator 2019-03-25 02:00:19 +01:00
Tom Verbeure
3d5e941aef Merge branch 'master' of https://github.com/SpinalHDL/VexRiscv 2019-03-24 23:56:23 +00:00
Dolu1990
e28702eb40 Add PlicCost test 2019-03-24 12:17:39 +01:00
Dolu1990
6c0608f0dd #60
Add LitexSoC workspace / linux loading.
Need to emulate peripherals and adapte the kernel now.
Probably also need some machine mode emulation
Software time !
2019-03-24 10:52:56 +01:00
Dolu1990
d70f970b15
Merge pull request #66 from tomverbeure/IBusSimple_to_PipelinedMemoryBus
Add getPipelinedMemoryBusConfig()
2019-03-24 08:05:21 +01:00
Tom Verbeure
ea62fd0e16 Same thing for DBusSimpleBus. 2019-03-23 23:36:13 +00:00
Tom Verbeure
1afad4f240 Ignore vim backup files. 2019-03-23 22:34:22 +00:00
Tom Verbeure
95c3e436dc Make toPipelinedMemoryBus() just like the other busses 2019-03-23 22:32:48 +00:00
Dolu1990
0656a49332 Make xtval more compliant 2019-03-23 20:12:36 +01:00
Dolu1990
7159237104 Fix csrrs/csrrc for xip registers 2019-03-23 18:11:26 +01:00
Dolu1990
505bff6f45 CSR Plugin now implement interruptions as specified in the spec 2019-03-23 12:56:04 +01:00
Dolu1990
3652ede130 Add mdeleg tests 2019-03-23 11:41:10 +01:00
Dolu1990
9139b4d269 Restore all tests 2019-03-22 18:03:35 +01:00
Dolu1990
597336b491 MMU sum/mxr tested and ok, all seem finen 2019-03-22 17:11:55 +01:00
Dolu1990
f7b793b7bf Add SSTATUS.SUM/MXR feature, need testing 2019-03-22 15:49:36 +01:00
Dolu1990
e4cdc2397a MMU pass all test, need to and SUM and MXR and it's all ok 2019-03-22 14:52:49 +01:00
Dolu1990
2b458fc642 Added MMU superpage support, pass MMU tests 2019-03-22 12:23:47 +01:00
Dolu1990
af2acbd46e Got the new MMU design to pass simple tests #60 2019-03-22 01:10:17 +01:00
Tom Verbeure
59a2817e5c Update DecoderSimplePlugin manual. 2019-03-21 05:53:27 +00:00
Tom Verbeure
3f5605f22e Fix table. 2019-03-21 05:36:30 +00:00
Tom Verbeure
02a6312912 Update IBusCachedPlugin manual. 2019-03-21 05:34:15 +00:00
Tom Verbeure
b7ddd02fc6 IBusSimplePlugin README. 2019-03-21 05:17:07 +00:00
Dolu1990
ea56481ead Add supervisor CSR in the riscv golden model 2019-03-20 23:26:08 +01:00
Dolu1990
7cbe399f1f Fix some supervisor CSR access 2019-03-20 23:25:52 +01:00
Dolu1990
6f2e5a0eb7 goldenmodel Implement some of the supervisor CSR 2019-03-20 20:28:04 +01:00
Dolu1990
39b2803914 Fix some CsrPlugin flags issues 2019-03-20 20:27:47 +01:00
Dolu1990
6c2fe934fd Bring changes and fixies from @kgugala @daveshah1. Thanks guys ! 2019-03-20 16:27:35 +01:00
Dolu1990
130a69eeae Pass regressions machinemode with CSR config including Supervisor 2019-03-20 14:14:59 +01:00
Dolu1990
d205f88fb8 riscv golden model and RTL pass all current regressions
add RVC into the linux config
2019-03-20 12:17:43 +01:00
Dolu1990
3c66f7c58a goldenmodel now pass more machine mode CSR tests 2019-03-20 11:46:27 +01:00
Dolu1990
ee402ec5dc clearning 2019-03-20 01:16:39 +01:00
Dolu1990
3a38fe4130 Add mmu regresion blank project 2019-03-20 01:13:05 +01:00
Dolu1990
ccc3b63d7c Enable golden model check for all regressions
Need to implement missing CSR of the golden model
2019-03-20 01:12:03 +01:00
Dolu1990
8f22365959 Disable MMU in machine mode 2019-03-19 22:21:30 +01:00
Dolu1990
46f10bacb2
Merge pull request #64 from tomverbeure/MulSimple
MulSimplePlugin
2019-03-19 20:39:28 +01:00
Dolu1990
3fbc2f4458 Fix generation 2019-03-19 20:29:28 +01:00
Dolu1990
915db9d6c9 cleaning 2019-03-18 20:50:19 +01:00
Dolu1990
001ca45c57 Add cachless dBus IBus access right checks 2019-03-18 12:52:22 +01:00
Dolu1990
c490838202 Added MMU support into cacheless DBus IBus plugins (for testing purposes)
Probably full of bugs, need testing
2019-03-18 12:17:43 +01:00
Dolu1990
ffa489d211 hardware refilled MmuPlugin wip 2019-03-17 21:06:47 +01:00
Tom Verbeure
b63395435f SimpleMul core. 2019-03-16 15:44:18 +00:00
Tom Verbeure
5bc53c08ce Merge branch 'master' of https://github.com/SpinalHDL/VexRiscv into MulSimple 2019-03-16 15:39:07 +00:00
Dolu1990
03663ce91a Move unreleased SpinalHDL 2019-03-15 17:35:31 +01:00
Dolu1990
9a61ff8347 Merge remote-tracking branch 'origin/dev' 2019-03-10 11:14:09 +01:00
Dolu1990
2e0b63bc67 SpinalHDL 1.3.2 2019-03-10 11:12:43 +01:00
Dolu1990
bad60f39cd Fix Decoding benchmark 2019-03-10 11:12:32 +01:00
Dolu1990
434793711b fix part of #59 2019-02-26 17:26:42 +01:00
Dolu1990
b9922105f0 Fix readme demo path 2019-02-26 17:22:13 +01:00
Dolu1990
e0214056ce
Merge pull request #58 from mithro/patch-1
Fix image in README.
2019-02-23 09:22:38 +01:00
Tim Ansell
7594cbd902
Fixing images in README in iCE40-hx8k_breakout_board_xip directory too. 2019-02-22 14:57:07 -08:00
Tim Ansell
5c6cc29304
Fixing other image. 2019-02-22 14:55:18 -08:00
Tim Ansell
c9f4a09de0
Fix image in README. 2019-02-22 14:52:09 -08:00
Dolu1990
e0c8ac01d2 Add custom external interrupts 2019-02-03 15:20:34 +01:00
Dolu1990
11f55359c6 IBusCache can now avoid injectorStage in singleStage mode 2019-01-30 01:37:47 +01:00
Dolu1990
56e3321394 cpp regresion now print the time of failure 2019-01-30 01:36:24 +01:00
Dolu1990
285f6bb6ac
Update README.md
Remove JDK constraints
2019-01-29 12:35:12 +01:00
Dolu1990
f4598fbd0a Add tightly coupled interface to the i$ 2019-01-21 23:46:18 +01:00
Dolu1990
8f1b4cc8e5 Merge branch 'master' into dev 2019-01-16 16:32:12 +01:00
Dolu1990
b5caca54cd restore all feature in TestsWorkspace 2019-01-16 15:25:50 +01:00
Dolu1990
f4f854ae4f SpinalHDL 1.3.1 2019-01-14 13:32:16 +01:00
Dolu1990
dcdfa79024 fix run-main into runMain 2019-01-03 20:07:38 +01:00
Dolu1990
414d2aba54 Merge remote-tracking branch 'origin/dev' 2018-12-30 15:54:14 +01:00
Dolu1990
927ab6d127 Merge remote-tracking branch 'origin/master' into dev 2018-12-30 15:53:25 +01:00
Dolu1990
92065a1a10 Update to SpinalHDL 1.3.0 2018-12-30 15:51:46 +01:00
Dolu1990
dd42e30c61 Merge remote-tracking branch 'origin/master' into dev 2018-12-29 14:04:07 +01:00
Dolu1990
d617bafb08 Roll back VexRiscvAvalonForSim to use caches 2018-12-25 00:15:23 +01:00
Dolu1990
1da055dc34
Merge pull request #49 from cutephoton/avalon
Avalon: Debug Clock Domain for JTAG
2018-12-23 16:27:50 +01:00
Brett Foster
961abb3cf1 Avalon: Debug Clock Domain for JTAG
This change ensures that the clock domain for the JTAG interface
uses the debug plugin's domain. Otherwise, resetting the processor
will put the jtag debugger in to reset as well.

See SpinalHDL/VexRiscv#48
2018-12-22 07:58:59 -08:00
Dolu1990
76ebfb2243 Fix machine mode to supervisor delegation 2018-12-10 13:15:03 +01:00
Dolu1990
d9029c2efc Fix #46 by filling missing return statements 2018-12-10 01:44:47 +01:00
Dolu1990
281d61bbe1 regression fix hex << dec #46 2018-12-09 16:37:16 +01:00
Dolu1990
1fbb81a4d9 regression fix delete [] #46 2018-12-09 15:40:02 +01:00
Dolu1990
cf80c63c22 fix travis 2018-12-08 15:16:17 +01:00
Dolu1990
f121ce1ed5 add sanity asserts in regression #46 2018-12-08 14:10:18 +01:00
Dolu1990
9330945623 fix regression makefile 2018-12-07 23:50:13 +01:00
Dolu1990
52419fd7ad Regression remove dplus stuff #46 2018-12-07 23:47:49 +01:00
Dolu1990
68fdbe60cc verilator regression fix missing fclose #46 2018-12-07 23:43:19 +01:00
Dolu1990
6334f430fe
Update README.md
Fix #44
2018-12-04 19:07:51 +01:00
Dolu1990
eca54585b0 Fix hardware breakpoint 2018-12-04 16:57:24 +01:00
Dolu1990
ac1ed40b80 Move things into SpinalHDL lib 2018-12-01 18:25:18 +01:00
Dolu1990
3d71045159 DebugPlugin doesn't require memory/writeback stage anymore 2018-12-01 18:24:33 +01:00
Dolu1990
58d7a4784d move HexTools into SpinalHDL lib 2018-11-30 17:39:33 +01:00
Dolu1990
b1b7da4f10 Rename SimpleBus into PipelinedMemoryBus
Move PipelinedMemoryBus into SpinalHDL lib
2018-11-30 17:37:17 +01:00
Tom Verbeure
ae85698a2b MulSimple 2018-08-09 22:15:26 -07:00
344 changed files with 81281 additions and 9146 deletions

69
.github/workflows/scala.yml vendored Normal file
View file

@ -0,0 +1,69 @@
name: Scala CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-v2
restore-keys: |
${{ runner.os }}-pip-
- name: Cache SBT
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
- name: Cache tools
id: tools
uses: actions/cache@v2
with:
path: |
~/tools
key: ${{ runner.os }}-tools_v4
- name: Setup env
run: echo "$HOME/tools/bin" >> $GITHUB_PATH
- name: Install cached tools
if: steps.tools.outputs.cache-hit != 'true'
run: source tools.sh && (cd ~/ && install_verilator)
- name: Install uncached tools
run: (cd .. && git clone https://github.com/SpinalHDL/SpinalHDL.git -b dev)
- name: Compile tests
run: sbt "+test:compile"
- name: Test Dhrystones
run: make regression_dhrystone -C scripts/regression
- name: Test Baremetal
run: make regression_random_baremetal -C scripts/regression
- name: Test Machine OS
run: make regression_random_machine_os -C scripts/regression
- name: Test Linux
run: make regression_random_linux -C scripts/regression

9
.gitignore vendored
View file

@ -1,6 +1,7 @@
*.class
*.log
*.bak
.*.swp
# sbt specific
.cache/
@ -24,6 +25,7 @@ out
bin/
.classpath
.project
.cproject
.settings
.cache-main
@ -33,17 +35,22 @@ bin/
*.cf
*.json
*.vcd
*.fst*
!tester/src/test/resources/*.vhd
obj_dir
*.logTrace
*.yaml
*.memTrace
*.regTrace
*.debugTrace
*.tcl
*.o
*.bin
explor
mill
simWorkspace/
tmp/
/archive.tar.gz
*.out32
*.out32

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "src/test/resources/VexRiscvRegressionData"]
path = src/test/resources/VexRiscvRegressionData
url = https://github.com/SpinalHDL/VexRiscvRegressionData.git

View file

@ -1,64 +1,89 @@
language: scala
dist: xenial
notifications:
email:
on_success: never
# See 'project/Version.scala'
scala:
- 2.11.6
- 2.11.12
sbt_args: -no-colors -J-Xss2m
script:
- export VEXRISCV_REGRESSION_CONFIG_COUNT=100
- export VEXRISCV_REGRESSION_FREERTOS_COUNT=no
- sbt -jvm-opts travis/jvmopts.compile compile
- sbt -jvm-opts travis/jvmopts.test test
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- git
- make
- autoconf
- g++
- flex
- bison
jdk:
- oraclejdk8
# - oraclejdk7
# - openjdk7
- openjdk10
env:
- secure: "v7FHP8yK/zixpv1ML05qcRhZfDVDFdTmTPjfMZHL7gmrJveVDgze22x4tY4tB1+JEXhKuVTYvimOrX/Ok+rOOT5gVKLowv4PUQwCR+HgWVIbqjcfZNLsa369v03/p4K/zbjJSiXFahZYOXa0ApED2KWHcVfCrNsPv0UF7YZGiIa1Q/lPBwfmpN1rLih2Mpgn4KVaJky22t7JXJyVrNdGVmIA51slVbyFwFAE8Ww/0tkC+i2PUcWWRMIxtXP4iyq/9Npcq5VdqOatKfWHqAElLfKSPNMYLMlcyxyNpNx4paq8cL6fQxFcBLi9M2msz2i/qpKv30a0tzNo5bQQgucAXOQJB2Buks728upLuqsr+k25hwcqrtjyMOr9UQkt7qXAJH/0kimW7aW1yoMxbm/6mNG98X9D1EzNRewHAKatwJeFy1bw5qIuSQxPBwQMGloManrHOHGotmHKk7Y+dgM/z1UlaAdxSQuKWGXBc8QlQvif8puPYEdJMoInJNRxiWfYu06XnmzTXgMketK7RdULM9DVYzw8hzS2EIWKu8Oa0zn0PTevD2YeJNd4G8mDqO0vz5hloIc7pFsq/exQUB/kFozfCsnvhW8P+MPN0LpuSpptBQTsLWbM5BH0hd46HoWcneDdlMvVrUcgsTPmmSroIkLIEUo+Y2iN5eQHPPp85Cw="
jobs:
include:
- stage: prepare cache-verilator
script:
- cp scripts/regression/verilator.mk $HOME/makefile
- cd $HOME
- make verilator_binary
- &test
stage: Test
name: Dhrystone
script:
- make regression_dhrystone -C scripts/regression
- <<: *test
stage: Test
name: Baremetal
script:
- make regression_random_baremetal -C scripts/regression
- <<: *test
stage: Test
name: Machine OS
script:
- make regression_random_machine_os -C scripts/regression
- <<: *test
stage: Test
name: Machine OS
script:
- make regression_random_machine_os -C scripts/regression
- <<: *test
stage: Test
name: Mixed
script:
- make regression_random -C scripts/regression
- <<: *test
stage: Test
name: Linux
script:
- make regression_random_linux -C scripts/regression
- <<: *test
stage: Test
name: Linux
script:
- make regression_random_linux -C scripts/regression
before_install:
# JDK fix
- cat /etc/hosts # optionally check the content *before*
- sudo hostname "$(hostname | cut -c1-63)"
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
- cat /etc/hosts # optionally check the content *after*
- cd ..
# Verilator
- sudo apt-get install git make autoconf g++ flex bison -y # First time prerequisites
- git clone http://git.veripool.org/git/verilator # Only first time
- unset VERILATOR_ROOT # For bash
- cd verilator
- git pull # Make sure we're up-to-date
- git checkout verilator_3_916
- autoconf # Create ./configure script
- ./configure
- make -j$(nproc)
- sudo make install
- cd ..
- git clone https://github.com/SpinalHDL/SpinalHDL.git
- git clone https://github.com/SpinalHDL/SpinalHDL.git -b dev
- cd VexRiscv
#- curl -T README.md -udolu1990:$BINTRAY_KEY https://api.bintray.com/content/spinalhdl/VexRiscv/test/0.0.4/README.md
#- curl -X POST -udolu1990:$BINTRAY_KEY https://api.bintray.com/content/spinalhdl/VexRiscv/test/0.0.4/publish
#- sbt compile
- export VERILATOR_ROOT=$HOME/verilator
- export PATH=$VERILATOR_ROOT/bin:$PATH
before_cache:
# Tricks to avoid unnecessary cache updates
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete
- rm -fv $HOME/.ivy2/.sbt.ivy.lock
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
- find $HOME/.sbt -name "*.lock" -print -delete
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
- $HOME/.sbt
- $HOME/verilator

899
README.md

File diff suppressed because it is too large Load diff

BIN
assets/fpuDesign.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

View file

@ -1,46 +1,20 @@
//name := "VexRiscv"
//
//organization := "com.github.spinalhdl"
//
//version := "1.0.0"
//
//scalaVersion := "2.11.6"
//
//EclipseKeys.withSource := true
//
//libraryDependencies ++= Seq(
// "com.github.spinalhdl" % "spinalhdl-core_2.11" % "1.2.1",
// "com.github.spinalhdl" % "spinalhdl-lib_2.11" % "1.2.1",
// "org.scalatest" % "scalatest_2.11" % "2.2.1",
// "org.yaml" % "snakeyaml" % "1.8"
//)
//
//
//
//addCompilerPlugin("org.scala-lang.plugins" % "scala-continuations-plugin_2.11.6" % "1.0.2")
//scalacOptions += "-P:continuations:enable"
//fork := true
val spinalVersion = "1.10.2a"
lazy val root = (project in file(".")).
settings(
inThisBuild(List(
organization := "com.github.spinalhdl",
scalaVersion := "2.11.6",
version := "1.0.0"
scalaVersion := "2.12.18",
version := "2.0.0"
)),
libraryDependencies ++= Seq(
"com.github.spinalhdl" % "spinalhdl-core_2.11" % "1.2.2",
"com.github.spinalhdl" % "spinalhdl-lib_2.11" % "1.2.2",
"org.scalatest" % "scalatest_2.11" % "2.2.1",
"org.yaml" % "snakeyaml" % "1.8"
"com.github.spinalhdl" %% "spinalhdl-core" % spinalVersion,
"com.github.spinalhdl" %% "spinalhdl-lib" % spinalVersion,
compilerPlugin("com.github.spinalhdl" %% "spinalhdl-idsl-plugin" % spinalVersion),
"org.scalatest" %% "scalatest" % "3.2.17",
"org.yaml" % "snakeyaml" % "1.8"
),
name := "VexRiscv"
)/*.dependsOn(spinalHdlSim,spinalHdlCore,spinalHdlLib)
lazy val spinalHdlSim = ProjectRef(file("../SpinalHDL"), "SpinalHDL-sim")
lazy val spinalHdlCore = ProjectRef(file("../SpinalHDL"), "SpinalHDL-core")
lazy val spinalHdlLib = ProjectRef(file("../SpinalHDL"), "SpinalHDL-lib")*/
)
addCompilerPlugin("org.scala-lang.plugins" % "scala-continuations-plugin_2.11.6" % "1.0.2")
scalacOptions += "-P:continuations:enable"
fork := true
fork := true

28
build.sc Normal file
View file

@ -0,0 +1,28 @@
import mill._, scalalib._
val spinalVersion = "1.10.1"
object ivys {
val sv = "2.11.12"
val spinalCore = ivy"com.github.spinalhdl::spinalhdl-core:$spinalVersion"
val spinalLib = ivy"com.github.spinalhdl::spinalhdl-lib:$spinalVersion"
val spinalPlugin = ivy"com.github.spinalhdl::spinalhdl-idsl-plugin:$spinalVersion"
val scalatest = ivy"org.scalatest::scalatest:3.2.5"
val macroParadise = ivy"org.scalamacros:::paradise:2.1.1"
val yaml = ivy"org.yaml:snakeyaml:1.8"
}
trait Common extends ScalaModule {
override def scalaVersion = ivys.sv
override def scalacPluginIvyDeps = Agg(ivys.macroParadise, ivys.spinalPlugin)
override def ivyDeps = Agg(ivys.spinalCore, ivys.spinalLib, ivys.yaml, ivys.scalatest)
override def scalacOptions = Seq("-Xsource:2.11")
}
object VexRiscv extends Common with SbtModule{
override def millSourcePath = os.pwd
override def moduleDeps: Seq[JavaModule] = super.moduleDeps
object test extends SbtModuleTests with TestModule.ScalaTest
}

1
doc/diagram.drawio Normal file
View file

@ -0,0 +1 @@
<mxfile host="Electron" modified="2022-10-26T08:46:23.573Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/16.5.1 Chrome/96.0.4664.110 Electron/16.0.7 Safari/537.36" etag="UNzW2AFYAA4diG_noPwE" version="16.5.1" type="device"><diagram id="U7yDgwaCbtEdI7JvCxo2" name="Page-1">7VxtV6s4EP41/aiH99KPSvWuu3WPR929ez9GSEv2UtINwbb3128CAQppC9am1VqPR8mQTMMzzyQzYbRnetPFNwJm4T0OYNQztGDRM4c9w3Asl/3kgqUQaGYumBAU5CK9EjyhX1AINSFNUQCTWkeKcUTRrC70cRxDn9ZkgBA8r3cb46j+qTMwgZLgyQeRLP2OAhrmUtfWKvlvEE3C4pN1TdyZgqKzECQhCPB8RWTe9EyPYEzzq+nCgxHHrsAlH3e74W45MQJj2mXAMHwxk/tnL70xvNtbPe6nf/y6EFpeQZSKB+4ZTsT0XSczEPNZ06WAwvkv5VO9HuOYXiSZoa5YB92YLaqb7GrCf99C6oeFKjanXFt+T8BRKjYITuMA8mnq7PY8RBQ+zYDP784ZqZgspNNI3OYfL2ji8mlSgn+WpuEdApCEpTLeeACUQhJnEjbfcgavkFC42IimXtqIcRviKaRkybqIAaYlzCp4bZuiPa9Y4ghRuEKQgg1A8HJSaq5Mxy6E9d5gSVOy5N9w8YgS//VqgawRitPFQ4R8L0LsAZsWYDjQEkwPR5gweYxjyAFHUdQQgQhNOJ4RHPNhHEjEXOZKiKcoCLhmziEfxZNR1m1oVZJHAQgXYTZ8HGWeEbKBkGm4nmE2ywwh+5p9M8w87dLu2WyuHmvrVZt98+6Eejhm0wcoMx8ECZ3DhE+OYAooeMmeVCv4I55c3wMRDLdOBGsgE0F31zDBVMUES2LCXc+wtnid1u51ewDK0ts9xjikx9gSTsMPidMaQq3DyVWFk6NojxhCn0ULX2qTcI68SfQVmfJmAf2Ufi1brnHLg9rSVWTLezjFfHpfx5SOcWRTDhSZ8jth5ngB/s8vZU37yNYs9u+NMQSLVkM8wTGIRhjPBD7/QkqXAk6QUlzHmmFBlv/w8SzsFc0fQl3WGC5qrWXRWiC6Moy1fhQa2XU1iDfKMXFwxTPnXhnvM8kt4iBk9/Ong4GUODcsxhDAKfHhNqjyfhSQCaRtIYjMAAIjQNFrfR7r7CmGPuAs+SkjLWNwadcXdatBivwJxLjV5LqpypJUOQ1V+UNKqjKKlc/0DtbpZ9Z1ZJ3TkXV9Jawz3Q1B4Vs5JynqH5hxxplxHRnX78g49zCMG+yJcY52YMaZZ8Z1ZJzbkXGDgzDOaQZbOzOueWqmmnFt50HvYlyNbxX9Whinr/CtYt/RGdc1lrPOu+pWxjkKGXehXWr6oE473TgG8bJPeIAEMbwgOd6Oa5933K1s7Ktg437WpP3ng1oD7F3XkOYRvqRItdVUHSjd3/91ykdJVoeDQfOQR0mGyqOksvG28KO4/mjhx+CoK77k8vrOa8fg0tEH1dd2tYpXkgKIva8k3tPjKa8kxmBDALCyklgHXUnk+pCH0Z3Xsryof9vdBGrdkntYoOTyCW909+fzh0Nq3cvkwyJlq9icWtKGnVKR3fLtPW5ORtfkWM2Rs7Q5NXPazpuT0aJI9XakMjn+RAeA+09Ym0VHzWqizgnrpuqlQzFEScJ6Zohk2J0DXElRc4NSzRBVhTND+JJOTjmolSoTjx2BmCrS4zVp7naXPZpLWmbDk+zBpWvuuLPb7boUO6YppyjBdZpIJuZIj8ALjOqGK4rSfYY6P1HeXJZOIHPllZLwerX5cJuziD8zEYN7JbVXjb2Fqhtdi20RfU0EN+9khe7WR+DxOIFqDKbi5djndT/bZC7jauVXQ+GuntiiVrVTylXy6HSccsO7yE/tlO6Xdkqj34wumfc4u3mifDYl61LtfvKbnFmE/DvuTSSlp+KHG+qe9u+HF1bDfuoc0VJakPm2o6wPXjqiqLx3f69kjlsSYqk403jzkt7Gh4ShQIsefgSSBPmFWHTTj7kzSHGV845sqd+uSzUp5GOM35+vvp3GhmBtOAf/mIEZa1Z/xp93r/4XgnnzPw==</diagram></mxfile>

592
doc/gcdPeripheral/README.md Normal file
View file

@ -0,0 +1,592 @@
# Tutorial on Implementing a Peripheral for the VexRiscv Based Murax SoC
**By**
**Sallar Ahmadi-Pour - Researcher, University of Bremen, Group of Computer Architecture**
[http://www.informatik.uni-bremen.de/agra/projects/risc-v/](http://www.informatik.uni-bremen.de/agra/projects/risc-v/)
[http://www.informatik.uni-bremen.de/agra/](http://www.informatik.uni-bremen.de/agra/)
## 1. Introduction
Traditional hardware design often requires using languages like VHDL and Verilog and tooling that don't catch errors that can be caught with static analysis of the design. Additionally, information developers receive from the tools is scarce and often lead inexperienced developers on an odyssey. Currently emerging tools (Verilator, Yosys, etc.) for hardware design and languages for hardware description (SpinalHDL, Amaranth, etc.) tackle these and other existing issues.
Projects like SpinalHDL and the thereon based highly configurable VexRiscv processor experience a rise in popularity and usage amongst academic and commercial users. The increased popularity also requires an increase in educational resources. Due to the specific popularity in the academic environment it only seems natural that researchers document their approaches and insights (not only in peer reviewed publications in a journal). This will allow the next generation of hardware designers to extend and explore big projects like VexRiscv.
## 2. Our Goal for this Tutorial
Murax SoC is a VexRiscv configuration that is a very lightweight RISC-V platform.
It features a basic set of peripherals (UART, GPIO, Prescalers and Timers) around a pipelined memory bus and Apb3 peripheral bus.
The Murax SoC features enough to more than a toy system and being small and thus offering space for extension.
For the choice of possible algorithms, that we want to describe in hardware rather than software, the algorithm for calculating the Greatest Common Divisor (GCD) is a good example to start off. There are many digital design resources available on designing a GCD module.
We will add the hardware peripheral module to the Murax on the Apb3 bus with memory mapped registers to control the module and transfer the data around for the calculation.
In this way we transfer the resources the software to the hardware implementation.
The aspects we will shed some light upon will be
a) How do we implement an algorithm that we know from the software domain in a hardware implementation suited for FPGAs?
b) How do we prepare and integrate a new peripheral into the Murax domain and map its control and data ports via memory mapped registers?
c) How do we extend the software to use the peripheral easily in our baremetal code?
For a) we will start off the pseudocode of the GCD and work our way to a hardware implementation in SpinalHDL.
We will evaluate that design in a SpinalHDL testbench with Verilator as the simulation backend and drive the testbench with randomly generated values which we compare to a software implementation of the same algorithm.
For b) we will look into the features of SpinalHDL and the structure of the Murax SoC to get an idea where and how to integrate our peripheral.
Before adding the peripheral into the Murax we also need to decide on the details of memory mapping our control and data ports to memory mapped registers (i.e, addresses, write/read/clear modes, etc.).
At the end there is a small list of possible extensions from which anyone can continue with their own additions.
## 3. GCD HW Implementation
Let us start the HW implementation by looking at some kind of specification.
```c
// Pseudocode of the Euclids algorithm for calculating the GCD
inputs: [a, b]
outputs: [ready, a]
ready := False
while(!ready):
if(a > b):
a := a - b
else if(b > a):
b := b - a
else:
ready := True
```
The pseudocode shows the GCD algorithm we want to implement in hardware.
Implementing algorithms in hardware in the Register Transfer Level (RTL) style will require you to separate the control path (so if, else, while, for) and the data path (moving, calculating and comparing data).
Inevitably results from data and comparisons affect the control flow and the control flow affects the data flow.
Thus the two paths need to communicate the shared information.
But let us start at defining the interface of our module that will calculate the GCD.
![GCD Top Diagram](./img/murax-gcd-diagrams-gcd.png)
Our pseudocode already defines some in- and outputs that can aid us in defining the interface for our module.
At this point we don't want to think about which bus we connect our module to (APB, AXI, Wishbone, etc.).
We take care about that part later.
We simply know we have our input integers A and B, a signal to indicate the start of the calculation, the result and a signal indicating the completion of the calculation.
We choose 32 bit integers and use a valid-ready mechanism (we add a valid signal to kick of the calculation).
The interface features the values A, B and result as the data signals, valid and ready are control signals.
Signals for reset and clock are omitted for readability (unless explicitly used these are handled by SpinalHDL internally anyways).
From this top level perspective we can describe the behavior as follows: Once we apply a set of operands A and B and then apply the valid signal the module calculates the GCD for a variable amount of clock cycles.
We know the result is ready and can be read once the ready signal is asserted.
Inside the GCD module we will have two other modules: the data path GCDData and the control path GCDCtrl.
We notice again, the data signals (opA, opB and result) belong to our data path and the control signals (valid and ready) belong to our control path.
![GCD top level block diagram](./img/murax-gcd-diagrams-gcd-dp+cp.png)
The data path will consist of some basic RTL blocks like multiplexers, a subtraction, comparators and registers.
The elements are connected and arranged such that they represent the dataflow of the algorithm.
Parts of the data path are enabled by the control path.
The control path will be represented by a Finite State Machine (FSM), which orchestrates the data paths calculation of the result.
![GCD data path](./img/murax-gcd-diagrams-gcd-datapath.png)
The diagram of the data path shows the processing elements for our algorithm in hardware, with their control input and outputs respectively.
From this we can already see what the interface towards the control path looks like.
The control path needs to know the results of the comparisons.
Vice versa the data path gets controlled through selecting the subtract operands (or more precisely their order), the register enables and an initiation signal for a defined start state.
In the data path, the D-Flipflops (DFF) hold the values A and B that are used for the calculation and they change value throughout the computation.
A subtraction which is set up for a computation such that `r = x - y` with x being the "left" and y being the "right" operand.
The left and right operands are multiplexed from our control path inputs.
Two comparators compute the greater than (cmpAgtB) and less than (cmpAltB) operation.
The result, the GCD of A and B, will be available in the A register after the calculation is done.
Completion of the calculation is signaled by the control path.
![GCD control path](./img/murax-gcd-diagrams-gcd-controlpath.png)
In the diagram of the control path we see the same interface (with inverse directions — this information will be helpful later in SpinalHDL).
The interface of the control path are the top level valid signal, the ready signal indicating the finished computation, the results of the two comparisons `A > B` (*cmpAgtB*) and `B > A` (*cmpAltB*).
Initially the FSM is in an idle state, waiting for the valid signal to be asserted, on exit of this state, the init signal is set to 1 to clock in the values of A and B into their respective registers.
Similar to the pseudocode the FSM loops for the calculation and based on the comparators of the data path and orchestrates the data path to calculate either `a := a - b` or `b := b - a`.
If both if the comparators outputs are 0, the end of the calculation is reached.
Within the `calcDone` state the `ready` signal is set to 1.
With the entry of the `idle` state the module becomes ready to calculate another GCD.
The control path drives all the outputs based on the state in the state machine (Moore FSM).
The guards on the transitions show the condition with which the respective transition occurs.
These block diagrams, digital logic and the FSM can be quickly implemented in SpinalHDL, things like the `DataControlIF` that interconnect between the data path and control path can be quickly created and connected in SpinalHDL as well.
## 4. SpinalHDL implementation
First we can take a look at the interface between the data and control path.
```scala
// in GCDTop.scala
case class GCDDataControl() extends Bundle with IMasterSlave{
val cmpAgtB = Bool
val cmpAltB = Bool
val loadA = Bool
val loadB = Bool
val init = Bool
val selL = Bool
val selR = Bool
override def asMaster(): Unit = {
out(loadA, loadB, selL, selR, init)
in(cmpAgtB, cmpAltB)
}
}
```
We can define a Bundle that implements the `IMasterSlave` Interface (see the [Bundle documentation](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Data%20types/bundle.html?highlight=master%20slave#master-slave)), which allows us to use a operator (`<>`) to interconnect modules and their signals without explicitly describing each wire and connection (other than inside the Bundle from above).
In the Bundle we can define the signals with their types.
We override the `asMaster()` Method (line 10 to 13) from the `IMasterSlave` interface.
In the `asMaster()` Method we define the signal direction from the point of view of the control path.
Thus `cmpAgtB` and `cmpAltB` are inputs and `loadA`, `loadB`, `selL`, `selR`, `init` are outputs.
SpinalHDL will infer the directions for the data path side when we will use the `<>`-Operator.
With that our top level module will look very tidy:
```scala
// in GCDTop.scala
class GCDTop() extends Component {
val io = new Bundle {
val valid = in Bool()
val ready = out Bool()
val a = in(UInt(32 bits))
val b = in(UInt(32 bits))
val res = out(UInt(32 bits))
}
val gcdCtr = new GCDCtrl()
gcdCtr.io.valid := io.valid
io.ready := gcdCtr.io.ready
val gcdDat = new GCDData()
gcdDat.io.a := io.a
gcdDat.io.b := io.b
io.res := gcdDat.io.res
gcdCtr.io.dataCtrl <> gcdDat.io.dataCtrl
}
```
Lines 2 to 8 define the input/output Bundle inline, lines 9 and 12 instantiate the control and data path. All other lines are interconnecting the IO signals. Note in line 16 we interconnect the control and data path by using the `<>`-Operator as they use the shared interface description from earlier as a input (called `dataCtrl` in the design). We will see this in the respective modules input/output bundles.
Our data path in SpinalHDL looks like this:
```scala
// in GCDData.scala
class GCDData() extends Component {
val io = new Bundle {
val a = in(UInt(32 bits))
val b = in(UInt(32 bits))
val res = out(UInt(32 bits))
val dataCtrl = slave(GCDDataControl())
}
//registers
val regA = Reg(UInt(32 bits)) init(0)
val regB = Reg(UInt(32 bits)) init(0)
// compare
val xGTy = regA > regB
val xLTy = regA < regB
// mux
val chX = io.dataCtrl.selL ? regB | regA
val chY = io.dataCtrl.selR ? regB | regA
// subtract
val subXY = chX - chY
// load logic
when(io.dataCtrl.init){
regA := io.a
regB := io.b
}
when(io.dataCtrl.loadA){
regA := subXY
}
when(io.dataCtrl.loadB){
regB := subXY
}
io.dataCtrl.cmpAgtB := xGTy
io.dataCtrl.cmpAltB := xLTy
io.res := regA
}
```
Lines 2 to 7 show the Bundle for the IO signals. Note the signal in line 6 (`dataCtrl`), we use the defined Bundle from earlier and give it the direction `slave()` instead `in()` or `out()`.
This tells SpinalHDL to infer the directions of the Bundle signals according to the `asMaster()` method (in that case the inverse directions).
We will see this again in the control path.
The rest of the module (or components, thats how SpinalHDL modules are called) consists of defining signals, registers, and behavior.
Registers can be defined through a `Reg()` components that takes a type and optionally a reset value (via `init()`).
We can write to the register in our `when()` Blocks which could be interpreted as the enable signals for the registers.
(* Side note: technically we describe a multiplexing onto each register as we have multiple cases of enables and different data sources, but we can abstract from that in SpinalHDL a bit and keep it in the back of our minds*).
Now for the control path of our GCD module:
```scala
// in GCDCtrl.scala
class GCDCtrl() extends Component {
val io = new Bundle {
val valid = in Bool()
val ready = out Bool()
val dataCtrl = master(GCDDataControl())
}
val fsm = new StateMachine{
io.dataCtrl.loadA := False
io.dataCtrl.loadB := False
io.dataCtrl.init := False
io.dataCtrl.selL := False
io.dataCtrl.selR := False
io.ready := False
val idle : State = new State with EntryPoint{
whenIsActive{
when(io.valid){
io.dataCtrl.init := True
goto(calculate)
}
}
}
val calculate : State = new State{
whenIsActive{
when(io.dataCtrl.cmpAgtB){
goto(calcA)
}.elsewhen(io.dataCtrl.cmpAltB){
goto(calcB)
}.elsewhen(!io.dataCtrl.cmpAgtB & !io.dataCtrl.cmpAgtB){
goto(calcDone)
}
}
}
val calcA : State = new State{
whenIsActive{
io.dataCtrl.selR := True
io.dataCtrl.loadA := True
goto(calculate)
}
}
val calcB : State = new State{
whenIsActive{
io.dataCtrl.selL := True
io.dataCtrl.loadB := True
goto(calculate)
}
}
val calcDone : State = new State{
whenIsActive{
io.ready := True
goto(idle)
}
}
}
}
```
The lines 2 to 6 show the input/output signals again, and this time the `dataCtrl` signal, at line 5, shows the direction as `master()`.
This will apply the directions that we set in the first code snipped.
SpinalHDL offers a library to build FSMs and since this module is only that, our control path is descriptive.
We set default values for outputs (lines 8 to 13) and apply the according value in the respective state.
The API for FSMs in SpinalHDL offers much more than we use here.
In each state we can describe actions for `onEntry`, `onExit`, `whenIsNext` and for `whenIsActive` phases (see the [State Machine documentation](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Libraries/fsm.html)).
The `onEntry` phase refers to the cycle before entering the state, `onExit` will be executed if the next cycle will be in a different state, and `whenIsNext` will be executed if the state machine will be in that state in the next cycle.
That resembles the capabilities of FSM we have in UML/SysML or in StateCharts.
There is also the possibility to nest FSMs hierarchically or have delay states for a certain amount of cycles.
Describing these things in classic HDL is a lot of boilerplate that SpinalHDL can generate for us instead.
But with these modules we can already run some first simulations, testing our design for functionality.
And as traditional HDLs go we need a testbench for this.
This applies to SpinalHDL as well.
The default way for [simulation in SpinalHDL](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Simulation/index.html) is by writing a testbench with SpinalHDL and Scala and then getting it simulated through Verilator.
Verilator compiles our HDL (generated from SpinalHDL) to a C++ simulation model, our testbench interacts with that and thus we can have a fast simulation at hand.
Lets jump straight into the simulation testbench and see how SpinalHDL aids our work here:
```scala
// in GCDTopSim.scala
object GCDTopSim {
def main(args: Array[String]) {
SimConfig.doSim(new GCDTop()){dut =>
def gcd(a: Long,b: Long): Long = {
if(b==0) a else gcd(b, a%b)
}
def RndNextUInt32(): Long = {
ThreadLocalRandom.current().nextLong(Math.pow(2, 32).toLong - 1)
}
var a = 0L
var b = 0L
var model = 0L
dut.io.a #= 0
dut.io.b #= 0
dut.io.valid #= false
dut.clockDomain.forkStimulus(period = 10)
dut.clockDomain.waitRisingEdge()
for(idx <- 0 to 50000){
a = RndNextUInt32()
b = RndNextUInt32()
model = gcd(a,b)
dut.io.a #= a
dut.io.b #= b
dut.io.valid #= true
dut.clockDomain.waitRisingEdge()
dut.io.valid #= false
waitUntil(dut.io.ready.toBoolean)
assert(
assertion = (dut.io.res.toBigInt == model),
message = "test " + idx + " failed. Expected " + model + ", retrieved: " + dut.io.res.toBigInt
)
waitUntil(!dut.io.ready.toBoolean)
}
}
}
}
```
In line 3 we basically setup our Design Under Test (DUT), and we could setup some other simulations options like generating the VCD wavetrace.
We want to generate some arbitrary amount of testcases and compare the results against a (different) implementation of the GCD algorithm in software.
Doing this for enough random cases can give confidence in the design, tho it will not always cover edge cases and other aspects that are covered by a constrained random approach, white box testing or formal methods to verify our design.
Lines 4 to 6 are our (recursive) software implementation.
Lines 7 to 9 generate a random number in the range of a UInt32 — we have to do this by hand because of the nature of Java, Scala and SpinalHDL and how they interact with each other when it comes to numeric values and types.
Lines 10 to 15 setup our input for the DUT and in line 17 and 18 we set up the clock and trigger the first event for our signals to be applied to the inputs.
Lines 20 to 35 describe the application of 50k random integers to our design, and our software model, and then comparing them after we waited for the hardware cycles to pass.
We use the `assert` to output a message to the terminal in case a testcase doesn't match with the software model.
If we add `.withWave` to the line 3 we can obtain a wavetrace (tho its recommended not to run as many testcases, as the dump will be huge otherwise).
![GCD wave trace](./img/simulationWave.PNG)
## 5. GCD Murax Integration
Now that we have a standalone module that we want to integrate into the Murax SoC.
Since the Murax is using the APB bus for the peripherals, our module needs to map the IO signals into the memory mapped space of the APB bus.
```scala
// in Apb3GCDCtrl.scala
object Apb3GCDCtrl {
def getApb3Config = Apb3Config(
addressWidth = 5,
dataWidth = 32,
selWidth = 1,
useSlaveError = false
)
}
class Apb3GCDCtrl(apb3Config : Apb3Config) extends Component {
val io = new Bundle {
val apb = slave(Apb3(Apb3GCDCtrl.getApb3Config))
}
val gcdCtrl = new GCDTop()
val apbCtrl = Apb3SlaveFactory(io.apb)
apbCtrl.driveAndRead(gcdCtrl.io.a, address=0)
apbCtrl.driveAndRead(gcdCtrl.io.b, address=4)
val resSyncBuf = RegNextWhen(gcdCtrl.io.res, gcdCtrl.io.ready)
apbCtrl.read(resSyncBuf, address=8)
apbCtrl.onRead(8)(resSyncBuf := 0)
apbCtrl.onRead(8)(rdySyncBuf := False)
val rdySyncBuf = RegNextWhen(gcdCtrl.io.ready, gcdCtrl.io.ready)
apbCtrl.read(rdySyncBuf, address=12)
gcdCtrl.io.valid := apbCtrl.setOnSet(RegNext(False) init(False), address=16, 0)
}
```
Looking at the other peripherals in the Murax, we get an idea how to implement our own Apb3 Mapping (this is also part of the SpinalHDL Workshop).
The components uses the APB3 Bus as a slave peripheral.
In line 14 we create a instance of our GCD module, in line 15 we create a [APB3 Slave Factory](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Libraries/bus_slave_factory.html) (for our APB bus connection of the component).
This factory offers us to add memory mapped registers very easily that create all the logic needed to interconnect with our module properly.
A register which can be read and written to can be seen in line 16 and 17 (`driveAndRead()`).
We pass the signal we want to be buffered through that register and an address.
Our result is [buffered with a `RegNextWhen`](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Sequential%20logic/registers.html#instantiation) (which buffers the first argument `gcdCtrl.io.res` based on the enable signal that is the second argument `gcdCtrl.io.ready`).
We need this because our result is visible for the clock cycle that the ready signal is asserted true by the control path.
We do something similar with the ready signal, and keep it buffered for longer than just one clock cycle (since we don't know when the software will check these registers).
The result and ready registers will be read-only (`read()`) on their respective addresses.
If the result is read (even if ready was not checked) we will flush both registers as if we fetched the result and don't need it anymore.
The valid signal shouldn't be asserted longer than one clock cycle, this is achieved in line 24.
We use a register that sets itself to 0/false whenever its written to.
So if we write a 1/true into it, after one cycle its set to 0/false again.
| Address | Name | Description | Mode |
|---------|-------|----------------------------------------------|----------------------------------|
| 0 | a | Operand A of the GCD(a,b) | R/W |
| 4 | b | Operand B of the GCD(a,b) | R/W |
| 8 | res | Result of GCD(a,b) | RO, clears res and ready on read |
| 12 | ready | Ready, 1 if result available, 0 otherwise | RO |
| 16 | valid | Valid, write 1 to start calculating GCD(a,b) | WO, clear after write |
In this way we implemented this memory mapped register bank with various modes.
Now all thats left is to attach our module to the APB bus of the Murax SoC and write some bare metal firmware to access it.
We created our modules inside the VexRiscv structure as follows:
```
src/main/scala/
├── spinal
└── vexriscv
├── demo
├── ip
├── periph <--- we add this directory with subdir
│ └── gcd
│ ├── Apb3GCDCtrl.scala
│ ├── GCDCtrl.scala
│ ├── GCDData.scala
│ ├── GCDTop.scala
│ └── GCDTopSim.scala
├── plugin
└── test
```
To integrate our `Apb3GCDCtrl` peripheral into the Murax we need to modify the Murax SoC (`src/main/scala/vexriscv/demo/Murax.scala`) directly.
Deep in the source there will be a comment designating the start of the APB peripherals (`//******** APB peripherals *********`).
There we are going to add our peripheral and designate some memory mapped space to it.
This step is straightforward as we can add the peripheral similarly to the existing ones.
After the code for the timer `MuraxApb3Timer` module we add our GCD peripheral:
```scala
val gcd = new Apb3GCDCtrl(
apb3Config = Apb3Config(
addressWidth = 20,
dataWidth = 32
)
)
apbMapping += gcd.io.apb -> (0x30000, 1 kB)
```
And thats it!
The Murax SoC now supports our own GCD peripheral.
All thats left now is to use the peripheral in a piece of software.
## 6. Software Driver Integration
We start off the software part with the existing `hello_world` example and copy it into a new directory `gcd_world`.
Since we support a new peripheral in hardware we also need to support it from the software (its supported but we are making it more usable for the developer).
We add a new file in the `gcd_world/src` directory called `gcd.h`.
```c
// in gcd.h
#ifndef GCD_H_
#define GCD_H_
typedef struct
{
volatile uint32_t A;
volatile uint32_t B;
volatile uint32_t RES;
volatile uint32_t READY;
volatile uint32_t VALID;
} Gcd_Reg;
#endif /* GCD_H_ */
```
With that we define the available memory mapped registers starting from the base address of the peripheral.
We then edit the `murax.h` header file in the same directory:
```c
#ifndef __MURAX_H__
#define __MURAX_H__
#include "timer.h"
#include "prescaler.h"
#include "interrupt.h"
#include "gpio.h"
#include "uart.h"
#include "gcd.h"
#define GPIO_A ((Gpio_Reg*)(0xF0000000))
#define TIMER_PRESCALER ((Prescaler_Reg*)0xF0020000)
#define TIMER_INTERRUPT ((InterruptCtrl_Reg*)0xF0020010)
#define TIMER_A ((Timer_Reg*)0xF0020040)
#define TIMER_B ((Timer_Reg*)0xF0020050)
#define UART ((Uart_Reg*)(0xF0010000))
#define GCD ((Gcd_Reg*)(0xF0030000))
#endif /* __MURAX_H__ */
```
Our addition is the line `#define GCD ((Gcd_Reg*)(0xF0030000))`.
With that we create a way of accessing the memory mapped registers without directly referring to the peripherals address (`0xF0030000`) or having to calculate offsets for the registers.
Now we can start writing our software!
In our `main.c` we add a function to make the peripheral handling a bit more convenient:
```c
uint32_t gcd(uint32_t a, uint32_t b){
GCD->A = a;
GCD->B = b;
GCD->VALID = 0x00000001;
uint32_t rdyFlag = 0;
do{
rdyFlag = GCD->READY;
}while(!rdyFlag);
return GCD->RES;
}
```
This function will take the parameters `a` and `b` and applies them to the respective hardware registers `A` and `B` of our peripheral.
Then the `VALID` signal is set (our Apb3 wrapper takes care of setting it back to 0).
All thats left is waiting for the result, which is done by polling the ready flag until its available and then returning our result value `RES`.
The software contains a little more code for formatting numbers to print them onto the UART device but reading and understanding that is left as an exercise to the reader.
So how do we execute our software on the Murax now?
First we compile the software with the make file. For that call `make` inside `src/main/c/murax/gcd_world`.
You should get some minor warnings and a statistics about the memory usage like
```
Memory region Used Size Region Size %age Used
RAM: 1752 B 2 KB 85.55%
```
Now we can edit the `Murax.scala` one last time before we execute our simulation.
For this scroll down in the `Murax.scala` file until `MuraxWithRamInit`.
In order to load the memory with our new software instead of the `hello_world` example we edit this part.
```scala
object MuraxWithRamInit {
def main(args: Array[String]) {
SpinalVerilog(
Murax(
MuraxConfig.default.copy(
onChipRamSize = 4 kB,
onChipRamHexFile = "src/main/c/murax/gcd_world/build/gcd_world.hex"
)
)
)
}
}
```
Then in the root directory we open `sbt` and call `runMain vexriscv.demo.MuraxWithRamInit` or we call `sbt "runMain vexriscv.demo.MuraxWithRamInit"` directly.
This will call SpinalHDL to generate the modified Murax SoC with our small software example.
The last thing we need to do is call the simulation.
For that navigate to `src/test/cpp/murax` and call `make clean run`.
After some time you should see the following output in the terminal:
```
...
BOOT
hello gcd world
gcd(1,123913):
1
gcd(461952,116298):
18
gcd(461952,1162):
2
gcd(461952,11623):
1
```
Keep in mind that we are simulating a SoC. There is no shutdown for our simulation so we have to stop it by ourselves by pressing `CTRL+C`!
Otherwise the simulation won't stop.
## 7. Conclusion
In a tutorial we described how to convert pseudocode for the GCD calculation into SpinalHDL based hardware. Furthermore the hardware was integrated into the VexRiscv based Murax SoC.
To demonstrate the usage an example C project was set up and the hardware peripheral was used from within the software.
This tutorial covered the translation from RTL into SpinalHDL, writing a small wrapper for the APB3 bus used in the Murax SoC, integrating the peripheral into the Murax SoC with designated memory mapped space and writing software in C for the Murax SoC that uses the hardware peripheral to calculate the GCD and print it out on the UART of the Murax SoC.
Now there are a few open challanges to approach as an exercise here are two that would follow up naturally to our existing code:
* The Murax SoC features interrupts, we could stop polling our ready flag and instead trigger an interrupt from the `Apb3GCDCtrl` instead.
* Write the same algorithm in C and compare it with the hardware peripheral. Is it faster, is it smaller (interacting with the peripheral in software still costs instruction in terms of memory)

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View file

@ -0,0 +1,134 @@
PROJ_NAME=gcd_world
DEBUG=no
BENCH=no
MULDIV=no
SRCS = $(wildcard src/*.c) \
$(wildcard src/*.cpp) \
$(wildcard src/*.S)
OBJDIR = build
INC =
LIBS =
LIBSINC = -L$(OBJDIR)
LDSCRIPT = ./src/linker.ld
#include ../../../resources/gcc.mk
# Set it to yes if you are using the sifive precompiled GCC pack
SIFIVE_GCC_PACK ?= no
ifeq ($(SIFIVE_GCC_PACK),yes)
RISCV_NAME ?= riscv64-unknown-elf
RISCV_PATH ?= /home/sallar/tools/riscv-64-newlib-dist/
else
RISCV_NAME ?= riscv32-unknown-elf
ifeq ($(MULDIV),yes)
RISCV_PATH ?= /home/sallar/tools/riscv-32-imac-ilp32-newlib-dist/
else
RISCV_PATH ?= /home/sallar/tools/rv32i-ilp32-dist/
endif
endif
MABI=ilp32
MARCH := rv32i
ifeq ($(MULDIV),yes)
MARCH := $(MARCH)m
endif
ifeq ($(COMPRESSED),yes)
MARCH := $(MARCH)ac
endif
CFLAGS += -march=$(MARCH) -mabi=$(MABI) -DNDEBUG
LDFLAGS += -march=$(MARCH) -mabi=$(MABI)
#include ../../../resources/subproject.mk
ifeq ($(DEBUG),yes)
CFLAGS += -g3 -O0
endif
ifeq ($(DEBUG),no)
CFLAGS += -g -Os
endif
ifeq ($(BENCH),yes)
CFLAGS += -fno-inline
endif
ifeq ($(SIFIVE_GCC_PACK),yes)
RISCV_CLIB=$(RISCV_PATH)/$(RISCV_NAME)/lib/$(MARCH)/$(MABI)/
else
RISCV_CLIB=$(RISCV_PATH)/$(RISCV_NAME)/lib/
endif
RISCV_OBJCOPY = $(RISCV_PATH)/bin/$(RISCV_NAME)-objcopy
RISCV_OBJDUMP = $(RISCV_PATH)/bin/$(RISCV_NAME)-objdump
RISCV_CC=$(RISCV_PATH)/bin/$(RISCV_NAME)-gcc
CFLAGS += -MD -fstrict-volatile-bitfields -fno-strict-aliasing
LDFLAGS += -nostdlib -lgcc -mcmodel=medany -nostartfiles -ffreestanding -Wl,-Bstatic,-T,$(LDSCRIPT),-Map,$(OBJDIR)/$(PROJ_NAME).map,--print-memory-usage
#LDFLAGS += -lgcc -lc -lg -nostdlib -lgcc -msave-restore --strip-debug,
OBJS := $(SRCS)
OBJS := $(OBJS:.c=.o)
OBJS := $(OBJS:.cpp=.o)
OBJS := $(OBJS:.S=.o)
OBJS := $(OBJS:..=miaou)
OBJS := $(addprefix $(OBJDIR)/,$(OBJS))
all: $(OBJDIR)/$(PROJ_NAME).elf $(OBJDIR)/$(PROJ_NAME).hex $(OBJDIR)/$(PROJ_NAME).asm $(OBJDIR)/$(PROJ_NAME).v
$(OBJDIR)/%.elf: $(OBJS) | $(OBJDIR)
$(RISCV_CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBSINC) $(LIBS)
%.hex: %.elf
$(RISCV_OBJCOPY) -O ihex $^ $@
%.bin: %.elf
$(RISCV_OBJCOPY) -O binary $^ $@
%.v: %.elf
$(RISCV_OBJCOPY) -O verilog $^ $@
%.asm: %.elf
$(RISCV_OBJDUMP) -S -d $^ > $@
$(OBJDIR)/%.o: %.c
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
$(RISCV_CC) -S $(CFLAGS) $(INC) -o $@.disasm $^
$(OBJDIR)/%.o: %.cpp
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
$(OBJDIR)/%.o: %.S
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) -o $@ $^ -D__ASSEMBLY__=1
$(OBJDIR):
mkdir -p $@
.PHONY: clean
clean:
rm -rf $(OBJDIR)/src
rm -f $(OBJDIR)/$(PROJ_NAME).elf
rm -f $(OBJDIR)/$(PROJ_NAME).hex
rm -f $(OBJDIR)/$(PROJ_NAME).map
rm -f $(OBJDIR)/$(PROJ_NAME).v
rm -f $(OBJDIR)/$(PROJ_NAME).asm
find $(OBJDIR) -type f -name '*.o' -print0 | xargs -0 -r rm
find $(OBJDIR) -type f -name '*.d' -print0 | xargs -0 -r rm
clean-all : clean
.SECONDARY: $(OBJS)

View file

@ -0,0 +1 @@
sbt.version=1.4.9

View file

@ -0,0 +1,98 @@
.global crtStart
.global main
.global irqCallback
.section .start_jump,"ax",@progbits
crtStart:
//long jump to allow crtInit to be anywhere
//do it always in 12 bytes
lui x2, %hi(crtInit)
addi x2, x2, %lo(crtInit)
jalr x1,x2
nop
.section .text
.global trap_entry
.align 5
trap_entry:
sw x1, - 1*4(sp)
sw x5, - 2*4(sp)
sw x6, - 3*4(sp)
sw x7, - 4*4(sp)
sw x10, - 5*4(sp)
sw x11, - 6*4(sp)
sw x12, - 7*4(sp)
sw x13, - 8*4(sp)
sw x14, - 9*4(sp)
sw x15, -10*4(sp)
sw x16, -11*4(sp)
sw x17, -12*4(sp)
sw x28, -13*4(sp)
sw x29, -14*4(sp)
sw x30, -15*4(sp)
sw x31, -16*4(sp)
addi sp,sp,-16*4
call irqCallback
lw x1 , 15*4(sp)
lw x5, 14*4(sp)
lw x6, 13*4(sp)
lw x7, 12*4(sp)
lw x10, 11*4(sp)
lw x11, 10*4(sp)
lw x12, 9*4(sp)
lw x13, 8*4(sp)
lw x14, 7*4(sp)
lw x15, 6*4(sp)
lw x16, 5*4(sp)
lw x17, 4*4(sp)
lw x28, 3*4(sp)
lw x29, 2*4(sp)
lw x30, 1*4(sp)
lw x31, 0*4(sp)
addi sp,sp,16*4
mret
.text
crtInit:
.option push
.option norelax
la gp, __global_pointer$
.option pop
la sp, _stack_start
bss_init:
la a0, _bss_start
la a1, _bss_end
bss_loop:
beq a0,a1,bss_done
sw zero,0(a0)
add a0,a0,4
j bss_loop
bss_done:
ctors_init:
la a0, _ctors_start
addi sp,sp,-4
ctors_loop:
la a1, _ctors_end
beq a0,a1,ctors_done
lw a3,0(a0)
add a0,a0,4
sw a0,0(sp)
jalr a3
lw a0,0(sp)
j ctors_loop
ctors_done:
addi sp,sp,4
li a0, 0x880 //880 enable timer + external interrupts
csrw mie,a0
li a0, 0x1808 //1808 enable interrupts
csrw mstatus,a0
call main
infinitLoop:
j infinitLoop

View file

@ -0,0 +1,13 @@
#ifndef GCD_H_
#define GCD_H_
typedef struct
{
volatile uint32_t A;
volatile uint32_t B;
volatile uint32_t RES;
volatile uint32_t READY;
volatile uint32_t VALID;
} Gcd_Reg;
#endif /* GCD_H_ */

View file

@ -0,0 +1,15 @@
#ifndef GPIO_H_
#define GPIO_H_
typedef struct
{
volatile uint32_t INPUT;
volatile uint32_t OUTPUT;
volatile uint32_t OUTPUT_ENABLE;
} Gpio_Reg;
#endif /* GPIO_H_ */

View file

@ -0,0 +1,17 @@
#ifndef INTERRUPTCTRL_H_
#define INTERRUPTCTRL_H_
#include <stdint.h>
typedef struct
{
volatile uint32_t PENDINGS;
volatile uint32_t MASKS;
} InterruptCtrl_Reg;
static void interruptCtrl_init(InterruptCtrl_Reg* reg){
reg->MASKS = 0;
reg->PENDINGS = 0xFFFFFFFF;
}
#endif /* INTERRUPTCTRL_H_ */

View file

@ -0,0 +1,110 @@
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
*/
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
OUTPUT_ARCH(riscv)
ENTRY(crtStart)
MEMORY {
RAM (rwx): ORIGIN = 0x80000000, LENGTH = 2k
}
_stack_size = DEFINED(_stack_size) ? _stack_size : 256;
_heap_size = DEFINED(_heap_size) ? _heap_size : 0;
SECTIONS {
._vector ORIGIN(RAM): {
*crt.o(.start_jump);
*crt.o(.text);
} > RAM
._user_heap (NOLOAD):
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
PROVIDE ( _heap_start = .);
. = . + _heap_size;
. = ALIGN(8);
PROVIDE ( _heap_end = .);
} > RAM
._stack (NOLOAD):
{
. = ALIGN(16);
PROVIDE (_stack_end = .);
. = . + _stack_size;
. = ALIGN(16);
PROVIDE (_stack_start = .);
} > RAM
.data :
{
*(.rdata)
*(.rodata .rodata.*)
*(.gnu.linkonce.r.*)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.*)
*(.gnu.linkonce.s.*)
. = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
*(.srodata.cst2)
*(.srodata .srodata.*)
} > RAM
.bss (NOLOAD) : {
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_bss_start = .;
*(.sbss*)
*(.gnu.linkonce.sb.*)
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_bss_end = .;
} > RAM
.rodata :
{
*(.rdata)
*(.rodata .rodata.*)
*(.gnu.linkonce.r.*)
} > RAM
.noinit (NOLOAD) : {
. = ALIGN(4);
*(.noinit .noinit.*)
. = ALIGN(4);
} > RAM
.memory : {
*(.text);
end = .;
} > RAM
.ctors :
{
. = ALIGN(4);
_ctors_start = .;
KEEP(*(.init_array*))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4);
_ctors_end = .;
PROVIDE ( END_OF_SW_IMAGE = . );
} > RAM
}

View file

@ -0,0 +1,62 @@
//#include "stddefs.h"
#include <stdint.h>
#include "murax.h"
#include "main.h"
#define DEBUG 0
uint32_t gcd(uint32_t a, uint32_t b){
GCD->A = a;
GCD->B = b;
GCD->VALID = 0x00000001;
uint32_t rdyFlag = 0;
do{
rdyFlag = GCD->READY;
}while(!rdyFlag);
return GCD->RES;
}
void calcPrintGCD(uint32_t a, uint32_t b){
uint32_t myGCD = 0;
char buf[5] = { 0x00 };
char aBuf[11] = { 0x00 };
char bBuf[11] = { 0x00 };
itoa(a, aBuf, 10);
itoa(b, bBuf, 10);
print("gcd(");print(aBuf);print(",");print(bBuf);println("):");
myGCD = gcd(a,b);
itoa(myGCD, buf, 10);
println(buf);
}
void main() {
GPIO_A->OUTPUT_ENABLE = 0x0000000F;
GPIO_A->OUTPUT = 0x00000001;
println("hello gcd world");
const int nleds = 4;
const int nloops = 2000000;
GCD->VALID = 0x00000000;
while(GCD->READY);
calcPrintGCD(1, 123913);
calcPrintGCD(461952, 116298);
calcPrintGCD(461952, 116298);
calcPrintGCD(461952, 116298);
while(1){
for(unsigned int i=0;i<nleds-1;i++){
GPIO_A->OUTPUT = 1<<i;
delay(nloops);
}
for(unsigned int i=0;i<nleds-1;i++){
GPIO_A->OUTPUT = (1<<(nleds-1))>>i;
delay(nloops);
}
}
}
void irqCallback(){
}

View file

@ -0,0 +1,78 @@
//----------------------------
// integer to ascii (itoa) with util functions
//----------------------------
// function to swap two numbers
void swap(char *x, char *y) {
char t = *x; *x = *y; *y = t;
}
// function to reverse buffer[i..j]
char* reverse(char *buffer, int i, int j) {
while (i < j)
swap(&buffer[i++], &buffer[j--]);
return buffer;
}
// Iterative function to implement itoa() function in C
char* itoa(int value, char* buffer, int base) {
// invalid input
if (base < 2 || base > 32)
return buffer;
// consider absolute value of number
int n = (value < 0) ? -value : value;
int i = 0;
while (n) {
int r = n % base;
if (r >= 10)
buffer[i++] = 65 + (r - 10);
else
buffer[i++] = 48 + r;
n = n / base;
}
// if number is 0
if (i == 0)
buffer[i++] = '0';
// If base is 10 and value is negative, the resulting string
// is preceded with a minus sign (-)
// With any other base, value is always considered unsigned
if (value < 0 && base == 10)
buffer[i++] = '-';
buffer[i] = '\0'; // null terminate string
// reverse the string and return it
return reverse(buffer, 0, i - 1);
}
//----------------------------
// print, println, dbgprint
//----------------------------
void print(const char*str){
while(*str){
uart_write(UART,*str);
str++;
}
}
void println(const char*str){
print(str);
uart_write(UART,'\n');
}
void dbgPrintln(const char*str){
#if DEBUG == 1
println(str);
#else
void;
#endif
}
void delay(uint32_t loops){
for(int i=0;i<loops;i++){
int tmp = GPIO_A->OUTPUT;
}
}

View file

@ -0,0 +1,20 @@
#ifndef __MURAX_H__
#define __MURAX_H__
#include "timer.h"
#include "prescaler.h"
#include "interrupt.h"
#include "gpio.h"
#include "uart.h"
#include "gcd.h"
#define GPIO_A ((Gpio_Reg*)(0xF0000000))
#define TIMER_PRESCALER ((Prescaler_Reg*)0xF0020000)
#define TIMER_INTERRUPT ((InterruptCtrl_Reg*)0xF0020010)
#define TIMER_A ((Timer_Reg*)0xF0020040)
#define TIMER_B ((Timer_Reg*)0xF0020050)
#define UART ((Uart_Reg*)(0xF0010000))
#define GCD ((Gcd_Reg*)(0xF0030000))
#endif /* __MURAX_H__ */

View file

@ -0,0 +1,16 @@
#ifndef PRESCALERCTRL_H_
#define PRESCALERCTRL_H_
#include <stdint.h>
typedef struct
{
volatile uint32_t LIMIT;
} Prescaler_Reg;
static void prescaler_init(Prescaler_Reg* reg){
}
#endif /* PRESCALERCTRL_H_ */

View file

@ -0,0 +1,20 @@
#ifndef TIMERCTRL_H_
#define TIMERCTRL_H_
#include <stdint.h>
typedef struct
{
volatile uint32_t CLEARS_TICKS;
volatile uint32_t LIMIT;
volatile uint32_t VALUE;
} Timer_Reg;
static void timer_init(Timer_Reg *reg){
reg->CLEARS_TICKS = 0;
reg->VALUE = 0;
}
#endif /* TIMERCTRL_H_ */

View file

@ -0,0 +1,42 @@
#ifndef UART_H_
#define UART_H_
typedef struct
{
volatile uint32_t DATA;
volatile uint32_t STATUS;
volatile uint32_t CLOCK_DIVIDER;
volatile uint32_t FRAME_CONFIG;
} Uart_Reg;
enum UartParity {NONE = 0,EVEN = 1,ODD = 2};
enum UartStop {ONE = 0,TWO = 1};
typedef struct {
uint32_t dataLength;
enum UartParity parity;
enum UartStop stop;
uint32_t clockDivider;
} Uart_Config;
static uint32_t uart_writeAvailability(Uart_Reg *reg){
return (reg->STATUS >> 16) & 0xFF;
}
static uint32_t uart_readOccupancy(Uart_Reg *reg){
return reg->STATUS >> 24;
}
static void uart_write(Uart_Reg *reg, uint32_t data){
while(uart_writeAvailability(reg) == 0);
reg->DATA = data;
}
static void uart_applyConfig(Uart_Reg *reg, Uart_Config *config){
reg->CLOCK_DIVIDER = config->clockDivider;
reg->FRAME_CONFIG = ((config->dataLength-1) << 0) | (config->parity << 8) | (config->stop << 16);
}
#endif /* UART_H_ */

View file

@ -0,0 +1,559 @@
package vexriscv.demo
import spinal.core._
import spinal.lib._
import spinal.lib.bus.amba3.apb._
import spinal.lib.bus.misc.SizeMapping
import spinal.lib.bus.simple.PipelinedMemoryBus
import spinal.lib.com.jtag.Jtag
import spinal.lib.com.spi.ddr.SpiXdrMaster
import spinal.lib.com.uart._
import spinal.lib.io.{InOutWrapper, TriStateArray}
import spinal.lib.misc.{InterruptCtrl, Prescaler, Timer}
import spinal.lib.soc.pinsec.{PinsecTimerCtrl, PinsecTimerCtrlExternal}
import vexriscv.plugin._
import vexriscv.{VexRiscv, VexRiscvConfig, plugin}
import spinal.lib.com.spi.ddr._
import spinal.lib.bus.simple._
import scala.collection.mutable.ArrayBuffer
import vexriscv.periph.gcd._
import vexriscv.periph.tasks.gen._
import vexriscv.periph.tasks.map._
import vexriscv.periph.tasks.sort._
import vexriscv.periph.tasks.max._
import vexriscv.periph.tasks.sum._
import vexriscv.periph.tasks.hash._
/** Created by PIC32F_USER on 28/07/2017.
*
* Murax is a very light SoC which could work without any external component.
* - ICE40-hx8k + icestorm => 53 MHz, 2142 LC
* - 0.37 DMIPS/MHz
* - 8 kB of on-chip ram
* - JTAG debugger (eclipse/GDB/openocd ready)
* - Interrupt support
* - APB bus for peripherals
* - 32 GPIO pin
* - one 16 bits prescaler, two 16 bits timers
* - one UART with tx/rx fifo
*/
case class MuraxConfig(
coreFrequency: HertzNumber,
onChipRamSize: BigInt,
onChipRamHexFile: String,
pipelineDBus: Boolean,
pipelineMainBus: Boolean,
pipelineApbBridge: Boolean,
gpioWidth: Int,
uartCtrlConfig: UartCtrlMemoryMappedConfig,
xipConfig: SpiXdrMasterCtrl.MemoryMappingParameters,
hardwareBreakpointCount: Int,
cpuPlugins: ArrayBuffer[Plugin[VexRiscv]]
) {
require(
pipelineApbBridge || pipelineMainBus,
"At least pipelineMainBus or pipelineApbBridge should be enable to avoid wipe transactions"
)
val genXip = xipConfig != null
}
object MuraxConfig {
def default: MuraxConfig = default(false, false)
def default(withXip: Boolean = false, bigEndian: Boolean = false) =
MuraxConfig(
coreFrequency = 12 MHz,
onChipRamSize = 8 kB,
onChipRamHexFile = null,
pipelineDBus = true,
pipelineMainBus = false,
pipelineApbBridge = true,
gpioWidth = 32,
xipConfig = ifGen(withXip)(
SpiXdrMasterCtrl.MemoryMappingParameters(
SpiXdrMasterCtrl
.Parameters(8, 12, SpiXdrParameter(2, 2, 1))
.addFullDuplex(0, 1, false),
cmdFifoDepth = 32,
rspFifoDepth = 32,
xip = SpiXdrMasterCtrl
.XipBusParameters(addressWidth = 24, lengthWidth = 2)
)
),
hardwareBreakpointCount = if (withXip) 3 else 0,
cpuPlugins = ArrayBuffer( //DebugPlugin added by the toplevel
new IBusSimplePlugin(
resetVector = if (withXip) 0xf001e000L else 0x80000000L,
cmdForkOnSecondStage = true,
cmdForkPersistence = withXip, //Required by the Xip controller
prediction = NONE,
catchAccessFault = false,
compressedGen = false,
bigEndian = bigEndian
),
new DBusSimplePlugin(
catchAddressMisaligned = false,
catchAccessFault = false,
earlyInjection = false,
bigEndian = bigEndian
),
new CsrPlugin(
CsrPluginConfig.smallest(mtvecInit =
if (withXip) 0xe0040020L else 0x80000020L
)
),
new DecoderSimplePlugin(
catchIllegalInstruction = false
),
new RegFilePlugin(
regFileReadyKind = plugin.SYNC,
zeroBoot = false
),
new IntAluPlugin,
new SrcPlugin(
separatedAddSub = false,
executeInsertion = false
),
new LightShifterPlugin,
new HazardSimplePlugin(
bypassExecute = false,
bypassMemory = false,
bypassWriteBack = false,
bypassWriteBackBuffer = false,
pessimisticUseSrc = false,
pessimisticWriteRegFile = false,
pessimisticAddressMatch = false
),
new BranchPlugin(
earlyBranch = false,
catchAddressMisaligned = false
),
new YamlPlugin("cpu0.yaml")
),
uartCtrlConfig = UartCtrlMemoryMappedConfig(
uartCtrlConfig = UartCtrlGenerics(
dataWidthMax = 8,
clockDividerWidth = 20,
preSamplingSize = 1,
samplingSize = 3,
postSamplingSize = 1
),
initConfig = UartCtrlInitConfig(
baudrate = 115200,
dataLength = 7, //7 => 8 bits
parity = UartParityType.NONE,
stop = UartStopType.ONE
),
busCanWriteClockDividerConfig = false,
busCanWriteFrameConfig = false,
txFifoDepth = 16,
rxFifoDepth = 16
)
)
def fast = {
val config = default
//Replace HazardSimplePlugin to get datapath bypass
config.cpuPlugins(
config.cpuPlugins.indexWhere(_.isInstanceOf[HazardSimplePlugin])
) = new HazardSimplePlugin(
bypassExecute = true,
bypassMemory = true,
bypassWriteBack = true,
bypassWriteBackBuffer = true
)
// config.cpuPlugins(config.cpuPlugins.indexWhere(_.isInstanceOf[LightShifterPlugin])) = new FullBarrelShifterPlugin()
config
}
}
case class Murax(config: MuraxConfig) extends Component {
import config._
val io = new Bundle {
//Clocks / reset
val asyncReset = in Bool ()
val mainClk = in Bool ()
//Main components IO
val jtag = slave(Jtag())
//Peripherals IO
val gpioA = master(TriStateArray(gpioWidth bits))
val uart = master(Uart())
val xip = ifGen(genXip)(master(SpiXdrMaster(xipConfig.ctrl.spi)))
}
val resetCtrlClockDomain = ClockDomain(
clock = io.mainClk,
config = ClockDomainConfig(
resetKind = BOOT
)
)
val resetCtrl = new ClockingArea(resetCtrlClockDomain) {
val mainClkResetUnbuffered = False
//Implement an counter to keep the reset axiResetOrder high 64 cycles
// Also this counter will automatically do a reset when the system boot.
val systemClkResetCounter = Reg(UInt(6 bits)) init (0)
when(systemClkResetCounter =/= U(systemClkResetCounter.range -> true)) {
systemClkResetCounter := systemClkResetCounter + 1
mainClkResetUnbuffered := True
}
when(BufferCC(io.asyncReset)) {
systemClkResetCounter := 0
}
//Create all reset used later in the design
val mainClkReset = RegNext(mainClkResetUnbuffered)
val systemReset = RegNext(mainClkResetUnbuffered)
}
val systemClockDomain = ClockDomain(
clock = io.mainClk,
reset = resetCtrl.systemReset,
frequency = FixedFrequency(coreFrequency)
)
val debugClockDomain = ClockDomain(
clock = io.mainClk,
reset = resetCtrl.mainClkReset,
frequency = FixedFrequency(coreFrequency)
)
val system = new ClockingArea(systemClockDomain) {
val pipelinedMemoryBusConfig = PipelinedMemoryBusConfig(
addressWidth = 32,
dataWidth = 32
)
val bigEndianDBus = config.cpuPlugins.exists(_ match {
case plugin: DBusSimplePlugin => plugin.bigEndian
case _ => false
})
//Arbiter of the cpu dBus/iBus to drive the mainBus
//Priority to dBus, !! cmd transactions can change on the fly !!
val mainBusArbiter =
new MuraxMasterArbiter(pipelinedMemoryBusConfig, bigEndianDBus)
//Instanciate the CPU
val cpu = new VexRiscv(
config = VexRiscvConfig(
plugins = cpuPlugins += new DebugPlugin(
debugClockDomain,
hardwareBreakpointCount
)
)
)
//Checkout plugins used to instanciate the CPU to connect them to the SoC
val timerInterrupt = False
val externalInterrupt = False
for (plugin <- cpu.plugins) plugin match {
case plugin: IBusSimplePlugin =>
mainBusArbiter.io.iBus.cmd <> plugin.iBus.cmd
mainBusArbiter.io.iBus.rsp <> plugin.iBus.rsp
case plugin: DBusSimplePlugin => {
if (!pipelineDBus)
mainBusArbiter.io.dBus <> plugin.dBus
else {
mainBusArbiter.io.dBus.cmd << plugin.dBus.cmd.halfPipe()
mainBusArbiter.io.dBus.rsp <> plugin.dBus.rsp
}
}
case plugin: CsrPlugin => {
plugin.externalInterrupt := externalInterrupt
plugin.timerInterrupt := timerInterrupt
}
case plugin: DebugPlugin =>
plugin.debugClockDomain {
resetCtrl.systemReset setWhen (RegNext(plugin.io.resetOut))
io.jtag <> plugin.io.bus.fromJtag()
}
case _ =>
}
//****** MainBus slaves ********
val mainBusMapping = ArrayBuffer[(PipelinedMemoryBus, SizeMapping)]()
val ram = new MuraxPipelinedMemoryBusRam(
onChipRamSize = onChipRamSize,
onChipRamHexFile = onChipRamHexFile,
pipelinedMemoryBusConfig = pipelinedMemoryBusConfig,
bigEndian = bigEndianDBus
)
mainBusMapping += ram.io.bus -> (0x80000000L, onChipRamSize)
val apbBridge = new PipelinedMemoryBusToApbBridge(
apb3Config = Apb3Config(
addressWidth = 20,
dataWidth = 32
),
pipelineBridge = pipelineApbBridge,
pipelinedMemoryBusConfig = pipelinedMemoryBusConfig
)
mainBusMapping += apbBridge.io.pipelinedMemoryBus -> (0xf0000000L, 1 MB)
//******** APB peripherals *********
val apbMapping = ArrayBuffer[(Apb3, SizeMapping)]()
val gpioACtrl = Apb3Gpio(gpioWidth = gpioWidth, withReadSync = true)
io.gpioA <> gpioACtrl.io.gpio
apbMapping += gpioACtrl.io.apb -> (0x00000, 4 kB)
val uartCtrl = Apb3UartCtrl(uartCtrlConfig)
uartCtrl.io.uart <> io.uart
externalInterrupt setWhen (uartCtrl.io.interrupt)
apbMapping += uartCtrl.io.apb -> (0x10000, 4 kB)
val timer = new MuraxApb3Timer()
timerInterrupt setWhen (timer.io.interrupt)
apbMapping += timer.io.apb -> (0x20000, 4 kB)
val gcd = new Apb3GCDCtrl(
apb3Config = Apb3Config(
addressWidth = 20,
dataWidth = 32
)
)
apbMapping += gcd.io.apb -> (0x30000, 1 kB)
val xip = ifGen(genXip)(new Area {
val ctrl = Apb3SpiXdrMasterCtrl(xipConfig)
ctrl.io.spi <> io.xip
externalInterrupt setWhen (ctrl.io.interrupt)
apbMapping += ctrl.io.apb -> (0x1f000, 4 kB)
val accessBus = new PipelinedMemoryBus(PipelinedMemoryBusConfig(24, 32))
mainBusMapping += accessBus -> (0xe0000000L, 16 MB)
ctrl.io.xip.fromPipelinedMemoryBus() << accessBus
val bootloader = Apb3Rom("src/main/c/murax/xipBootloader/crt.bin")
apbMapping += bootloader.io.apb -> (0x1e000, 4 kB)
})
//******** Memory mappings *********
val apbDecoder = Apb3Decoder(
master = apbBridge.io.apb,
slaves = apbMapping
)
val mainBusDecoder = new Area {
val logic = new MuraxPipelinedMemoryBusDecoder(
master = mainBusArbiter.io.masterBus,
specification = mainBusMapping,
pipelineMaster = pipelineMainBus
)
}
}
}
object Murax {
def main(args: Array[String]) {
SpinalVerilog(Murax(MuraxConfig.default))
}
}
object Murax_iCE40_hx8k_breakout_board_xip {
case class SB_GB() extends BlackBox {
val USER_SIGNAL_TO_GLOBAL_BUFFER = in Bool ()
val GLOBAL_BUFFER_OUTPUT = out Bool ()
}
case class SB_IO_SCLK() extends BlackBox {
addGeneric("PIN_TYPE", B"010000")
val PACKAGE_PIN = out Bool ()
val OUTPUT_CLK = in Bool ()
val CLOCK_ENABLE = in Bool ()
val D_OUT_0 = in Bool ()
val D_OUT_1 = in Bool ()
setDefinitionName("SB_IO")
}
case class SB_IO_DATA() extends BlackBox {
addGeneric("PIN_TYPE", B"110000")
val PACKAGE_PIN = inout(Analog(Bool))
val CLOCK_ENABLE = in Bool ()
val INPUT_CLK = in Bool ()
val OUTPUT_CLK = in Bool ()
val OUTPUT_ENABLE = in Bool ()
val D_OUT_0 = in Bool ()
val D_OUT_1 = in Bool ()
val D_IN_0 = out Bool ()
val D_IN_1 = out Bool ()
setDefinitionName("SB_IO")
}
case class Murax_iCE40_hx8k_breakout_board_xip() extends Component {
val io = new Bundle {
val mainClk = in Bool ()
val jtag_tck = in Bool ()
val jtag_tdi = in Bool ()
val jtag_tdo = out Bool ()
val jtag_tms = in Bool ()
val uart_txd = out Bool ()
val uart_rxd = in Bool ()
val mosi = inout(Analog(Bool))
val miso = inout(Analog(Bool))
val sclk = out Bool ()
val spis = out Bool ()
val led = out Bits (8 bits)
}
val murax = Murax(
MuraxConfig.default(withXip = true).copy(onChipRamSize = 8 kB)
)
murax.io.asyncReset := False
val mainClkBuffer = SB_GB()
mainClkBuffer.USER_SIGNAL_TO_GLOBAL_BUFFER <> io.mainClk
mainClkBuffer.GLOBAL_BUFFER_OUTPUT <> murax.io.mainClk
val jtagClkBuffer = SB_GB()
jtagClkBuffer.USER_SIGNAL_TO_GLOBAL_BUFFER <> io.jtag_tck
jtagClkBuffer.GLOBAL_BUFFER_OUTPUT <> murax.io.jtag.tck
io.led <> murax.io.gpioA.write(7 downto 0)
murax.io.jtag.tdi <> io.jtag_tdi
murax.io.jtag.tdo <> io.jtag_tdo
murax.io.jtag.tms <> io.jtag_tms
murax.io.gpioA.read <> 0
murax.io.uart.txd <> io.uart_txd
murax.io.uart.rxd <> io.uart_rxd
val xip = new ClockingArea(murax.systemClockDomain) {
RegNext(murax.io.xip.ss.asBool) <> io.spis
val sclkIo = SB_IO_SCLK()
sclkIo.PACKAGE_PIN <> io.sclk
sclkIo.CLOCK_ENABLE := True
sclkIo.OUTPUT_CLK := ClockDomain.current.readClockWire
sclkIo.D_OUT_0 <> murax.io.xip.sclk.write(0)
sclkIo.D_OUT_1 <> RegNext(murax.io.xip.sclk.write(1))
val datas =
for ((data, pin) <- (murax.io.xip.data, List(io.mosi, io.miso)).zipped)
yield new Area {
val dataIo = SB_IO_DATA()
dataIo.PACKAGE_PIN := pin
dataIo.CLOCK_ENABLE := True
dataIo.OUTPUT_CLK := ClockDomain.current.readClockWire
dataIo.OUTPUT_ENABLE <> data.writeEnable
dataIo.D_OUT_0 <> data.write(0)
dataIo.D_OUT_1 <> RegNext(data.write(1))
dataIo.INPUT_CLK := ClockDomain.current.readClockWire
data.read(0) := dataIo.D_IN_0
data.read(1) := RegNext(dataIo.D_IN_1)
}
}
}
def main(args: Array[String]) {
SpinalVerilog(Murax_iCE40_hx8k_breakout_board_xip())
}
}
object MuraxDhrystoneReady {
def main(args: Array[String]) {
SpinalVerilog(Murax(MuraxConfig.fast.copy(onChipRamSize = 256 kB)))
}
}
object MuraxDhrystoneReadyMulDivStatic {
def main(args: Array[String]) {
SpinalVerilog({
val config = MuraxConfig.fast.copy(onChipRamSize = 256 kB)
config.cpuPlugins += new MulPlugin
config.cpuPlugins += new DivPlugin
config.cpuPlugins.remove(
config.cpuPlugins.indexWhere(_.isInstanceOf[BranchPlugin])
)
config.cpuPlugins += new BranchPlugin(
earlyBranch = false,
catchAddressMisaligned = false
)
config.cpuPlugins += new IBusSimplePlugin(
resetVector = 0x80000000L,
cmdForkOnSecondStage = true,
cmdForkPersistence = false,
prediction = STATIC,
catchAccessFault = false,
compressedGen = false
)
config.cpuPlugins.remove(
config.cpuPlugins.indexWhere(_.isInstanceOf[LightShifterPlugin])
)
config.cpuPlugins += new FullBarrelShifterPlugin
Murax(config)
})
}
}
//Will blink led and echo UART RX to UART TX (in the verilator sim, type some text and press enter to send UART frame to the Murax RX pin)
object MuraxWithRamInit {
def main(args: Array[String]) {
SpinalVerilog(
Murax(
MuraxConfig.default.copy(
onChipRamSize = 4 kB,
onChipRamHexFile = "src/main/c/murax/gcd_world/build/gcd_world.hex"
)
)
)
.printPruned()
}
}
object MuraxWithRamInitSynth {
def main(args: Array[String]) {
val config = SpinalConfig(
targetDirectory = "synth",
defaultClockDomainFrequency = FixedFrequency(12 MHz)
)
config
.generateVerilog(
Murax(
MuraxConfig.default.copy(
onChipRamSize = 4 kB,
onChipRamHexFile = "src/main/c/murax/gcd_world/build/gcd_world.hex"
)
)
)
.printPruned()
}
}
object Murax_arty {
def main(args: Array[String]) {
val hex = "src/main/c/murax/hello_world/build/hello_world.hex"
SpinalVerilog(
Murax(
MuraxConfig
.default(false)
.copy(
coreFrequency = 100 MHz,
onChipRamSize = 32 kB,
onChipRamHexFile = hex
)
)
)
}
}
object MuraxAsicBlackBox extends App {
println("Warning this soc do not has any rom to boot on.")
val config = SpinalConfig()
config.addStandardMemBlackboxing(blackboxAll)
config.generateVerilog(Murax(MuraxConfig.default()))
}

View file

@ -0,0 +1,39 @@
package vexriscv.periph.gcd
import spinal.core._
import spinal.lib._
import spinal.lib.bus.amba3.apb.{Apb3, Apb3Config, Apb3SlaveFactory}
import spinal.lib.eda.altera.QSysify
import spinal.lib.slave
object Apb3GCDCtrl {
def getApb3Config = Apb3Config(
addressWidth = 5,
dataWidth = 32,
selWidth = 1,
useSlaveError = false
)
}
class Apb3GCDCtrl(apb3Config : Apb3Config) extends Component {
val io = new Bundle {
val apb = slave(Apb3(Apb3GCDCtrl.getApb3Config))
// maybe later
// val interrupt = out Bool
}
val gcdCtrl = new GCDTop()
val apbCtrl = Apb3SlaveFactory(io.apb)
apbCtrl.driveAndRead(gcdCtrl.io.a, address=0)
apbCtrl.driveAndRead(gcdCtrl.io.b, address=4)
// when result of calculation ready, synchronize it into memory mapped register
val resSyncBuf = RegNextWhen(gcdCtrl.io.res, gcdCtrl.io.ready)
apbCtrl.read(resSyncBuf, address=8)
// if result is read, it will be consumed, set ready to 0
apbCtrl.onRead(8)(resSyncBuf := 0)
apbCtrl.onRead(8)(rdySyncBuf := False)
// synchronize ready signal into memory mapped register
val rdySyncBuf = RegNextWhen(gcdCtrl.io.ready, gcdCtrl.io.ready)
apbCtrl.read(rdySyncBuf, address=12)
// set valid based on memory mapped register but clear/consume it after 1 cycle <s
gcdCtrl.io.valid := apbCtrl.setOnSet(RegNext(False) init(False), address=16, 0)
}

View file

@ -0,0 +1,68 @@
package vexriscv.periph.gcd
import spinal.core._
import spinal.lib._
import spinal.lib.master
import spinal.lib.fsm._
//Hardware definition
class GCDCtrl() extends Component {
val io = new Bundle {
val valid = in Bool()
val ready = out Bool()
val dataCtrl = master(GCDDataControl())
}
val fsm = new StateMachine{
io.dataCtrl.loadA := False
io.dataCtrl.loadB := False
io.dataCtrl.init := False
io.dataCtrl.selL := False
io.dataCtrl.selR := False
io.ready := False
val idle : State = new State with EntryPoint{
whenIsActive{
when(io.valid){
io.dataCtrl.init := True
goto(calculate)
}
}
}
val calculate : State = new State{
whenIsActive{
when(io.dataCtrl.cmpAgtB){
goto(calcA)
}.elsewhen(io.dataCtrl.cmpAltB){
goto(calcB)
}.elsewhen(!io.dataCtrl.cmpAgtB & !io.dataCtrl.cmpAgtB){
goto(calcDone)
}
}
}
val calcA : State = new State{
whenIsActive{
io.dataCtrl.selR := True
io.dataCtrl.loadA := True
goto(calculate)
}
}
val calcB : State = new State{
whenIsActive{
io.dataCtrl.selL := True
io.dataCtrl.loadB := True
goto(calculate)
}
}
val calcDone : State = new State{
whenIsActive{
io.ready := True
goto(idle)
}
}
}
}
object GCDCtrlVerilog {
def main(args: Array[String]) {
SpinalVerilog(new GCDCtrl)
}
}

View file

@ -0,0 +1,54 @@
package vexriscv.periph.gcd
import spinal.core._
import spinal.lib._
import spinal.lib.slave
//Hardware definition
class GCDData() extends Component {
val io = new Bundle {
val a = in(UInt(32 bits))
val b = in(UInt(32 bits))
val res = out(UInt(32 bits))
val dataCtrl = slave(GCDDataControl())
}
/*
*
* // Pseudocode of the Euclids algorithm for calculating the GCD
* inputs: [a, b, start]
* outputs: [done, a]
* done := False
* while(!done):
* if(a > b):
* a := a - b
* else if(b > a):
* b := b - a
* else:
* done := True
*/
//registers
val regA = Reg(UInt(32 bits)) init(0)
val regB = Reg(UInt(32 bits)) init(0)
// compare
val xGTy = regA > regB
val xLTy = regA < regB
// mux
val chX = io.dataCtrl.selL ? regB | regA
val chY = io.dataCtrl.selR ? regB | regA
// subtract
val subXY = chX - chY
// load logic
when(io.dataCtrl.init){
regA := io.a
regB := io.b
}
when(io.dataCtrl.loadA){
regA := subXY
}
when(io.dataCtrl.loadB){
regB := subXY
}
io.dataCtrl.cmpAgtB := xGTy
io.dataCtrl.cmpAltB := xLTy
io.res := regA
}

View file

@ -0,0 +1,46 @@
package vexriscv.periph.gcd
import spinal.core._
import spinal.lib._
import spinal.lib.IMasterSlave
case class GCDDataControl() extends Bundle with IMasterSlave{
val cmpAgtB = Bool
val cmpAltB = Bool
val loadA = Bool
val loadB = Bool
val init = Bool
val selL = Bool
val selR = Bool
// define <> semantic
override def asMaster(): Unit = {
// as controller: output, input
out(loadA, loadB, selL, selR, init)
in(cmpAgtB, cmpAltB)
}
}
//Hardware definition
class GCDTop() extends Component {
val io = new Bundle {
val valid = in Bool()
val ready = out Bool()
val a = in(UInt(32 bits))
val b = in(UInt(32 bits))
val res = out(UInt(32 bits))
}
val gcdCtr = new GCDCtrl()
gcdCtr.io.valid := io.valid
io.ready := gcdCtr.io.ready
val gcdDat = new GCDData()
gcdDat.io.a := io.a
gcdDat.io.b := io.b
io.res := gcdDat.io.res
gcdCtr.io.dataCtrl <> gcdDat.io.dataCtrl
}
object GCDTopVerilog {
def main(args: Array[String]) {
SpinalVerilog(new GCDTop)
}
}

View file

@ -0,0 +1,52 @@
package vexriscv.periph.gcd
import spinal.core._
import spinal.sim._
import spinal.core.sim._
//import scala.util.Random
import java.util.concurrent.ThreadLocalRandom
object GCDTopSim {
def main(args: Array[String]) {
SimConfig.withWave.doSim(new GCDTop()){dut =>
// SimConfig.doSim(new GCDTop()){dut =>
def gcd(a: Long,b: Long): Long = {
if(b==0) a else gcd(b, a%b)
}
def RndNextUInt32(): Long = {
ThreadLocalRandom.current().nextLong(Math.pow(2, 32).toLong - 1)
}
var a = 0L
var b = 0L
var model = 0L
dut.io.a #= 0
dut.io.b #= 0
dut.io.valid #= false
dut.clockDomain.forkStimulus(period = 10)
dut.clockDomain.waitRisingEdge()
for(idx <- 0 to 500){
// generate 2 random ints
a = RndNextUInt32()
b = RndNextUInt32()
// calculate the model value (software)
model = gcd(a,b)
// apply stimulus with random ints
dut.io.a #= a
dut.io.b #= b
dut.io.valid #= true
dut.clockDomain.waitRisingEdge()
dut.io.valid #= false
// wait until calculation of hardware is done
waitUntil(dut.io.ready.toBoolean)
assert(
assertion = (dut.io.res.toBigInt == model),
message = "test " + idx + " failed. Expected " + model + ", retrieved: " + dut.io.res.toBigInt
)
waitUntil(!dut.io.ready.toBoolean)
}
}
}
}

140
doc/nativeJtag/README.md Normal file
View file

@ -0,0 +1,140 @@
# Implementing VexRiscv Based Murax SoC on Arty A7 Artix-7 PCB from Digilent and Enabling JTAG Connection through Xilinxs BSCANE2 Debug IP
**By**<br>
**Pradeep Krishnamurthy Student Research Assistant, OFFIS e.V.**<br>
**Frank Poppen Senior Research Engineer, OFFIS e.V.**<br>
**www.offis.de**
Acknowledgement
This work was supported in part by the German Federal Ministry of Education and Research (BMBF) within the project
SATiSFy under contract no. 16KIS0821K, and within the project Scale4Edge under contract no. 16ME0127.
## 1. Introduction
Up-to-date FPGA evaluation boards, like the Digilent Arty A7 mounting a Xilinx Artix-7 FPGA, come with an integrated
FTDI chip which makes programming and debugging quite easy. In our work, we synthesized the VexRiscv based Murax
processor to an Artix-7 FPGA and at first lead out the JTAG relevant signals of the Riscv core to the boards Pmod
Header to connect to a dedicated Olimex JTAG Adapter through a second USB cable. As it turns out, this extra effort
on hardware can be minimized by use of some Xilinx Debug IP named BSCANE2. Collecting the required information on how
to do this was tedious. So we came to the decision to document our path to success with this short report. We expect
that the reader is familiar with the README.md to be found at https://github.com/SpinalHDL/VexRiscv and that the
reader is capable of generating the Murax SoC as it is described there.
## 2. SpinalHDL - Generation of Murax SoC with BSCANE2
The BSCANE2 allows access between the internal FPGA logic and the JTAG Boundary Scan logic controller. This allows
for communication between the internally running design and the dedicated JTAG pins of the FPGA.
Run the following command at the top level of the repository.
```sh
sbt "runMain vexriscv.demo.MuraxWithRamInitWithNativeJtag"
```
The Murax configuration `MuraxWithRamInitWithNativeJtag` activates `WithNativeJtag` flag, which removes toplevel Jtag signals from the default Murax configuration and integrates `BSCANE2` plugin.
After code generation you will see the Verilog file `Murax.v` next to four `.bin` files at the top level of the repository. These files are the input to the Xilinx FPGA synthesis. Inside the `Murax.v` file, we can see that the BSCANE2 ports are instantiated, confirming that the BSCANE2 has successfully been instantiated within the Murax SoC as a debug bridge to JTAG.
## 3. Xilinx Vivado - Programming Arty A7 FPGA
There are many applications to program a FPGA. In our work we referred to the freely available Xilinx Vivado 2020
application to synthesize and program the FPGA. Vivado is readily available at Xilinx website and free of cost to
download. This document assumes that the reader is able to setup and execute FPGA synthesis projects. The
following is not a step by step tutorial, but gives general guiding information.
### Programming the FPGA
* Create a new project and choose the board. In our case it is the Arty A7-35 (`xc7a35ticsg324-1L`).
* Copy the mentioned files (.v and .bin) of the previous section from the Vexriscv folder into the Vivado project
in e.g. the path: `project_name.srcs\sources_1\imports\Downloads`
* Create a toplevel file by instantiating Murax I/O ports in it to blink the LEDs on the Digilent board. (Note: The program to blink the LEDs is already present in the four `.bin` files with the `Murax.v` file). The toplevel file and constraint `arty_a7.xdc` file, if required, can be found and reused from the path: `VexRiscv/scripts/Murax/arty_a7`, but you need to make sure that all the JTAG ports of Murax are commented or deleted in the toplevel file. Remember: we removed them in Section 2 and connected them internally to the BSCANE2 debug bridge.
* Be aware that line numbers as given could move with future changes to the file. The lines to remove from toplevel file are:
```
[43] reg tesic_tck,tesic_tms,tesic_tdi;
[44] wire tesic_tdo;
[45] reg soc_tck,soc_tms,soc_tdi;
[46] wire soc_tdo;
[47]
[48] always @(*) begin
[49] {soc_tck, soc_tms, soc_tdi } = {tck,tms,tdi};
[50] tdo = soc_tdo;
[51] end
[56] .io_jtag_tck(soc_tck),
[57] .io_jtag_tdi(soc_tdi),
[58] .io_jtag_tdo(soc_tdo),
[59] .io_jtag_tms(soc_tms),
```
* Also remove any JTAG port to pin assignments from any constraint file.
* Next, click Generate Bitstream and program the FPGA with the bit file. You can see the LEDs blink and Murax SoC has been programmed into the FPGA.
### 4. Debugging - Using OpenOCD and GDB
* Clone and setup openocd with the steps as provided by https://github.com/SpinalHDL/openocd_riscv
* You basically have to provide two files for OpenOCD to connect successfully through the FPGA into the Murax SoC inside it:
1. `usb_connect.cfg` (interface configuration)
2. `soc_init.cfg` (take over the control of the CPU)
* `usb_connect.cfg`
You can take it from ... https://github.com/SpinalHDL/SaxonSoc/blob/dev-0.3/bsp/digilent/ArtyA7SmpLinux/openocd/usb_connect.cfg ... without modifications as we would say. Be aware that it includes the two files `xilinx-xc7.cfg` and `jtagspi.cfg` which are part of the OpenOCD project ... https://github.com/riscv/riscv-openocd/tree/riscv/tcl/cpld , but make sure to check the path for the files. If required, adapt the find and path for the lines:
```
[29] source [find cpld/xilinx-xc7.cfg]
[30] source [find cpld/jtagspi.cfg]
```
* `soc_init.cfg`
https://github.com/SpinalHDL/SaxonSoc/blob/dev-0.3/bsp/digilent/ArtyA7SmpLinux/openocd/soc_init.cfg
You can take it but you need to: `set cpu_count to 1` and remove lines 22 to 35 as shown in the result below:
```
set cpu_count 1
for {set i 0} {$i < $cpu_count} {incr i} {
target create saxon.cpu$i vexriscv -endian little -chain-position $TAP_NAME -coreid $i -dbgbase [expr $i*0x1000+0x10B80000]
vexriscv readWaitCycles 40
vexriscv cpuConfigFile $CPU0_YAML
if {$SPINAL_SIM != "yes"} {
vexriscv jtagMapping 3 3 0 1 2 2
}
}
for {set i 0} {$i < $cpu_count} {incr i} {
targets saxon.cpu$i
poll_period 50
init
soft_reset_halt
}
puts " done"
```
* Run openocd:
```
openocd -c "set CPU0_YAML ../VexRiscv/cpu0.yaml" \
-f tcl/interface/usb_connect.cfg \
-f tcl/interface/soc_init.cfg
```
On success you should be able to see something like
```
Open On-Chip Debugger 0.10.0+dev-01231-gf8c1c8ad-dirty (2021-05-03-10:57)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
../../cpu0.yaml
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
xc7.tap
Info : set servers polling period to 50ms
Info : clock speed 5000 kHz
Info : JTAG tap: xc7.tap tap/device found: 0x0362d093 (mfg: 0x049 (Xilinx), part: 0x362d, ver: 0x0)
Info : starting gdb server for saxon.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
requesting target halt and executing a soft reset
done
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
```
* Information on setting up a riscv compiler and debugger toolchain are to be found at:
https://github.com/riscv/riscv-gnu-toolchain
* With openocd running you can now connect a debugger to `port 3333`.
* A demonstration software to compile and debug with the Murax SoC can be found at https://github.com/SpinalHDL/VexRiscvSocSoftware in the path `VexRiscvSocSoftware/projects/murax/demo`. With a `make` you create the `.elf` in the `build` directory from which you then give the command:
```
riscv64-unknown-elf-gdb demo.elf
```
* The riscv debugger is started with the `demo.elf` program and is ready to be connected to the CPU. Do so by issuing the following command in its window:
* `target remote localhost:3333` This command will connect the GDB server to OpenOCD
* `load` This command will load the program into the FPGA. Whenever you decide to make changes to the demo software and recompiled it, you need to upload the resulting new executable to the CPU in this way.
* `monitor reset halt` This command resets the Murax CPU and halts it to receive further commands.
* `continue` From here on you should be able to execute a regular debug session with your VexRiscv based Murax SoC on the FPGA.

View file

@ -0,0 +1,26 @@
if [info exists env(SPINAL_SIM)] {
set SPINAL_SIM $::env(SPINAL_SIM)
} else {
set SPINAL_SIM no
}
set cpu_count 1
for {set i 0} {$i < $cpu_count} {incr i} {
target create saxon.cpu$i vexriscv -endian little -chain-position $TAP_NAME -coreid $i -dbgbase [expr $i*0x1000+0x10B80000]
vexriscv readWaitCycles 40
vexriscv cpuConfigFile $CPU0_YAML
if {$SPINAL_SIM != "yes"} {
vexriscv jtagMapping 3 3 0 1 2 2
}
}
for {set i 0} {$i < $cpu_count} {incr i} {
targets saxon.cpu$i
poll_period 50
init
soft_reset_halt
}
puts " done"

View file

@ -0,0 +1,14 @@
adapter driver ftdi
ftdi_device_desc "Digilent USB Device"
ftdi_vid_pid 0x0403 0x6010
ftdi_channel 0
ftdi_layout_init 0x00e8 0x60eb
ftdi_tdo_sample_edge falling
reset_config none
adapter speed 5000
source [find cpld/xilinx-xc7.cfg]
source [find cpld/jtagspi.cfg]
set TAP_NAME xc7.tap

216
doc/smp/smp.md Normal file
View file

@ -0,0 +1,216 @@
# Coherent interface specification
Features :
- 3 interface (write, read, probe) composed of 7 streams
- Two data paths (read + write), but allow dirty/clean sharing by reusing the write data path
- Allow multi level coherent interconnect
- No ordering, but provide barrier
- Allow cache-full and cache-less agents
## A few hint to help reading the spec
In order to make the spec more readable, there is some definitions :
### Stream
A stream is a primitive interface which carry transactions using a valid/ready handshake.
### Memory copy
To talk in a non abstract way, in a system with multiple caches, a given memory address can potentialy be loaded in multiple caches at the same time. So let's define that :
- The DDR memory is named `main memory`
- Each cache line can be loaded with a part of the main memory, let's name that a `memory copy`
### Master / Interconnect / Slave
A master could be for instance a CPU cache, the side of the interconnect toward the main memory or toward a more general interconnect.
A slave could be main memory, the side of the interconnect toward a CPU cache or toward a less general interconnect.
The spec will try to stay abstract and define the coherent interface as something which can be used between two agents (cpu, interconnect, main memory)
## Memory copy status
Memory copy, in other words, cache line, have more states than non coherent systems :
| Name | Description |
|---------------|-------------|
| Valid/Invalid | Line loaded or not |
| Shared/Unique | shared => multiple copy of the cache line in different caches, unique => no other caches has a copy of the line |
| Owner/Lodger | lodger => copy of the line, but no other responsibility, owner => the given cache is responsible to write back dirty data and answer probes with the data |
| Clean/Dirty | clean => match main memory, dirty => main memory need updates |
All combination of those cache flag are valid. But if a cache line is invalid, the other status have no meaning.
Later in the spec, memory copy state can be described for example as :
- VSOC for (Valid, Shared, Owner, Clean)
- V-OC for (Valid, Shared or Unique, Owner, Clean)
- !V-OC for NOT (Valid, Shared or Unique, Owner, Clean)
- ...
## Coherent interface
One full coherent interface is composed of 3 inner interfaces, them-self composed of 7 stream described bellow as `interfaceName (Side -> StreamName -> Side -> StreamName -> ...)`
- write (M -> writeCmd -> S -> writeRsp -> M)
- read (M -> readCmd- > S -> readRsp -> M -> readAck -> S)
- probe (S -> probeCmd -> M -> probeRsp -> S)
The following streams could physically be merges in order to reduce the number of arbitration :
- writeCmd, probeRsp, readAck
- writeRsp, readRsp
### Read interface
Used by masters to obtain new memory copies and make copies unique (used to write them).
Composed of 3 stream :
| Name | Direction | Description |
|---------|-----------|----------|
| readCmd | M -> S | Emit memory read and cache management commands |
| readRsp | M <- S | Return some data and/or a status from readCmd |
| readAck | M -> S | Return ACK from readRsp to synchronize the interconnect status |
### Write interface
Used by masters to write data back to the memory and notify the interconnect of memory copies eviction (used to keep potential directories updated).
Composed of 2 stream :
| Name | Direction | Description |
|---------|-----------|----------|
| writeCmd | M -> S | Emit memory writes and cache management commands |
| writeRsp | M <- S | Return a status from writeCmd |
### Probe interface
Used by the interconnect to order master to change their memory copies status and get memory copies owners data.
Composed of 2 stream :
| Name | Direction | Description |
|----------|-----------|----------|
| probeCmd | M <- S | Used for cache management |
| probeRsp | M -> S | Acknowledgment |
## Transactions
This chapter define transactions moving over the 3 previously defined interface (read/write/probe).
### Read commands
Emitted on the readCmd channel (master -> slave)
| Command | Initial state | Description | Usage example |
|-------------|---------------|----------|------|
| readShared | I--- | Get a memory copy as V--- | Want to read a uncached address |
| readUnique | I--- | Get a memory copy as VUO- | Want to write a uncached address |
| readOnce | I--- | Get a memory copy without coherency tracking | Instruction cache read |
| makeUnique | VS-- | Make other memory copy as I--- and make yourself VUO- | Want to write into a shared line |
| readBarrier | N/A | Ensure that the visibility of the memory operations of this channel do not cross the barrier | ISA fence |
makeUnique should be designed with care. There is a few corner cases :
- While a master has a inflight makeUnique, a probe can change its state, in such case, the makeUnique become weak and invalidation is canceled. This is usefull for multi level coherent interconnects.
- Multi level coherent interconnect should be careful to properly move the ownership and not lose dirty data
I'm not sure yet if we should add some barrier transactions to enforce
### Read responses
Emitted on the readRsp channel (master <- slave)
readSuccess, readError, data shared/unique clean/dirty owner/notOwner
| Responses | From command | Description |
|-------------|---------------|----------|
| readSuccess | makeUnique, readBarrier | - |
| readError | readShared, readUnique, readOnce | Bad address |
| readData | readShared, readUnique, readOnce | Data + coherency status (V---) |
### Read ack
Emitted on the readAck channel (master -> slave), it carry no information, just a notification that the master received the read response
| Name | From command | Description |
|--------------|---------------|----------|
| readSuccess | * | - |
### Write commands
Write commands can be emitted on the writeCmd channel (master -> slave)
| Name | Initial state | Description | Usage example |
|--------------|---------------|----------|----------|
| writeInvalid | V-O- | Write the memory copy and update it status to I--- | Need to free the dirty cache line |
| writeShare | V-O- | Write the memory copy but keep it as VSO- | A probe makeShared asked it |
| writeUnique | VUO- | Write the memory copy but keep it as VUO- | A probe probeOnce need to read the data |
| evict | V---, !V-OD | Notify the interconnect that the cache line is now I--- | Need to free a clean cache line |
| writeBarrier | N/A | Ensure that the visibility of the memory operations of this channel do not cross the barrier | ISA fence |
### Write responses
Emitted on the writeRsp channel (master <- slave), it carry no information, just a notification that the corresponding command is done.
| Name | From command | Description |
|--------------|---------------|----------|
| writeSuccess | * | - |
### Probe commands
Probe commands can be emitted on the probeCmd channel (slave -> master)
| Name | Description | Usage example |
|-------------|-------------|---------------|
| makeInvalid | Make the memory copy I--- | Another cache want to make his shared copy unique to write it |
| makeShared | Make the memory copy VS-- | Another cache want to read a memory block, so unique copy need to be shared |
| probeOnce | Read the V-O- memory copy | A non coherent agent did a readOnce |
makeInvalid and makeShared could result into one of the following probeSuccess, writeInvalid, writeShare
probeOnce can result into one of the following probeSuccess, writeShare, writeUnique
To help the slave matching the writeInvalid and writeShare generated from a probe, those request are tagged with a matching ID.
### Probe responses
Emitted on the probeRsp channel (master -> slave), it carry no information, just a notification that the corresponding command is done.
| Name | From command | Description |
|--------------|---------------|----------|
| probeSuccess | * | - |
## Channel interlocking
This is a delicate subject as if everything was permited, it would be easy to end up with deadlocks.
There is the streams priority (top => high priority, bottom => low priority) A lower priority stream should not block a higher priority stream in order to avoid deadlocks.
- writeCmd, writeRsp, readRsp, readAck, probeRsp. Nothing should realy block them excepted bandwidth
- probeCmd. Can be blocked by inflight/generated writes
- readCmd. Can be blocked by inflight/generated probes
In other words :
Masters can emit writeCmd and wait their writeRsp completion before answering probes commands.
Slaves can emit probeCmd and wait their proveRsp completion before answering reads.
Slaves can emit readRsp and wait on their readAck completion before doing anything else
## Interface subsets
There is a few cases where you could need a specific subset of the coherent interface :
- Instruction caches do not necessarily need to maintain the coherency with the memory system.
- DMA need to read and write the memory system, but are cache-less (no probe)
### ReadOnly interface without maintained coherency
Such interface is only composed of the read bus on which the readCmd stream can only use readOnce requests
### WriteOnly interface
In such interface, there is no read/probe buses, but only a writeCmd and a writeRsp stream. The writeCmd will invalidate other memory copies, then write into the memory while the writeRsp will return a writeSuccess/writeError status.

106
doc/vjtag/README.md Normal file
View file

@ -0,0 +1,106 @@
# Intel VJTAG
*By Levi Walker (@LYWalker)*
Intel VJTAG allows JTAG communication with the FPGA fabric of Altera devices through the standard USB cable using the onboard USB-Blaster. This avoids the needs to breakout the JTAG signals to the GPIO and use a dedicated external debugger.
## How to use VJTAG with Briey
In Briey.scala remove the following lines (note: line numbers may differ, depending on edits):
```
[185] val jtag = slave(Jtag())
...
[466] val tcpJtag = JtagTcp(
[467] jtag = dut.io.jtag,
[468] jtagClkPeriod = jtagClkPeriod
[469] )
```
Then VJAG can be added in two ways.
### Method 1
Replace the following line in Briey.scala:
```
[311] io.jtag <> plugin.io.bus.fromJtag()
```
with
```
[311] plugin.io.bus.fromVJtag()
```
### Method 2
Replace the following line in Briey.scala:
```
[311] io.jtag <> plugin.io.bus.fromJtag()
```
with
```
[311] val tap = new sld_virtual_jtag(2)
[312] val jtagCtrl = tap.toJtagTapInstructionCtrl()
[313] jtagCtrl <> plugin.io.bus.fromJtagInstructionCtrl(ClockDomain(tap.io.tck),0)
```
And add
```
import spinal.lib.blackbox.altera.sld_virtual_jtag
```
to the imports at the top of the file.
This uses the existing JtagInstructionCtrl architecture and communicates using DR headers.
## Using OpenOCD
First, clone and setup openocd with the steps as provided by https://github.com/SpinalHDL/openocd_riscv
Then in tcl/target/Briey.cfg set `_USE_VJTAG` to 1:
```
[3] set _USE_VJTAG 1
```
Then if you used Method 1 above uncomment line 25:
```
[25] vexriscv jtagMapping 0 1 0 0 0 0
```
If you used Method 2 uncomment line 27:
```
[27] vexriscv jtagMapping 0 0 0 1 2 2
```
If the board uses USB-Blaster2 then run OpenOCD in shell using:
```
openocd -c "set CPU0_YAML ../VexRiscv/cpu0.yaml" \
-f tcl/interface/altera-usb-blaster2.cfg \
-f tcl/interface/soc_init.cfg
```
Note: you may need to edit `tcl/interface/altera-usb-blaster2.cfg` with your quartus path.
If using an older board using USB-Blaster run using:
```
openocd -c "set CPU0_YAML ../VexRiscv/cpu0.yaml" -f tcl/interface/altera-usb-blaster.cfg -f tcl/interface/Briey.cfg
```
On success it should look something like:
```
Open On-Chip Debugger 0.11.0+dev-02588-gb10abb4b1 (2022-11-07-13:38)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
../../Verilog/cpu0.yaml
Info : only one transport option; autoselect 'jtag'
DEPRECATED! use 'adapter speed' not 'adapter_khz'
DEPRECATED! use 'adapter srst delay' not 'adapter_nsrst_delay'
Info : set servers polling period to 50ms
Info : usb blaster interface using libftdi
Info : This adapter doesn't support configurable speed
Info : JTAG tap: fpgasoc.fpga.tap tap/device found: 0x020f20dd (mfg: 0x06e (Altera), part: 0x20f2, ver: 0x0)
[fpga_spinal.cpu0] Target successfully examined.
Info : starting gdb server for fpga_spinal.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
requesting target halt and executing a soft reset
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
```
From this point on attach a gdb connection and debug the board as usual.
*NOTE: You may need to add your boards FPGA ID to line [21] of Briey.cfg, simply append it to the other expected ids using: `-expected-id <your id>`. The IDs for the DE1-SoC and DE0 have already been added.*

View file

@ -1 +1 @@
sbt.version=0.13.16
sbt.version=1.6.0

View file

@ -1,2 +0,0 @@
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.1")

View file

@ -0,0 +1,129 @@
This example is for the Digilent ARTY A7 35T board.
# Using the example
## Before Starting
You should make sure you have the following tools installed:
* vivado 2018.1 or later
* riscv toolchain (riscv64-unknown-elf)
* sbt
## Board setup
Make sure you have a rev E board. If you have a later version check that the
flash part is S25FL128SAGMF100.
Jumper settings for board rev E:
* Disconnect anything from the connectors (Pmod, Arduino)
* Jumpers: JP1 and JP2 on, others off.
## Building
You should be able to just type `make` and get output similar to this;
```
...
Memory region Used Size Region Size %age Used
RAM: 896 B 2 KB 43.75%
...
---------------------------------------------------------------------------------
Finished RTL Elaboration : Time (s): cpu = 00:00:08 ; elapsed = 00:00:09 . Memory (MB): peak = 1457.785 ; gain = 243.430 ; free physical = 17940 ; free virtual = 57159
---------------------------------------------------------------------------------
...
---------------------------------------------------------------------------------
Finished Technology Mapping : Time (s): cpu = 00:02:42 ; elapsed = 00:02:58 . Memory (MB): peak = 1986.879 ; gain = 772.523 ; free physical = 17454 ; free virtual = 56670
---------------------------------------------------------------------------------
...
---------------------------------------------------------------------------------
Finished Writing Synthesis Report : Time (s): cpu = 00:02:45 ; elapsed = 00:03:01 . Memory (MB): peak = 1986.879 ; gain = 772.523 ; free physical = 17457 ; free virtual = 56673
---------------------------------------------------------------------------------
...
Writing bitstream ./toplevel.bit...
...
mmi files generated
...
********************************************
./soc_latest_sw.bit correctly generated
********************************************
...
********************************************
./soc_latest_sw.mcs correctly generated
********************************************
INFO: [Common 17-206] Exiting Vivado at Thu Nov 28 04:00:50 2019...
```
The process should take around 8 minutes on a reasonably fast computer.
## Programming
### Direct FPGA RAM programming
Run `make prog` to program the bit file directly to FPGA RAM.
You should get output like the following;
```
...
****** Xilinx hw_server v2018.1
**** Build date : Apr 4 2018-18:56:09
** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
INFO: [Labtoolstcl 44-466] Opening hw_target localhost:3121/xilinx_tcf/Digilent/210319AB569AA
INFO: [Labtools 27-1434] Device xc7a35t (JTAG device index = 0) is programmed with a design that has no supported debug core(s) in it.
WARNING: [Labtools 27-3361] The debug hub core was not detected.
Resolution:
1. Make sure the clock connected to the debug hub (dbg_hub) core is a free running clock and is active.
2. Make sure the BSCAN_SWITCH_USER_MASK device property in Vivado Hardware Manager reflects the user scan chain setting in the design and refresh the device. To determine the user scan chain setting in the design, open the implemented design and use 'get_property C_USER_SCAN_CHAIN [get_debug_cores dbg_hub]'.
For more details on setting the scan chain property, consult the Vivado Debug and Programming User Guide (UG908).
INFO: [Labtools 27-3164] End of startup status: HIGH
INFO: [Common 17-206] Exiting Vivado at Thu Nov 28 04:01:36 2019...
```
After programming the LED4~LED7 shall show some activity.
### QSPI flash programming
Run `make flash` to program the bit file to the QSPI flash.
You should get output like the following;
```
...
****** Xilinx hw_server v2018.1
**** Build date : Apr 4 2018-18:56:09
** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
INFO: [Labtoolstcl 44-466] Opening hw_target localhost:3121/xilinx_tcf/Digilent/210319AB569AA
INFO: [Labtools 27-1434] Device xc7a35t (JTAG device index = 0) is programmed with a design that has no supported debug core(s) in it.
...
INFO: [Labtools 27-3164] End of startup status: HIGH
Mfg ID : 1 Memory Type : 20 Memory Capacity : 18 Device ID 1 : 0 Device ID 2 : 0
Performing Erase Operation...
Erase Operation successful.
Performing Program and Verify Operations...
Program/Verify Operation successful.
INFO: [Labtoolstcl 44-377] Flash programming completed successfully
program_hw_cfgmem: Time (s): cpu = 00:00:00.11 ; elapsed = 00:00:52 . Memory (MB): peak = 1792.711 ; gain = 8.000 ; free physical = 17712 ; free virtual = 56943
INFO: [Labtoolstcl 44-464] Closing hw_target localhost:3121/xilinx_tcf/Digilent/210319AB569AA
...
INFO: [Common 17-206] Exiting Vivado at Thu Nov 28 04:06:28 2019...
```
After programming the flash you need to press the "PROG" button on the board. Then after a second or so the "DONE" LED shall be ON and LED4~LED7 shall show some activity.
## Connect
After programming you should be able to connect to the serial port and have some output.
On Linux you can do this using a command like `screen /dev/ttyUSB1`. Other good alternatives:
* moserial (GUI)
* picocom (can be launched via the file "picocom_arty")
Parameters:
* port is : /dev/ttyUSB1
* flowcontrol : none
* baudrate is : 115200
* parity is : none
* databits are : 8
* stopbits are : 1

View file

@ -0,0 +1,366 @@
set_property PACKAGE_PIN F4 [get_ports tck]
set_property IOSTANDARD LVCMOS33 [get_ports tck]
set_property PACKAGE_PIN D2 [get_ports tms]
set_property IOSTANDARD LVCMOS33 [get_ports tms]
set_property PACKAGE_PIN D4 [get_ports tdo]
set_property IOSTANDARD LVCMOS33 [get_ports tdo]
set_property PULLUP true [get_ports tdo]
set_property PACKAGE_PIN E2 [get_ports tdi]
set_property IOSTANDARD LVCMOS33 [get_ports tdi]
set_property PACKAGE_PIN D3 [get_ports trst]
set_property IOSTANDARD LVCMOS33 [get_ports trst]
set_property PULLUP true [get_ports trst]
## serial:0.tx
set_property PACKAGE_PIN D10 [get_ports serial_tx]
set_property IOSTANDARD LVCMOS33 [get_ports serial_tx]
## serial:0.rx
set_property PACKAGE_PIN A9 [get_ports serial_rx]
set_property IOSTANDARD LVCMOS33 [get_ports serial_rx]
## clk100:0
set_property PACKAGE_PIN E3 [get_ports clk100]
set_property IOSTANDARD LVCMOS33 [get_ports clk100]
## cpu_reset:0
set_property PACKAGE_PIN C2 [get_ports cpu_reset]
set_property IOSTANDARD LVCMOS33 [get_ports cpu_reset]
## eth_ref_clk:0
#set_property LOC G18 [get_ports eth_ref_clk]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_ref_clk]
## user_led:0
set_property PACKAGE_PIN H5 [get_ports user_led0]
set_property IOSTANDARD LVCMOS33 [get_ports user_led0]
## user_led:1
set_property PACKAGE_PIN J5 [get_ports user_led1]
set_property IOSTANDARD LVCMOS33 [get_ports user_led1]
## user_led:2
set_property PACKAGE_PIN T9 [get_ports user_led2]
set_property IOSTANDARD LVCMOS33 [get_ports user_led2]
## user_led:3
set_property PACKAGE_PIN T10 [get_ports user_led3]
set_property IOSTANDARD LVCMOS33 [get_ports user_led3]
## user_sw:0
set_property PACKAGE_PIN A8 [get_ports user_sw0]
set_property IOSTANDARD LVCMOS33 [get_ports user_sw0]
## user_sw:1
set_property PACKAGE_PIN C11 [get_ports user_sw1]
set_property IOSTANDARD LVCMOS33 [get_ports user_sw1]
## user_sw:2
set_property PACKAGE_PIN C10 [get_ports user_sw2]
set_property IOSTANDARD LVCMOS33 [get_ports user_sw2]
## user_sw:3
set_property PACKAGE_PIN A10 [get_ports user_sw3]
set_property IOSTANDARD LVCMOS33 [get_ports user_sw3]
## user_btn:0
set_property PACKAGE_PIN D9 [get_ports user_btn0]
set_property IOSTANDARD LVCMOS33 [get_ports user_btn0]
## user_btn:1
set_property PACKAGE_PIN C9 [get_ports user_btn1]
set_property IOSTANDARD LVCMOS33 [get_ports user_btn1]
## user_btn:2
set_property PACKAGE_PIN B9 [get_ports user_btn2]
set_property IOSTANDARD LVCMOS33 [get_ports user_btn2]
## user_btn:3
set_property PACKAGE_PIN B8 [get_ports user_btn3]
set_property IOSTANDARD LVCMOS33 [get_ports user_btn3]
## spiflash_1x:0.cs_n
#set_property LOC L13 [get_ports spiflash_1x_cs_n]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_cs_n]
# ## spiflash_1x:0.mosi
#set_property LOC K17 [get_ports spiflash_1x_mosi]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_mosi]
# ## spiflash_1x:0.miso
#set_property LOC K18 [get_ports spiflash_1x_miso]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_miso]
# ## spiflash_1x:0.wp
#set_property LOC L14 [get_ports spiflash_1x_wp]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_wp]
# ## spiflash_1x:0.hold
#set_property LOC M14 [get_ports spiflash_1x_hold]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_hold]
# ## ddram:0.a
#set_property LOC R2 [get_ports ddram_a[0]]
#set_property SLEW FAST [get_ports ddram_a[0]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[0]]
# ## ddram:0.a
#set_property LOC M6 [get_ports ddram_a[1]]
#set_property SLEW FAST [get_ports ddram_a[1]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[1]]
# ## ddram:0.a
#set_property LOC N4 [get_ports ddram_a[2]]
#set_property SLEW FAST [get_ports ddram_a[2]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[2]]
# ## ddram:0.a
#set_property LOC T1 [get_ports ddram_a[3]]
#set_property SLEW FAST [get_ports ddram_a[3]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[3]]
# ## ddram:0.a
#set_property LOC N6 [get_ports ddram_a[4]]
#set_property SLEW FAST [get_ports ddram_a[4]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[4]]
# ## ddram:0.a
#set_property LOC R7 [get_ports ddram_a[5]]
#set_property SLEW FAST [get_ports ddram_a[5]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[5]]
# ## ddram:0.a
#set_property LOC V6 [get_ports ddram_a[6]]
#set_property SLEW FAST [get_ports ddram_a[6]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[6]]
# ## ddram:0.a
#set_property LOC U7 [get_ports ddram_a[7]]
#set_property SLEW FAST [get_ports ddram_a[7]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[7]]
# ## ddram:0.a
#set_property LOC R8 [get_ports ddram_a[8]]
#set_property SLEW FAST [get_ports ddram_a[8]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[8]]
# ## ddram:0.a
#set_property LOC V7 [get_ports ddram_a[9]]
#set_property SLEW FAST [get_ports ddram_a[9]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[9]]
# ## ddram:0.a
#set_property LOC R6 [get_ports ddram_a[10]]
#set_property SLEW FAST [get_ports ddram_a[10]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[10]]
# ## ddram:0.a
#set_property LOC U6 [get_ports ddram_a[11]]
#set_property SLEW FAST [get_ports ddram_a[11]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[11]]
# ## ddram:0.a
#set_property LOC T6 [get_ports ddram_a[12]]
#set_property SLEW FAST [get_ports ddram_a[12]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[12]]
# ## ddram:0.a
#set_property LOC T8 [get_ports ddram_a[13]]
#set_property SLEW FAST [get_ports ddram_a[13]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[13]]
# ## ddram:0.ba
#set_property LOC R1 [get_ports ddram_ba[0]]
#set_property SLEW FAST [get_ports ddram_ba[0]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_ba[0]]
# ## ddram:0.ba
#set_property LOC P4 [get_ports ddram_ba[1]]
#set_property SLEW FAST [get_ports ddram_ba[1]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_ba[1]]
# ## ddram:0.ba
#set_property LOC P2 [get_ports ddram_ba[2]]
#set_property SLEW FAST [get_ports ddram_ba[2]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_ba[2]]
# ## ddram:0.ras_n
#set_property LOC P3 [get_ports ddram_ras_n]
#set_property SLEW FAST [get_ports ddram_ras_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_ras_n]
# ## ddram:0.cas_n
#set_property LOC M4 [get_ports ddram_cas_n]
#set_property SLEW FAST [get_ports ddram_cas_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_cas_n]
# ## ddram:0.we_n
#set_property LOC P5 [get_ports ddram_we_n]
#set_property SLEW FAST [get_ports ddram_we_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_we_n]
# ## ddram:0.cs_n
#set_property LOC U8 [get_ports ddram_cs_n]
#set_property SLEW FAST [get_ports ddram_cs_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_cs_n]
# ## ddram:0.dm
#set_property LOC L1 [get_ports ddram_dm[0]]
#set_property SLEW FAST [get_ports ddram_dm[0]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dm[0]]
# ## ddram:0.dm
#set_property LOC U1 [get_ports ddram_dm[1]]
#set_property SLEW FAST [get_ports ddram_dm[1]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dm[1]]
# ## ddram:0.dq
#set_property LOC K5 [get_ports ddram_dq[0]]
#set_property SLEW FAST [get_ports ddram_dq[0]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[0]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[0]]
# ## ddram:0.dq
#set_property LOC L3 [get_ports ddram_dq[1]]
#set_property SLEW FAST [get_ports ddram_dq[1]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[1]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[1]]
# ## ddram:0.dq
#set_property LOC K3 [get_ports ddram_dq[2]]
#set_property SLEW FAST [get_ports ddram_dq[2]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[2]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[2]]
# ## ddram:0.dq
#set_property LOC L6 [get_ports ddram_dq[3]]
#set_property SLEW FAST [get_ports ddram_dq[3]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[3]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[3]]
# ## ddram:0.dq
#set_property LOC M3 [get_ports ddram_dq[4]]
#set_property SLEW FAST [get_ports ddram_dq[4]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[4]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[4]]
# ## ddram:0.dq
#set_property LOC M1 [get_ports ddram_dq[5]]
#set_property SLEW FAST [get_ports ddram_dq[5]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[5]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[5]]
# ## ddram:0.dq
#set_property LOC L4 [get_ports ddram_dq[6]]
#set_property SLEW FAST [get_ports ddram_dq[6]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[6]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[6]]
# ## ddram:0.dq
#set_property LOC M2 [get_ports ddram_dq[7]]
#set_property SLEW FAST [get_ports ddram_dq[7]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[7]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[7]]
# ## ddram:0.dq
#set_property LOC V4 [get_ports ddram_dq[8]]
#set_property SLEW FAST [get_ports ddram_dq[8]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[8]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[8]]
# ## ddram:0.dq
#set_property LOC T5 [get_ports ddram_dq[9]]
#set_property SLEW FAST [get_ports ddram_dq[9]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[9]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[9]]
# ## ddram:0.dq
#set_property LOC U4 [get_ports ddram_dq[10]]
#set_property SLEW FAST [get_ports ddram_dq[10]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[10]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[10]]
# ## ddram:0.dq
#set_property LOC V5 [get_ports ddram_dq[11]]
#set_property SLEW FAST [get_ports ddram_dq[11]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[11]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[11]]
# ## ddram:0.dq
#set_property LOC V1 [get_ports ddram_dq[12]]
#set_property SLEW FAST [get_ports ddram_dq[12]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[12]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[12]]
# ## ddram:0.dq
#set_property LOC T3 [get_ports ddram_dq[13]]
#set_property SLEW FAST [get_ports ddram_dq[13]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[13]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[13]]
# ## ddram:0.dq
#set_property LOC U3 [get_ports ddram_dq[14]]
#set_property SLEW FAST [get_ports ddram_dq[14]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[14]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[14]]
# ## ddram:0.dq
#set_property LOC R3 [get_ports ddram_dq[15]]
#set_property SLEW FAST [get_ports ddram_dq[15]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[15]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[15]]
# ## ddram:0.dqs_p
#set_property LOC N2 [get_ports ddram_dqs_p[0]]
#set_property SLEW FAST [get_ports ddram_dqs_p[0]]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_dqs_p[0]]
# ## ddram:0.dqs_p
#set_property LOC U2 [get_ports ddram_dqs_p[1]]
#set_property SLEW FAST [get_ports ddram_dqs_p[1]]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_dqs_p[1]]
# ## ddram:0.dqs_n
#set_property LOC N1 [get_ports ddram_dqs_n[0]]
#set_property SLEW FAST [get_ports ddram_dqs_n[0]]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_dqs_n[0]]
# ## ddram:0.dqs_n
#set_property LOC V2 [get_ports ddram_dqs_n[1]]
#set_property SLEW FAST [get_ports ddram_dqs_n[1]]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_dqs_n[1]]
# ## ddram:0.clk_p
#set_property LOC U9 [get_ports ddram_clk_p]
#set_property SLEW FAST [get_ports ddram_clk_p]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_clk_p]
# ## ddram:0.clk_n
#set_property LOC V9 [get_ports ddram_clk_n]
#set_property SLEW FAST [get_ports ddram_clk_n]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_clk_n]
# ## ddram:0.cke
#set_property LOC N5 [get_ports ddram_cke]
#set_property SLEW FAST [get_ports ddram_cke]
#set_property IOSTANDARD SSTL15 [get_ports ddram_cke]
# ## ddram:0.odt
#set_property LOC R5 [get_ports ddram_odt]
#set_property SLEW FAST [get_ports ddram_odt]
#set_property IOSTANDARD SSTL15 [get_ports ddram_odt]
# ## ddram:0.reset_n
#set_property LOC K6 [get_ports ddram_reset_n]
#set_property SLEW FAST [get_ports ddram_reset_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_reset_n]
# ## eth_clocks:0.tx
#set_property LOC H16 [get_ports eth_clocks_tx]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_clocks_tx]
# ## eth_clocks:0.rx
#set_property LOC F15 [get_ports eth_clocks_rx]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_clocks_rx]
# ## eth:0.rst_n
#set_property LOC C16 [get_ports eth_rst_n]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rst_n]
# ## eth:0.mdio
#set_property LOC K13 [get_ports eth_mdio]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_mdio]
# ## eth:0.mdc
#set_property LOC F16 [get_ports eth_mdc]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_mdc]
# ## eth:0.rx_dv
#set_property LOC G16 [get_ports eth_rx_dv]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_dv]
# ## eth:0.rx_er
#set_property LOC C17 [get_ports eth_rx_er]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_er]
# ## eth:0.rx_data
#set_property LOC D18 [get_ports eth_rx_data[0]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_data[0]]
# ## eth:0.rx_data
#set_property LOC E17 [get_ports eth_rx_data[1]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_data[1]]
# ## eth:0.rx_data
#set_property LOC E18 [get_ports eth_rx_data[2]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_data[2]]
# ## eth:0.rx_data
#set_property LOC G17 [get_ports eth_rx_data[3]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_data[3]]
# ## eth:0.tx_en
#set_property LOC H15 [get_ports eth_tx_en]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_en]
# ## eth:0.tx_data
#set_property LOC H14 [get_ports eth_tx_data[0]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_data[0]]
# ## eth:0.tx_data
#set_property LOC J14 [get_ports eth_tx_data[1]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_data[1]]
# ## eth:0.tx_data
#set_property LOC J13 [get_ports eth_tx_data[2]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_data[2]]
# ## eth:0.tx_data
#set_property LOC H17 [get_ports eth_tx_data[3]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_data[3]]
# ## eth:0.col
#set_property LOC D17 [get_ports eth_col]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_col]
# ## eth:0.crs
#set_property LOC G14 [get_ports eth_crs]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_crs]
set_property INTERNAL_VREF 0.75 [get_iobanks 34]
create_clock -period 10.000 -name clk100 [get_nets clk100]
#create_clock -name eth_rx_clk -period 40.0 [get_nets eth_rx_clk]
#create_clock -name eth_tx_clk -period 40.0 [get_nets eth_tx_clk]
#set_clock_groups -group [get_clocks -include_generated_clocks -of [get_nets sys_clk]] -group [get_clocks -include_generated_clocks -of [get_nets eth_rx_clk]] -asynchronous
#set_clock_groups -group [get_clocks -include_generated_clocks -of [get_nets sys_clk]] -group [get_clocks -include_generated_clocks -of [get_nets eth_tx_clk]] -asynchronous
#set_clock_groups -group [get_clocks -include_generated_clocks -of [get_nets eth_rx_clk]] -group [get_clocks -include_generated_clocks -of [get_nets eth_tx_clk]] -asynchronous
set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]

View file

@ -0,0 +1,350 @@
## serial:0.tx
set_property LOC D10 [get_ports serial_tx]
set_property IOSTANDARD LVCMOS33 [get_ports serial_tx]
## serial:0.rx
set_property LOC A9 [get_ports serial_rx]
set_property IOSTANDARD LVCMOS33 [get_ports serial_rx]
## clk100:0
set_property LOC E3 [get_ports clk100]
set_property IOSTANDARD LVCMOS33 [get_ports clk100]
## cpu_reset:0
set_property LOC C2 [get_ports cpu_reset]
set_property IOSTANDARD LVCMOS33 [get_ports cpu_reset]
## eth_ref_clk:0
#set_property LOC G18 [get_ports eth_ref_clk]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_ref_clk]
## user_led:0
set_property LOC H5 [get_ports user_led0]
set_property IOSTANDARD LVCMOS33 [get_ports user_led0]
## user_led:1
set_property LOC J5 [get_ports user_led1]
set_property IOSTANDARD LVCMOS33 [get_ports user_led1]
## user_led:2
set_property LOC T9 [get_ports user_led2]
set_property IOSTANDARD LVCMOS33 [get_ports user_led2]
## user_led:3
set_property LOC T10 [get_ports user_led3]
set_property IOSTANDARD LVCMOS33 [get_ports user_led3]
## user_sw:0
set_property LOC A8 [get_ports user_sw0]
set_property IOSTANDARD LVCMOS33 [get_ports user_sw0]
## user_sw:1
set_property LOC C11 [get_ports user_sw1]
set_property IOSTANDARD LVCMOS33 [get_ports user_sw1]
## user_sw:2
set_property LOC C10 [get_ports user_sw2]
set_property IOSTANDARD LVCMOS33 [get_ports user_sw2]
## user_sw:3
set_property LOC A10 [get_ports user_sw3]
set_property IOSTANDARD LVCMOS33 [get_ports user_sw3]
## user_btn:0
set_property LOC D9 [get_ports user_btn0]
set_property IOSTANDARD LVCMOS33 [get_ports user_btn0]
## user_btn:1
set_property LOC C9 [get_ports user_btn1]
set_property IOSTANDARD LVCMOS33 [get_ports user_btn1]
## user_btn:2
set_property LOC B9 [get_ports user_btn2]
set_property IOSTANDARD LVCMOS33 [get_ports user_btn2]
## user_btn:3
set_property LOC B8 [get_ports user_btn3]
set_property IOSTANDARD LVCMOS33 [get_ports user_btn3]
## spiflash_1x:0.cs_n
#set_property LOC L13 [get_ports spiflash_1x_cs_n]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_cs_n]
# ## spiflash_1x:0.mosi
#set_property LOC K17 [get_ports spiflash_1x_mosi]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_mosi]
# ## spiflash_1x:0.miso
#set_property LOC K18 [get_ports spiflash_1x_miso]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_miso]
# ## spiflash_1x:0.wp
#set_property LOC L14 [get_ports spiflash_1x_wp]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_wp]
# ## spiflash_1x:0.hold
#set_property LOC M14 [get_ports spiflash_1x_hold]
#set_property IOSTANDARD LVCMOS33 [get_ports spiflash_1x_hold]
# ## ddram:0.a
#set_property LOC R2 [get_ports ddram_a[0]]
#set_property SLEW FAST [get_ports ddram_a[0]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[0]]
# ## ddram:0.a
#set_property LOC M6 [get_ports ddram_a[1]]
#set_property SLEW FAST [get_ports ddram_a[1]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[1]]
# ## ddram:0.a
#set_property LOC N4 [get_ports ddram_a[2]]
#set_property SLEW FAST [get_ports ddram_a[2]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[2]]
# ## ddram:0.a
#set_property LOC T1 [get_ports ddram_a[3]]
#set_property SLEW FAST [get_ports ddram_a[3]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[3]]
# ## ddram:0.a
#set_property LOC N6 [get_ports ddram_a[4]]
#set_property SLEW FAST [get_ports ddram_a[4]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[4]]
# ## ddram:0.a
#set_property LOC R7 [get_ports ddram_a[5]]
#set_property SLEW FAST [get_ports ddram_a[5]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[5]]
# ## ddram:0.a
#set_property LOC V6 [get_ports ddram_a[6]]
#set_property SLEW FAST [get_ports ddram_a[6]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[6]]
# ## ddram:0.a
#set_property LOC U7 [get_ports ddram_a[7]]
#set_property SLEW FAST [get_ports ddram_a[7]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[7]]
# ## ddram:0.a
#set_property LOC R8 [get_ports ddram_a[8]]
#set_property SLEW FAST [get_ports ddram_a[8]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[8]]
# ## ddram:0.a
#set_property LOC V7 [get_ports ddram_a[9]]
#set_property SLEW FAST [get_ports ddram_a[9]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[9]]
# ## ddram:0.a
#set_property LOC R6 [get_ports ddram_a[10]]
#set_property SLEW FAST [get_ports ddram_a[10]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[10]]
# ## ddram:0.a
#set_property LOC U6 [get_ports ddram_a[11]]
#set_property SLEW FAST [get_ports ddram_a[11]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[11]]
# ## ddram:0.a
#set_property LOC T6 [get_ports ddram_a[12]]
#set_property SLEW FAST [get_ports ddram_a[12]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[12]]
# ## ddram:0.a
#set_property LOC T8 [get_ports ddram_a[13]]
#set_property SLEW FAST [get_ports ddram_a[13]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_a[13]]
# ## ddram:0.ba
#set_property LOC R1 [get_ports ddram_ba[0]]
#set_property SLEW FAST [get_ports ddram_ba[0]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_ba[0]]
# ## ddram:0.ba
#set_property LOC P4 [get_ports ddram_ba[1]]
#set_property SLEW FAST [get_ports ddram_ba[1]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_ba[1]]
# ## ddram:0.ba
#set_property LOC P2 [get_ports ddram_ba[2]]
#set_property SLEW FAST [get_ports ddram_ba[2]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_ba[2]]
# ## ddram:0.ras_n
#set_property LOC P3 [get_ports ddram_ras_n]
#set_property SLEW FAST [get_ports ddram_ras_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_ras_n]
# ## ddram:0.cas_n
#set_property LOC M4 [get_ports ddram_cas_n]
#set_property SLEW FAST [get_ports ddram_cas_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_cas_n]
# ## ddram:0.we_n
#set_property LOC P5 [get_ports ddram_we_n]
#set_property SLEW FAST [get_ports ddram_we_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_we_n]
# ## ddram:0.cs_n
#set_property LOC U8 [get_ports ddram_cs_n]
#set_property SLEW FAST [get_ports ddram_cs_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_cs_n]
# ## ddram:0.dm
#set_property LOC L1 [get_ports ddram_dm[0]]
#set_property SLEW FAST [get_ports ddram_dm[0]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dm[0]]
# ## ddram:0.dm
#set_property LOC U1 [get_ports ddram_dm[1]]
#set_property SLEW FAST [get_ports ddram_dm[1]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dm[1]]
# ## ddram:0.dq
#set_property LOC K5 [get_ports ddram_dq[0]]
#set_property SLEW FAST [get_ports ddram_dq[0]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[0]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[0]]
# ## ddram:0.dq
#set_property LOC L3 [get_ports ddram_dq[1]]
#set_property SLEW FAST [get_ports ddram_dq[1]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[1]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[1]]
# ## ddram:0.dq
#set_property LOC K3 [get_ports ddram_dq[2]]
#set_property SLEW FAST [get_ports ddram_dq[2]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[2]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[2]]
# ## ddram:0.dq
#set_property LOC L6 [get_ports ddram_dq[3]]
#set_property SLEW FAST [get_ports ddram_dq[3]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[3]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[3]]
# ## ddram:0.dq
#set_property LOC M3 [get_ports ddram_dq[4]]
#set_property SLEW FAST [get_ports ddram_dq[4]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[4]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[4]]
# ## ddram:0.dq
#set_property LOC M1 [get_ports ddram_dq[5]]
#set_property SLEW FAST [get_ports ddram_dq[5]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[5]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[5]]
# ## ddram:0.dq
#set_property LOC L4 [get_ports ddram_dq[6]]
#set_property SLEW FAST [get_ports ddram_dq[6]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[6]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[6]]
# ## ddram:0.dq
#set_property LOC M2 [get_ports ddram_dq[7]]
#set_property SLEW FAST [get_ports ddram_dq[7]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[7]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[7]]
# ## ddram:0.dq
#set_property LOC V4 [get_ports ddram_dq[8]]
#set_property SLEW FAST [get_ports ddram_dq[8]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[8]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[8]]
# ## ddram:0.dq
#set_property LOC T5 [get_ports ddram_dq[9]]
#set_property SLEW FAST [get_ports ddram_dq[9]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[9]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[9]]
# ## ddram:0.dq
#set_property LOC U4 [get_ports ddram_dq[10]]
#set_property SLEW FAST [get_ports ddram_dq[10]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[10]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[10]]
# ## ddram:0.dq
#set_property LOC V5 [get_ports ddram_dq[11]]
#set_property SLEW FAST [get_ports ddram_dq[11]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[11]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[11]]
# ## ddram:0.dq
#set_property LOC V1 [get_ports ddram_dq[12]]
#set_property SLEW FAST [get_ports ddram_dq[12]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[12]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[12]]
# ## ddram:0.dq
#set_property LOC T3 [get_ports ddram_dq[13]]
#set_property SLEW FAST [get_ports ddram_dq[13]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[13]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[13]]
# ## ddram:0.dq
#set_property LOC U3 [get_ports ddram_dq[14]]
#set_property SLEW FAST [get_ports ddram_dq[14]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[14]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[14]]
# ## ddram:0.dq
#set_property LOC R3 [get_ports ddram_dq[15]]
#set_property SLEW FAST [get_ports ddram_dq[15]]
#set_property IOSTANDARD SSTL15 [get_ports ddram_dq[15]]
#set_property IN_TERM UNTUNED_SPLIT_40 [get_ports ddram_dq[15]]
# ## ddram:0.dqs_p
#set_property LOC N2 [get_ports ddram_dqs_p[0]]
#set_property SLEW FAST [get_ports ddram_dqs_p[0]]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_dqs_p[0]]
# ## ddram:0.dqs_p
#set_property LOC U2 [get_ports ddram_dqs_p[1]]
#set_property SLEW FAST [get_ports ddram_dqs_p[1]]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_dqs_p[1]]
# ## ddram:0.dqs_n
#set_property LOC N1 [get_ports ddram_dqs_n[0]]
#set_property SLEW FAST [get_ports ddram_dqs_n[0]]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_dqs_n[0]]
# ## ddram:0.dqs_n
#set_property LOC V2 [get_ports ddram_dqs_n[1]]
#set_property SLEW FAST [get_ports ddram_dqs_n[1]]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_dqs_n[1]]
# ## ddram:0.clk_p
#set_property LOC U9 [get_ports ddram_clk_p]
#set_property SLEW FAST [get_ports ddram_clk_p]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_clk_p]
# ## ddram:0.clk_n
#set_property LOC V9 [get_ports ddram_clk_n]
#set_property SLEW FAST [get_ports ddram_clk_n]
#set_property IOSTANDARD DIFF_SSTL15 [get_ports ddram_clk_n]
# ## ddram:0.cke
#set_property LOC N5 [get_ports ddram_cke]
#set_property SLEW FAST [get_ports ddram_cke]
#set_property IOSTANDARD SSTL15 [get_ports ddram_cke]
# ## ddram:0.odt
#set_property LOC R5 [get_ports ddram_odt]
#set_property SLEW FAST [get_ports ddram_odt]
#set_property IOSTANDARD SSTL15 [get_ports ddram_odt]
# ## ddram:0.reset_n
#set_property LOC K6 [get_ports ddram_reset_n]
#set_property SLEW FAST [get_ports ddram_reset_n]
#set_property IOSTANDARD SSTL15 [get_ports ddram_reset_n]
# ## eth_clocks:0.tx
#set_property LOC H16 [get_ports eth_clocks_tx]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_clocks_tx]
# ## eth_clocks:0.rx
#set_property LOC F15 [get_ports eth_clocks_rx]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_clocks_rx]
# ## eth:0.rst_n
#set_property LOC C16 [get_ports eth_rst_n]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rst_n]
# ## eth:0.mdio
#set_property LOC K13 [get_ports eth_mdio]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_mdio]
# ## eth:0.mdc
#set_property LOC F16 [get_ports eth_mdc]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_mdc]
# ## eth:0.rx_dv
#set_property LOC G16 [get_ports eth_rx_dv]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_dv]
# ## eth:0.rx_er
#set_property LOC C17 [get_ports eth_rx_er]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_er]
# ## eth:0.rx_data
#set_property LOC D18 [get_ports eth_rx_data[0]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_data[0]]
# ## eth:0.rx_data
#set_property LOC E17 [get_ports eth_rx_data[1]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_data[1]]
# ## eth:0.rx_data
#set_property LOC E18 [get_ports eth_rx_data[2]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_data[2]]
# ## eth:0.rx_data
#set_property LOC G17 [get_ports eth_rx_data[3]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_rx_data[3]]
# ## eth:0.tx_en
#set_property LOC H15 [get_ports eth_tx_en]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_en]
# ## eth:0.tx_data
#set_property LOC H14 [get_ports eth_tx_data[0]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_data[0]]
# ## eth:0.tx_data
#set_property LOC J14 [get_ports eth_tx_data[1]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_data[1]]
# ## eth:0.tx_data
#set_property LOC J13 [get_ports eth_tx_data[2]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_data[2]]
# ## eth:0.tx_data
#set_property LOC H17 [get_ports eth_tx_data[3]]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_tx_data[3]]
# ## eth:0.col
#set_property LOC D17 [get_ports eth_col]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_col]
# ## eth:0.crs
#set_property LOC G14 [get_ports eth_crs]
#set_property IOSTANDARD LVCMOS33 [get_ports eth_crs]
set_property INTERNAL_VREF 0.750 [get_iobanks 34]
create_clock -name sys_clk -period 10.0 [get_nets sys_clk]
create_clock -name clk100 -period 10.0 [get_nets clk100]
#create_clock -name eth_rx_clk -period 40.0 [get_nets eth_rx_clk]
#create_clock -name eth_tx_clk -period 40.0 [get_nets eth_tx_clk]
#set_clock_groups -group [get_clocks -include_generated_clocks -of [get_nets sys_clk]] -group [get_clocks -include_generated_clocks -of [get_nets eth_rx_clk]] -asynchronous
#set_clock_groups -group [get_clocks -include_generated_clocks -of [get_nets sys_clk]] -group [get_clocks -include_generated_clocks -of [get_nets eth_tx_clk]] -asynchronous
#set_clock_groups -group [get_clocks -include_generated_clocks -of [get_nets eth_rx_clk]] -group [get_clocks -include_generated_clocks -of [get_nets eth_tx_clk]] -asynchronous
set_false_path -quiet -to [get_nets -quiet -filter {mr_ff == TRUE}]
set_false_path -quiet -to [get_pins -quiet -filter {REF_PIN_NAME == PRE} -of [get_cells -quiet -filter {ars_ff1 == TRUE || ars_ff2 == TRUE}]]
set_max_delay 2 -quiet -from [get_pins -quiet -filter {REF_PIN_NAME == Q} -of [get_cells -quiet -filter {ars_ff1 == TRUE}]] -to [get_pins -quiet -filter {REF_PIN_NAME == D} -of [get_cells -quiet -filter {ars_ff2 == TRUE}]]

View file

@ -0,0 +1,50 @@
# Input files
set mmi_file "./soc.mmi"
set elf_file "./soc.elf"
set source_bit_file "./soc.bit"
# Output files
set output_bit_file "./soc_latest_sw.bit"
# Enable to turn on debug
set updatemem_debug 0
# Assemble bit file that can be downloaded to device directly
# Combine the original bit file, mmi file, and software elf to create the full bitstream
# Delete target file
file delete -force $output_bit_file
# Determine if the user has built the project and has the target source file
# If not, then use the reference bit file shipped with the project
if { ![file exists $source_bit_file] } {
puts "\n********************************************"
puts "INFO - File $source_bit_file doesn't exist as project has not been built"
puts " Using $reference_bit_file instead\n"
puts "********************************************/n"
set source_bit_file $reference_bit_file
}
# Banner message to console as there is no output for a few seconds
puts " Running updatemem ..."
if { $updatemem_debug } {
set error [catch {exec updatemem --debug --force --meminfo $mmi_file --data $elf_file --bit $source_bit_file --proc dummy --out $output_bit_file} result]
} else {
set error [catch {exec updatemem --force --meminfo $mmi_file --data $elf_file --bit $source_bit_file --proc dummy --out $output_bit_file} result]
}
# Print the stdout from updatemem
puts $result
# Updatemem returns 0 even when there is an error, so cannot trap on error. Having deleted output file to start, then
# detect if it now exists, else exit.
if { ![file exists $output_bit_file] } {
puts "ERROR - $output_bit_file not made"
return -1
} else {
puts "\n********************************************"
puts " $output_bit_file correctly generated"
puts "********************************************\n"
}

View file

@ -0,0 +1,6 @@
#!/bin/sh
#Create mcs file for QSPI flash
cd ./build
vivado -mode batch -source ../make_mcs_file.tcl -notrace

View file

@ -0,0 +1,31 @@
# Input file
set source_bit_file "./latest.bit"
# Output file
set output_mcs_file "./latest.mcs"
# Delete target file
file delete -force $output_mcs_file
# Determine if the user has built the project and has the target source file
# If not, then use the reference bit file shipped with the project
if { ![file exists $source_bit_file] } {
puts "\n********************************************"
puts "INFO - File $source_bit_file doesn't exist as project has not been built\n"
puts "********************************************/n"
error
}
# Create MCS file for base board QSPI flash memory
write_cfgmem -force -format MCS -size 16 -interface SPIx4 -loadbit " up 0 $source_bit_file" $output_mcs_file
# Check MCS was correctly made
if { ![file exists $output_mcs_file] } {
puts "ERROR - $output_bit_file not made"
return -1
} else {
puts "\n********************************************"
puts " $output_mcs_file correctly generated"
puts "********************************************\n"
}

View file

@ -0,0 +1,4 @@
#!/bin/sh
cd ./build
vivado -mode batch -source ../make_mmi_files.tcl -notrace

View file

@ -0,0 +1,6 @@
source [file join [file dirname [file normalize [info script]]] vivado_params.tcl]
open_project -read_only $outputdir/$projectName
open_run impl_1
source $base/soc_mmi.tcl
puts "mmi files generated"

View file

@ -0,0 +1,9 @@
#!/bin/sh
#cannot rm build because it erase software images that the make file copy there
#rm -rf ./build
mkdir -p ./build
cd ./build
vivado -mode batch -source ../make_vivado_project.tcl -notrace

View file

@ -0,0 +1,46 @@
#Create output directory and clear contents
source [file join [file dirname [file normalize [info script]]] vivado_params.tcl]
file mkdir $outputdir
set files [glob -nocomplain "$outputdir/*"]
if {[llength $files] != 0} {
puts "deleting contents of $outputdir"
file delete -force {*}[glob -directory $outputdir *]; # clear folder contents
} else {
puts "$outputdir is empty"
}
#Create project
create_project -part $part $projectName $outputdir
#add source files to Vivado project
#add_files -fileset sim_1 ./path/to/testbench.vhd
#add_files [glob ./path/to/sources/*.vhd]
#add_files -fileset constrs_1 ./path/to/constraint/constraint.xdc
#add_files [glob ./path/to/library/sources/*.vhd]
#set_property -library userDefined [glob ./path/to/library/sources/*.vhd]
add_files [glob $base/*.v]
add_files [glob $topv]
add_files -fileset constrs_1 $base/arty_a7.xdc
#set top level module and update compile order
set_property top toplevel [current_fileset]
update_compile_order -fileset sources_1
#update_compile_order -fileset sim_1
#launch synthesis
launch_runs synth_1
wait_on_run synth_1
#Run implementation and generate bitstream
set_property STEPS.PHYS_OPT_DESIGN.IS_ENABLED true [get_runs impl_1]
launch_runs impl_1 -to_step write_bitstream
wait_on_run impl_1
puts "Implementation done!"
#reports generated by default
#open_run impl_1
#report_timing_summary -check_timing_verbose -report_unconstrained -file report_timing_summary.rpt
#report_utilization -hierarchical -file report_utilization.rpt
#TODO: add checks about timing, DRC, CDC such that the script give clear indication if design is OK or not

View file

@ -0,0 +1,62 @@
ROOT=../../..
SWBASE=$(ROOT)/src/main/c/murax
SOCSW=hello_world
SOCMEMSRC=$(SWBASE)/$(SOCSW)/build/$(SOCSW).v
SOCMEM=build/soc.mem
TOP=Murax
all : build/latest.bit
../../../$(TOP).v : toplevel.v
(cd ../../..; sbt "runMain vexriscv.demo.Murax_arty")
.PHONY: $(SOCMEMSRC)
$(SOCMEMSRC):
mkdir -p build
make -C $(SWBASE)/$(SOCSW)
$(SOCMEM) : $(SOCMEMSRC)
cp -u $(SOCMEMSRC) $(SOCMEM)
build/vivado_project/fpga.runs/impl_1/toplevel.bit : toplevel.v arty_a7.xdc ../../../$(TOP).v
mkdir -p build
./make_vivado_project
cp build/vivado_project/fpga.runs/impl_1/toplevel.bit build/latest.bit
build/soc.mmi: build/vivado_project/fpga.runs/impl_1/toplevel.bit
./make_mmi_files
build/latest_soc_sw.bit : $(SOCMEM) build/soc.mmi
rm -f updatemem.jou updatemem.log
updatemem -force --meminfo build/soc.mmi --data $(SOCMEM) --bit build/latest.bit --proc dummy --out build/latest_soc_sw.bit
cp build/latest_soc_sw.bit build/latest.bit
build/latest.bit : build/latest_soc_sw.bit
build/latest.mcs : build/latest.bit
./make_mcs_file
prog : build/latest.bit
./write_fpga
flash : build/latest.mcs
./write_flash
clean-soc-sw:
make -C $(SWBASE)/$(SOCSW) clean-all
soc-sw: clean-soc-sw $(SOCMEM)
.PHONY: clean
clean :
rm -rf build
mkdir build
rm -f updatemem.jou
rm -f updatemem.log
clean-sw: clean-soc-sw
clean-all : clean clean-sw
rm -f ../../../$(TOP).v
rm -f ../../../$(TOP).v_*

View file

@ -0,0 +1,4 @@
#!/bin/sh
cd ./build
vivado -mode batch -source ../open_vivado_project.tcl -notrace

View file

@ -0,0 +1,4 @@
source [file join [file dirname [file normalize [info script]]] vivado_params.tcl]
open_project -read_only $outputdir/$projectName
start_gui

View file

@ -0,0 +1 @@
picocom --baud 115200 --imap lfcrlf /dev/ttyUSB1

View file

@ -0,0 +1,151 @@
#script to update the init values of RAM without re-synthesis
if {![info exists mmi_file]} {
# Set MMI output file name
set mmi_file "soc.mmi"
}
if {![info exists part]} {
set part "xc7a35ticsg324-1L"
}
# Function to swap bits
proc swap_bits { bit } {
if { $bit > 23 } {return [expr {24 + (31 - $bit)}]}
if { $bit > 15 } {return [expr {16 + (23 - $bit)}]}
if { $bit > 7 } {return [expr {8 + (15 - $bit)}]}
return [expr {7 - $bit}]
}
# If run from batch file, will need to open project, then open the run
# open_run impl_1
# Find all the RAMs, place in a list
set rams [get_cells -hier -regexp {.*core/system_ram/.*} -filter {REF_NAME == RAMB36E1 || REF_NAME == RAMB18E1}]
puts "[llength $rams] RAMs in total"
foreach m $rams {puts $m}
set mems [dict create]
foreach m $rams {
set numbers [regexp -all -inline -- {[0-9]+} $m]
dict set mems $numbers $m
}
set keys [dict keys $mems]
#set keys [lsort -integer $keys]
set rams []
foreach key $keys {
set m [dict get $mems $key]
puts "$key -> $m"
lappend rams $m
}
puts "after sort:"
foreach m $rams {puts $m}
puts $rams
if { [llength $rams] == 0 } {
puts "Error - no memories found"
return -1
}
if { [expr {[llength $rams] % 4}] != 0 } {
puts "Error - Number of memories not divisible by 4"
return -1
}
set size_bytes [expr {4096*[llength $rams]}]
puts "Instruction memory size $size_bytes"
# Currently only support memory sizes between 16kB, (one byte per mem), and 128kB, (one bit per mem)
if { ($size_bytes < (4*4096)) || ($size_bytes > (32*4096)) } {
puts "Error - Memory size of $size_bytes out of range"
puts " Script only supports memory sizes between 16kB and 128kB"
return -1
}
# Create and open target mmi file
set fp [open $mmi_file {WRONLY CREAT TRUNC}]
if { $fp == 0 } {
puts "Error - Unable to open $mmi_file for writing"
return -1
}
# Write the file header
puts $fp "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
puts $fp "<MemInfo Version=\"1\" Minor=\"15\">"
puts $fp " <Processor Endianness=\"ignored\" InstPath=\"dummy\">"
puts $fp " <AddressSpace Name=\"soc_side\" Begin=\"[expr {0x80000000}]\" End=\"[expr {0x80000000 + $size_bytes-1}]\">"
puts $fp " <BusBlock>"
# Calculate the expected number of bits per memory
set mem_bits [expr {32/[llength $rams]}]
puts "mem_bits = $mem_bits"
set mem_info [dict create]
set i 0
foreach ram $rams {
# Get the RAM location
set loc_val [get_property LOC [get_cells $ram]]
regexp {(RAMB.+_)([0-9XY]+)} $loc_val full ram_name loc_xy
set memi [dict create ram $ram loc $loc_xy]
set numbers [regexp -all -inline -- {[0-9]+} $ram]
if { [llength $numbers] == 2 } {
dict lappend mem_info [lindex $numbers 0] $memi
} else {
dict lappend mem_info [expr $i/4] $memi
}
incr i
}
set sorted_mem_info [dict create]
foreach {idx mems} $mem_info {
foreach mem [lreverse $mems] {
dict lappend sorted_mem_info $idx $mem
}
}
foreach mems $sorted_mem_info {
foreach mem $mems {
puts $mem
}
}
set lsb 0
set memlen [ expr 4096*8 / $mem_bits ]
foreach {idx mems} $sorted_mem_info {
puts "idx=$idx"
foreach mem $mems {
puts "mem=$mem"
set ram [dict get $mem ram]
set loc [dict get $mem loc]
set msb [expr $lsb+$mem_bits-1]
set addr_start 0
set addr_end [expr $memlen-1]
puts "ram=$ram loc=$loc lsb=$lsb msb=$msb addr_start=$addr_start addr_end=$addr_end"
puts $fp " <!-- $ram -->"
puts $fp " <BitLane MemType=\"RAMB36\" Placement=\"$loc\">"
puts $fp " <DataWidth MSB=\"$msb\" LSB=\"$lsb\"/>"
puts $fp " <!--not used!--><AddressRange Begin=\"$addr_start\" End=\"$addr_end\"/>"
puts $fp " <Parity ON=\"false\" NumBits=\"0\"/>"
puts $fp " </BitLane>"
set lsb [expr ($msb+1)%32]
}
}
puts $fp " </BusBlock>"
puts $fp " </AddressSpace>"
puts $fp " </Processor>"
puts $fp " <Config>"
puts $fp " <Option Name=\"Part\" Val=\"$part\"/>"
puts $fp " </Config>"
puts $fp " <DRC>"
puts $fp " <Rule Name=\"RDADDRCHANGE\" Val=\"false\"/>"
puts $fp " </DRC>"
puts $fp "</MemInfo>"
close $fp

View file

@ -0,0 +1,66 @@
`timescale 1ns / 1ps
module toplevel(
input wire clk100,
input wire cpu_reset,//active low
input wire tck,
input wire tms,
input wire tdi,
input wire trst,//ignored
output reg tdo,
input wire serial_rx,
output wire serial_tx,
input wire user_sw0,
input wire user_sw1,
input wire user_sw2,
input wire user_sw3,
input wire user_btn0,
input wire user_btn1,
input wire user_btn2,
input wire user_btn3,
output wire user_led0,
output wire user_led1,
output wire user_led2,
output wire user_led3
);
wire [31:0] io_gpioA_read;
wire [31:0] io_gpioA_write;
wire [31:0] io_gpioA_writeEnable;
wire io_asyncReset = ~cpu_reset;
assign {user_led3,user_led2,user_led1,user_led0} = io_gpioA_write[3 : 0];
assign io_gpioA_read[3:0] = {user_sw3,user_sw2,user_sw1,user_sw0};
assign io_gpioA_read[7:4] = {user_btn3,user_btn2,user_btn1,user_btn0};
assign io_gpioA_read[11:8] = {tck,tms,tdi,trst};
reg tesic_tck,tesic_tms,tesic_tdi;
wire tesic_tdo;
reg soc_tck,soc_tms,soc_tdi;
wire soc_tdo;
always @(*) begin
{soc_tck, soc_tms, soc_tdi } = {tck,tms,tdi};
tdo = soc_tdo;
end
Murax core (
.io_asyncReset(io_asyncReset),
.io_mainClk (clk100 ),
.io_jtag_tck(soc_tck),
.io_jtag_tdi(soc_tdi),
.io_jtag_tdo(soc_tdo),
.io_jtag_tms(soc_tms),
.io_gpioA_read (io_gpioA_read),
.io_gpioA_write (io_gpioA_write),
.io_gpioA_writeEnable(io_gpioA_writeEnable),
.io_uart_txd(serial_tx),
.io_uart_rxd(serial_rx)
);
endmodule

View file

@ -0,0 +1,5 @@
set outputdir ./vivado_project
set part "xc7a35ticsg324-1L"
set base ".."
set projectName "fpga"
set topv "$base/../../../Murax.v"

View file

@ -0,0 +1,3 @@
#!/bin/sh
cd ./build
vivado -mode batch -source ../write_flash.tcl -notrace

View file

@ -0,0 +1,26 @@
open_hw
connect_hw_server
open_hw_target
current_hw_device [get_hw_devices xc7a35t_0]
refresh_hw_device -update_hw_probes false [lindex [get_hw_devices xc7a35t_0] 0]
create_hw_cfgmem -hw_device [lindex [get_hw_devices] 0] -mem_dev [lindex [get_cfgmem_parts {s25fl128sxxxxxx0-spi-x1_x2_x4}] 0]
set_property PROBES.FILE {} [get_hw_devices xc7a35t_0]
set_property FULL_PROBES.FILE {} [get_hw_devices xc7a35t_0]
refresh_hw_device [lindex [get_hw_devices xc7a35t_0] 0]
set_property PROGRAM.ADDRESS_RANGE {use_file} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
set_property PROGRAM.FILES [list "latest.mcs" ] [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
set_property PROGRAM.PRM_FILE {} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
set_property PROGRAM.UNUSED_PIN_TERMINATION {pull-none} [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
set_property PROGRAM.BLANK_CHECK 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
set_property PROGRAM.ERASE 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
set_property PROGRAM.CFG_PROGRAM 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
set_property PROGRAM.VERIFY 1 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
set_property PROGRAM.CHECKSUM 0 [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
if {![string equal [get_property PROGRAM.HW_CFGMEM_TYPE [lindex [get_hw_devices xc7a35t_0] 0]] [get_property MEM_TYPE [get_property CFGMEM_PART [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]]]] } { create_hw_bitstream -hw_device [lindex [get_hw_devices xc7a35t_0] 0] [get_property PROGRAM.HW_CFGMEM_BITFILE [ lindex [get_hw_devices xc7a35t_0] 0]]; program_hw_devices [lindex [get_hw_devices xc7a35t_0] 0]; };
program_hw_cfgmem -hw_cfgmem [ get_property PROGRAM.HW_CFGMEM [lindex [get_hw_devices xc7a35t_0] 0]]
close_hw_target
close_hw

View file

@ -0,0 +1,3 @@
#!/bin/sh
cd ./build
vivado -mode batch -source ../write_fpga.tcl -notrace

View file

@ -0,0 +1,10 @@
open_hw
connect_hw_server
open_hw_target
current_hw_device [get_hw_devices xc7a35t_0]
refresh_hw_device -update_hw_probes false [lindex [get_hw_devices xc7a35t_0] 0]
set_property PROBES.FILE {} [get_hw_devices xc7a35t_0]
set_property FULL_PROBES.FILE {} [get_hw_devices xc7a35t_0]
set_property PROGRAM.FILE {latest.bit} [get_hw_devices xc7a35t_0]
program_hw_devices [get_hw_devices xc7a35t_0]
disconnect_hw_server

View file

@ -3,10 +3,10 @@
VERILOG = ../../../Murax.v toplevel.v
generate :
(cd ../../..; sbt "run-main vexriscv.demo.MuraxWithRamInit")
(cd ../../..; sbt "runMain vexriscv.demo.MuraxWithRamInit")
../../../Murax.v :
(cd ../../..; sbt "run-main vexriscv.demo.MuraxWithRamInit")
(cd ../../..; sbt "runMain vexriscv.demo.MuraxWithRamInit")
../../../Murax.v*.bin:

View file

@ -2,7 +2,8 @@ This example is for the
[Lattice iCE40HX-8K Breakout Board](http://www.latticesemi.com/Products/DevelopmentBoardsAndKits/iCE40HX8KBreakoutBoard.aspx).
An image of this board is shown below;
![img/iCE40HX8K-breakout-revA.png]
![`iCE40HX8K breakout revA`](img/iCE40HX8K-breakout-revA.png)
This board can be purchased for ~$USD 49 directly from Lattice and is supported
by the IceStorm
@ -20,7 +21,8 @@ mode. This requires removing jumper `J7` and putting the pair of jumpers on
This is shown in **Figure 5** of the
[iCE40HX-8K Breakout Board User Guide](http://www.latticesemi.com/view_document?document_id=50373).
which is also reproduced below;
![img/cram-programming-config.png]
![CRAM Programming Config](img/cram-programming-config.png)
Once your board is ready, you should follow the setup instructions at the
[top level](../../../README.md).

View file

@ -1,19 +1,21 @@
VBASE = ../../..
VNAME = Murax_iCE40_hx8k_breakout_board_xip
VERILOG = ${VBASE}/${VNAME}.v
VERILOG = ../../../Murax_iCE40_hx8k_breakout_board_xip.v
all: prog
generate :
#(cd ../../..; sbt "run-main vexriscv.demo.Murax_iCE40_hx8k_breakout_board_xip")
${VERILOG} :
(cd ${VBASE}; sbt "runMain vexriscv.demo.${VNAME}")
../../../Murax_iCE40_hx8k_breakout_board_xip.v :
#(cd ../../..; sbt "run-main vexriscv.demo.Murax_iCE40_hx8k_breakout_board_xip")
generate : ${VERILOG}
../../../Murax_iCE40_hx8k_breakout_board_xip.v*.bin:
${VERILOG}*.bin:
bin/Murax_iCE40_hx8k_breakout_board_xip.blif : ${VERILOG} ../../../Murax_iCE40_hx8k_breakout_board_xip.v*.bin
bin/Murax_iCE40_hx8k_breakout_board_xip.blif : ${VERILOG} ${VERILOG}*.bin
mkdir -p bin
rm -f Murax_iCE40_hx8k_breakout_board_xip.v*.bin
cp ../../../Murax_iCE40_hx8k_breakout_board_xip.v*.bin . | true
cp ${VERILOG}*.bin . | true
yosys -v3 -p "synth_ice40 -top Murax_iCE40_hx8k_breakout_board_xip -blif bin/Murax_iCE40_hx8k_breakout_board_xip.blif" ${VERILOG}
bin/Murax_iCE40_hx8k_breakout_board_xip.asc : Murax_iCE40_hx8k_breakout_board_xip.pcf bin/Murax_iCE40_hx8k_breakout_board_xip.blif
@ -28,11 +30,15 @@ time: bin/Murax_iCE40_hx8k_breakout_board_xip.bin
icetime -tmd hx8k bin/Murax_iCE40_hx8k_breakout_board_xip.asc
prog : bin/Murax_iCE40_hx8k_breakout_board_xip.bin
lsusb -d 0403:6010
iceprog -S bin/Murax_iCE40_hx8k_breakout_board_xip.bin
sudo-prog : bin/Murax_iCE40_hx8k_breakout_board_xip.bin
sudo lsusb -d 0403:6010
sudo iceprog -S bin/Murax_iCE40_hx8k_breakout_board_xip.bin
clean :
rm -rf bin
rm -f Murax_iCE40_hx8k_breakout_board_xip.v*.bin
rm -f ${VERILOG}*.bin
rm -f ${VERILOG}

View file

@ -1,12 +1,12 @@
## iCE40-hx8k breakout board
set_io io_J3 J3
set_io io_H16 H16
set_io io_G15 G15
set_io io_G16 G16
set_io io_F15 F15
set_io io_B12 B12
set_io io_B10 B10
set_io io_mainClk J3
set_io io_jtag_tck H16
set_io io_jtag_tdi G15
set_io io_jtag_tdo G16
set_io io_jtag_tms F15
set_io io_uart_txd B12
set_io io_uart_rxd B10
set_io io_led[0] B5
set_io io_led[1] B4
set_io io_led[2] A2
@ -17,7 +17,7 @@ set_io io_led[6] B3
set_io io_led[7] C3
#XIP
set_io io_P12 P12
set_io io_P11 P11
set_io io_R11 R11
set_io io_R12 R12
set_io io_miso P12
set_io io_mosi P11
set_io io_sclk R11
set_io io_spis R12

View file

@ -2,12 +2,17 @@ This example is for the
[Lattice iCE40HX-8K Breakout Board](http://www.latticesemi.com/Products/DevelopmentBoardsAndKits/iCE40HX8KBreakoutBoard.aspx).
An image of this board is shown below;
![img/iCE40HX8K-breakout-revA.png]
![`iCE40HX8K breakout revA`](img/iCE40HX8K-breakout-revA.png)
This board can be purchased for ~$USD 49 directly from Lattice and is supported
by the IceStorm
[`iceprog`](https://github.com/cliffordwolf/icestorm/tree/master/iceprog) tool.
# Bootloader operations
A bootloader is implemented in a ROM within the FPGA bitfile. It configure the SPI and attempt to read the first word in 'XIP' area of the flash (0xE0040000 in CPU address space, 0x40000 in flash). If this first word is not 0xFFFFFFFF and the same value is read 3 times,
then the bootloader jump at 0xE0040000.
# Using the example
@ -20,7 +25,8 @@ mode. This requires removing jumper `J7` and putting the pair of jumpers on
This is shown in **Figure 5** of the
[iCE40HX-8K Breakout Board User Guide](http://www.latticesemi.com/view_document?document_id=50373).
which is also reproduced below;
![img/cram-programming-config.png]
![CRAM Programming Config](img/cram-programming-config.png)
Once your board is ready, you should follow the setup instructions at the
[top level](../../../README.md).
@ -57,12 +63,29 @@ The process should take around 30 seconds on a reasonable fast computer.
## Programming
Make sure the FPGA board is the only USB peripheral with ID 0403:6010
For example, this is bad:
```
user@lafite:~$ lsusb -d 0403:6010
Bus 001 Device 088: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
Bus 001 Device 090: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
```
This is good:
```
user@lafite:~$ lsusb -d 0403:6010
Bus 001 Device 088: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
```
After building you should be able to run `make prog`. You may need to run `make
sudo-prog` if root is needed to access your USB devices.
You should get output like the following;
```
iceprog -S bin/toplevel.bin
lsusb -d 0403:6010
Bus 001 Device 088: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
iceprog -S bin/Murax_iCE40_hx8k_breakout_board_xip.bin
init..
cdone: high
reset..
@ -72,13 +95,113 @@ cdone: high
Bye.
```
After programming the LEDs at the top of the board should start flashing in an
interesting pattern.
WARNING: having this output does NOT guarantee you actually programmed anything in the FPGA!
## Connect
After programming nothing visual will happen, except the LEDs being off.
The bootloader is waiting for a valid content in the flash (see Bootloader operations).
After programming you should be able to connect to the serial port and have the
output echoed back to you.
## Programming flash image
On Linux you can do this using a command like `screen /dev/ttyUSB1`. Then as
you type you should get back the same characters.
### Connect JTAG
We will use vexrisc JTAG to program the flash, so you need openocd and a
suitable JTAG dongle.
Pin-out:
```
TCK: H16 aka J2.25
TDO: G16 aka J2.26
TDI: G15 aka J2.27
TMS: F15 aka J2.28
```
In addition you need to connect the ground and VTarget aka VIO: J2.2 on the
board.
### Start GDB server / OpenOCD
Make sure to use https://github.com/SpinalHDL/openocd_riscv
Make sure to select the configuration file which match your JTAG dongle.
An example with the dongle "ft2232h_breakout":
```
src/openocd -f tcl/interface/ftdi/ft2232h_breakout.cfg -c "set MURAX_CPU0_YAML ../VexRiscv/cpu0.yaml" -f tcl/target/murax_xip.cfg
```
You should get an output like below:
```
Open On-Chip Debugger 0.10.0+dev-01214-g0ace94f (2019-10-02-18:23)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
../VexRiscv/cpu0.yaml
adapter speed: 100 kHz
adapter_nsrst_delay: 260
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
jtag_ntrst_delay: 250
Info : set servers polling period to 50ms
Error: libusb_get_string_descriptor_ascii() failed with LIBUSB_ERROR_INVALID_PARAM
Info : clock speed 100 kHz
Info : JTAG tap: fpga_spinal.bridge tap/device found: 0x10001fff (mfg: 0x7ff (<invalid>), part: 0x0001, ver: 0x1)
Info : Listening on port 3333 for gdb connections
requesting target halt and executing a soft reset
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
```
### Loading the flash with telnet
First we connect and stop execution on the device:
```
user@lafite:~/Downloads/vexrisc_full/VexRiscv/src/main/c/murax/xipBootloader$ telnet 127.0.0.1 4444
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Open On-Chip Debugger
> reset
JTAG tap: fpga_spinal.bridge tap/device found: 0x10001fff (mfg: 0x7ff (<invalid>), part: 0x0001, ver: 0x1)
>
```
Now we can safely connect the J7 jumper on the board to be able to access the flash.
After that, we can load the program in flash:
```
> flash erase_sector 0 4 4
erased sectors 4 through 4 on flash bank 0 in 0.872235s
> flash write_bank 0 /home/user/dev/vexrisc_fork/VexRiscv/src/main/c/murax/xipBootloader/demo_xip.bin 0x40000
wrote 48 bytes from file /home/user/dev/vexrisc_fork/VexRiscv/src/main/c/murax/xipBootloader/demo_xip.bin to flash bank 0 at offset 0x00040000 in 0.285539s (0.164 KiB/s)
> flash verify_bank 0 /home/user/dev/vexrisc_fork/VexRiscv/src/main/c/murax/xipBootloader/demo_xip.bin 0x40000
read 48 bytes from file /home/user/dev/vexrisc_fork/VexRiscv/src/main/c/murax/xipBootloader/demo_xip.bin and flash bank 0 at offset 0x00040000 in 0.192036s (0.244 KiB/s)
contents match
> reset
JTAG tap: fpga_spinal.bridge tap/device found: 0x10001fff (mfg: 0x7ff (<invalid>), part: 0x0001, ver: 0x1)
> resume
> exit
Connection closed by foreign host.
```
From now the device runs the code from flash, LEDs shall display a dot moving from D9 to D2.
### Loading flash using GDB / eclipse
```
src/openocd -f tcl/interface/ftdi/ft2232h_breakout.cfg -c "set MURAX_CPU0_YAML ../VexRiscv/cpu0.yaml" -f tcl/target/murax_xip.cfg
```
- Make sure J7 is connected.
- Connect to GDB / eclipse as usual.
From there code loading, step, break points works as usual (including software break points in flash).
## Update hardware/bootloader
- Stop any OpenOCD connection
- Remove J7, then:
```
make clean prog
```
- Remember to check a single FTDI device is listed in the output. If not:
- Disconnect the other devices
```
make prog
```
- Connect J7, flash software shall start executing.
## Flash software
Refer to "Loading the flash with telnet" or "Loading flash using GDB / eclipse".

View file

@ -3,10 +3,10 @@
VERILOG = ../../../Murax.v toplevel.v toplevel_pll.v
generate :
(cd ../../..; sbt "run-main vexriscv.demo.MuraxWithRamInit")
(cd ../../..; sbt "runMain vexriscv.demo.MuraxWithRamInit")
../../../Murax.v :
(cd ../../..; sbt "run-main vexriscv.demo.MuraxWithRamInit")
(cd ../../..; sbt "runMain vexriscv.demo.MuraxWithRamInit")
../../../Murax.v*.bin:

3
scripts/regression/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
verilator*
verilator
!verilator.mk

View file

@ -0,0 +1,7 @@
.ONESHELL:
include verilator.mk
include regression.mk

View file

@ -0,0 +1,48 @@
.ONESHELL:
regression_random:
cd ../..
export VEXRISCV_REGRESSION_CONFIG_COUNT=4
export VEXRISCV_REGRESSION_FREERTOS_COUNT=1
export VEXRISCV_REGRESSION_ZEPHYR_COUNT=4
export VEXRISCV_REGRESSION_THREAD_COUNT=1
sbt "testOnly vexriscv.TestIndividualFeatures"
regression_random_linux:
cd ../..
export VEXRISCV_REGRESSION_CONFIG_COUNT=2
export VEXRISCV_REGRESSION_CONFIG_LINUX_RATE=1.0
export VEXRISCV_REGRESSION_CONFIG_SECURE_RATE=0.0
export VEXRISCV_REGRESSION_FREERTOS_COUNT=1
export VEXRISCV_REGRESSION_ZEPHYR_COUNT=2
export VEXRISCV_REGRESSION_THREAD_COUNT=1
sbt "testOnly vexriscv.TestIndividualFeatures"
regression_random_machine_os:
cd ../..
export VEXRISCV_REGRESSION_CONFIG_COUNT=10
export VEXRISCV_REGRESSION_CONFIG_LINUX_RATE=0.0
export VEXRISCV_REGRESSION_CONFIG_MACHINE_OS_RATE=1.0
export VEXRISCV_REGRESSION_CONFIG_SECURE_RATE=0.0
export VEXRISCV_REGRESSION_FREERTOS_COUNT=1
export VEXRISCV_REGRESSION_ZEPHYR_COUNT=2
export VEXRISCV_REGRESSION_THREAD_COUNT=1
sbt "testOnly vexriscv.TestIndividualFeatures"
regression_random_baremetal:
cd ../..
export VEXRISCV_REGRESSION_CONFIG_COUNT=30
export VEXRISCV_REGRESSION_CONFIG_LINUX_RATE=0.0
export VEXRISCV_REGRESSION_CONFIG_MACHINE_OS_RATE=0.0
export VEXRISCV_REGRESSION_CONFIG_SECURE_RATE=0.0
export VEXRISCV_REGRESSION_FREERTOS_COUNT=1
export VEXRISCV_REGRESSION_ZEPHYR_COUNT=no
export VEXRISCV_REGRESSION_THREAD_COUNT=1
sbt "testOnly vexriscv.TestIndividualFeatures"
regression_dhrystone:
cd ../..
sbt "testOnly vexriscv.DhrystoneBench"

View file

@ -0,0 +1,20 @@
.ONESHELL:
verilator/configure:
rm -rf verilator*
wget https://www.veripool.org/ftp/verilator-4.034.tgz
tar xvzf verilator*.t*gz
mv verilator-4.034 verilator
verilator/Makefile: verilator/configure
cd verilator
./configure
verilator/bin/verilator_bin: verilator/Makefile
cd verilator
make -j$(shell nproc)
rm -rf src/obj_dbg
rm -rf src/obj_opt
verilator_binary: verilator/bin/verilator_bin

151
src/main/c/common/ram.ld Executable file
View file

@ -0,0 +1,151 @@
OUTPUT_ARCH( "riscv" )
ENTRY( _start )
MEMORY
{
ram : ORIGIN = DEFINED(__ram_origin) ? __ram_origin : 0x80000000, LENGTH = 64k
}
SECTIONS
{
__stack_size = DEFINED(__stack_size) ? __stack_size : 2K;
.init :
{
KEEP (*(SORT_NONE(.init)))
}> ram
.text :
{
*(.text.unlikely .text.unlikely.*)
*(.text.startup .text.startup.*)
*(.text .text.*)
*(.gnu.linkonce.t.*)
*(.note.gnu.build-id)
} > ram
.fini :
{
KEEP (*(SORT_NONE(.fini)))
} > ram
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
. = ALIGN(4);
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} > ram
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
} > ram
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
} > ram
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} > ram
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} > ram
.lalign :
{
. = ALIGN(4);
PROVIDE( _data_lma = . );
} > ram
.dalign :
{
. = ALIGN(4);
PROVIDE( _data = . );
} > ram
.data :
{
*(.rdata)
*(.rodata .rodata.*)
*(.gnu.linkonce.r.*)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.*)
*(.gnu.linkonce.s.*)
. = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
*(.srodata.cst2)
*(.srodata .srodata.*)
} >ram
. = ALIGN(4);
PROVIDE( _edata = . );
PROVIDE( edata = . );
PROVIDE( _fbss = . );
PROVIDE( __bss_start = . );
.bss :
{
*(.sbss*)
*(.gnu.linkonce.sb.*)
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
} >ram
. = ALIGN(8);
PROVIDE( _end = . );
PROVIDE( end = . );
.stack :
{
PROVIDE( _heap_end = . );
. = __stack_size;
PROVIDE( _sp = . );
} > ram
}

View file

@ -0,0 +1,16 @@
RISCV_BIN ?= riscv64-unknown-elf-
RISCV_CC=${RISCV_BIN}gcc
RISCV_OBJCOPY=${RISCV_BIN}objcopy
RISCV_OBJDUMP=${RISCV_BIN}objdump
MARCH := rv32i
ifeq ($(MULDIV),yes)
MARCH := $(MARCH)M
endif
ifeq ($(COMPRESSED),yes)
MARCH := $(MARCH)AC
endif
CFLAGS += -march=$(MARCH) -mabi=ilp32 -DUSE_GP
LDFLAGS += -march=$(MARCH) -mabi=ilp32

View file

@ -0,0 +1,74 @@
LDFLAGS += -lc
CFLAGS += -I${STANDALONE}/include
ifeq ($(DEBUG),yes)
CFLAGS += -g3 -Og
endif
ifeq ($(DEBUG),no)
CFLAGS += -O3
endif
LDFLAGS += -nostdlib -lgcc -nostartfiles -ffreestanding -Wl,-Bstatic,-T,$(LDSCRIPT),-Map,$(OBJDIR)/$(PROJ_NAME).map,--print-memory-usage
OBJDIR ?= build
OBJS := $(SRCS)
OBJS := $(OBJS:.c=.o)
OBJS := $(OBJS:.cpp=.o)
OBJS := $(OBJS:.S=.o)
OBJS := $(OBJS:..=miaou)
OBJS := $(addprefix $(OBJDIR)/,$(OBJS))
all: $(OBJDIR)/$(PROJ_NAME).elf $(OBJDIR)/$(PROJ_NAME).hex $(OBJDIR)/$(PROJ_NAME).asm $(OBJDIR)/$(PROJ_NAME).bin
$(OBJDIR)/%.elf: $(OBJS) | $(OBJDIR)
$(RISCV_CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
%.hex: %.elf
$(RISCV_OBJCOPY) -O ihex $^ $@
%.bin: %.elf
$(RISCV_OBJCOPY) -O binary $^ $@
%.v: %.elf
$(RISCV_OBJCOPY) -O verilog $^ $@
%.asm: %.elf
$(RISCV_OBJDUMP) -S -d $^ > $@
$(OBJDIR)/%.o: %.c
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
$(OBJDIR)/%.o: %.cpp
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
$(OBJDIR)/%.o: %.S
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) -o $@ $^ -D__ASSEMBLY__=1
$(OBJDIR):
mkdir -p $@
clean:
rm -f $(OBJDIR)/$(PROJ_NAME).elf
rm -f $(OBJDIR)/$(PROJ_NAME).hex
rm -f $(OBJDIR)/$(PROJ_NAME).map
rm -f $(OBJDIR)/$(PROJ_NAME).v
rm -f $(OBJDIR)/$(PROJ_NAME).bin
rm -f $(OBJDIR)/$(PROJ_NAME).asm
find $(OBJDIR) -type f -name '*.o' -print0 | xargs -0 -r rm
.SECONDARY: $(OBJS)

6
src/main/c/emulator/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
*.map
*.v
*.elf
*.o
*.hex
!*.bin

View file

@ -0,0 +1,620 @@
build/emulator.elf: file format elf32-littleriscv
Disassembly of section .init:
80000000 <_start>:
80000000: 00001117 auipc sp,0x1
80000004: 18810113 addi sp,sp,392 # 80001188 <_sp>
80000008: 00001517 auipc a0,0x1
8000000c: 8dc50513 addi a0,a0,-1828 # 800008e4 <__init_array_end>
80000010: 00001597 auipc a1,0x1
80000014: 8d458593 addi a1,a1,-1836 # 800008e4 <__init_array_end>
80000018: 00001617 auipc a2,0x1
8000001c: 97060613 addi a2,a2,-1680 # 80000988 <__bss_start>
80000020: 00c5fc63 bgeu a1,a2,80000038 <_start+0x38>
80000024: 00052283 lw t0,0(a0)
80000028: 0055a023 sw t0,0(a1)
8000002c: 00450513 addi a0,a0,4
80000030: 00458593 addi a1,a1,4
80000034: fec5e8e3 bltu a1,a2,80000024 <_start+0x24>
80000038: 00001517 auipc a0,0x1
8000003c: 95050513 addi a0,a0,-1712 # 80000988 <__bss_start>
80000040: 00001597 auipc a1,0x1
80000044: 94858593 addi a1,a1,-1720 # 80000988 <__bss_start>
80000048: 00b57863 bgeu a0,a1,80000058 <_start+0x58>
8000004c: 00052023 sw zero,0(a0)
80000050: 00450513 addi a0,a0,4
80000054: feb56ce3 bltu a0,a1,8000004c <_start+0x4c>
80000058: 7e4000ef jal ra,8000083c <__libc_init_array>
8000005c: 178000ef jal ra,800001d4 <init>
80000060: 00000097 auipc ra,0x0
80000064: 01408093 addi ra,ra,20 # 80000074 <done>
80000068: 00000513 li a0,0
8000006c: c30005b7 lui a1,0xc3000
80000070: 30200073 mret
80000074 <done>:
80000074: 0000006f j 80000074 <done>
80000078 <_init>:
80000078: 00008067 ret
8000007c <trapEntry>:
8000007c: 34011173 csrrw sp,mscratch,sp
80000080: 00112223 sw ra,4(sp)
80000084: 00312623 sw gp,12(sp)
80000088: 00412823 sw tp,16(sp)
8000008c: 00512a23 sw t0,20(sp)
80000090: 00612c23 sw t1,24(sp)
80000094: 00712e23 sw t2,28(sp)
80000098: 02812023 sw s0,32(sp)
8000009c: 02912223 sw s1,36(sp)
800000a0: 02a12423 sw a0,40(sp)
800000a4: 02b12623 sw a1,44(sp)
800000a8: 02c12823 sw a2,48(sp)
800000ac: 02d12a23 sw a3,52(sp)
800000b0: 02e12c23 sw a4,56(sp)
800000b4: 02f12e23 sw a5,60(sp)
800000b8: 05012023 sw a6,64(sp)
800000bc: 05112223 sw a7,68(sp)
800000c0: 05212423 sw s2,72(sp)
800000c4: 05312623 sw s3,76(sp)
800000c8: 05412823 sw s4,80(sp)
800000cc: 05512a23 sw s5,84(sp)
800000d0: 05612c23 sw s6,88(sp)
800000d4: 05712e23 sw s7,92(sp)
800000d8: 07812023 sw s8,96(sp)
800000dc: 07912223 sw s9,100(sp)
800000e0: 07a12423 sw s10,104(sp)
800000e4: 07b12623 sw s11,108(sp)
800000e8: 07c12823 sw t3,112(sp)
800000ec: 07d12a23 sw t4,116(sp)
800000f0: 07e12c23 sw t5,120(sp)
800000f4: 07f12e23 sw t6,124(sp)
800000f8: 2c4000ef jal ra,800003bc <trap>
800000fc: 00412083 lw ra,4(sp)
80000100: 00c12183 lw gp,12(sp)
80000104: 01012203 lw tp,16(sp)
80000108: 01412283 lw t0,20(sp)
8000010c: 01812303 lw t1,24(sp)
80000110: 01c12383 lw t2,28(sp)
80000114: 02012403 lw s0,32(sp)
80000118: 02412483 lw s1,36(sp)
8000011c: 02812503 lw a0,40(sp)
80000120: 02c12583 lw a1,44(sp)
80000124: 03012603 lw a2,48(sp)
80000128: 03412683 lw a3,52(sp)
8000012c: 03812703 lw a4,56(sp)
80000130: 03c12783 lw a5,60(sp)
80000134: 04012803 lw a6,64(sp)
80000138: 04412883 lw a7,68(sp)
8000013c: 04812903 lw s2,72(sp)
80000140: 04c12983 lw s3,76(sp)
80000144: 05012a03 lw s4,80(sp)
80000148: 05412a83 lw s5,84(sp)
8000014c: 05812b03 lw s6,88(sp)
80000150: 05c12b83 lw s7,92(sp)
80000154: 06012c03 lw s8,96(sp)
80000158: 06412c83 lw s9,100(sp)
8000015c: 06812d03 lw s10,104(sp)
80000160: 06c12d83 lw s11,108(sp)
80000164: 07012e03 lw t3,112(sp)
80000168: 07412e83 lw t4,116(sp)
8000016c: 07812f03 lw t5,120(sp)
80000170: 07c12f83 lw t6,124(sp)
80000174: 34011173 csrrw sp,mscratch,sp
80000178: 30200073 mret
Disassembly of section .text:
8000017c <putString>:
8000017c: ff010113 addi sp,sp,-16
80000180: 00812423 sw s0,8(sp)
80000184: 00112623 sw ra,12(sp)
80000188: 00050413 mv s0,a0
8000018c: 00054503 lbu a0,0(a0)
80000190: 00050a63 beqz a0,800001a4 <putString+0x28>
80000194: 00140413 addi s0,s0,1
80000198: 668000ef jal ra,80000800 <putC>
8000019c: 00044503 lbu a0,0(s0)
800001a0: fe051ae3 bnez a0,80000194 <putString+0x18>
800001a4: 00c12083 lw ra,12(sp)
800001a8: 00812403 lw s0,8(sp)
800001ac: 01010113 addi sp,sp,16
800001b0: 00008067 ret
800001b4 <setup_pmp>:
800001b4: 01f00793 li a5,31
800001b8: fff00713 li a4,-1
800001bc: 00000297 auipc t0,0x0
800001c0: 01428293 addi t0,t0,20 # 800001d0 <setup_pmp+0x1c>
800001c4: 30529073 csrw mtvec,t0
800001c8: 3b071073 csrw pmpaddr0,a4
800001cc: 3a079073 csrw pmpcfg0,a5
800001d0: 00008067 ret
800001d4 <init>:
800001d4: ff010113 addi sp,sp,-16
800001d8: 00112623 sw ra,12(sp)
800001dc: 00812423 sw s0,8(sp)
800001e0: 01f00793 li a5,31
800001e4: fff00713 li a4,-1
800001e8: 00000297 auipc t0,0x0
800001ec: 01428293 addi t0,t0,20 # 800001fc <init+0x28>
800001f0: 30529073 csrw mtvec,t0
800001f4: 3b071073 csrw pmpaddr0,a4
800001f8: 3a079073 csrw pmpcfg0,a5
800001fc: 80001437 lui s0,0x80001
80000200: 638000ef jal ra,80000838 <halInit>
80000204: 95840413 addi s0,s0,-1704 # 80000958 <_sp+0xfffff7d0>
80000208: 02a00513 li a0,42
8000020c: 00140413 addi s0,s0,1
80000210: 5f0000ef jal ra,80000800 <putC>
80000214: 00044503 lbu a0,0(s0)
80000218: fe051ae3 bnez a0,8000020c <init+0x38>
8000021c: 800007b7 lui a5,0x80000
80000220: 07c78793 addi a5,a5,124 # 8000007c <_sp+0xffffeef4>
80000224: 30579073 csrw mtvec,a5
80000228: 800017b7 lui a5,0x80001
8000022c: 10878793 addi a5,a5,264 # 80001108 <_sp+0xffffff80>
80000230: 34079073 csrw mscratch,a5
80000234: 000017b7 lui a5,0x1
80000238: 88078793 addi a5,a5,-1920 # 880 <__stack_size+0x80>
8000023c: 30079073 csrw mstatus,a5
80000240: 30405073 csrwi mie,0
80000244: c00007b7 lui a5,0xc0000
80000248: 34179073 csrw mepc,a5
8000024c: 0000b7b7 lui a5,0xb
80000250: 10078793 addi a5,a5,256 # b100 <__stack_size+0xa900>
80000254: 30279073 csrw medeleg,a5
80000258: 22200793 li a5,546
8000025c: 30379073 csrw mideleg,a5
80000260: 14305073 csrwi stval,0
80000264: 80001437 lui s0,0x80001
80000268: 97040413 addi s0,s0,-1680 # 80000970 <_sp+0xfffff7e8>
8000026c: 02a00513 li a0,42
80000270: 00140413 addi s0,s0,1
80000274: 58c000ef jal ra,80000800 <putC>
80000278: 00044503 lbu a0,0(s0)
8000027c: fe051ae3 bnez a0,80000270 <init+0x9c>
80000280: 00c12083 lw ra,12(sp)
80000284: 00812403 lw s0,8(sp)
80000288: 01010113 addi sp,sp,16
8000028c: 00008067 ret
80000290 <readRegister>:
80000290: 800017b7 lui a5,0x80001
80000294: 10878793 addi a5,a5,264 # 80001108 <_sp+0xffffff80>
80000298: 00251513 slli a0,a0,0x2
8000029c: 00f50533 add a0,a0,a5
800002a0: 00052503 lw a0,0(a0)
800002a4: 00008067 ret
800002a8 <writeRegister>:
800002a8: 800017b7 lui a5,0x80001
800002ac: 00251513 slli a0,a0,0x2
800002b0: 10878793 addi a5,a5,264 # 80001108 <_sp+0xffffff80>
800002b4: 00f50533 add a0,a0,a5
800002b8: 00b52023 sw a1,0(a0)
800002bc: 00008067 ret
800002c0 <redirectTrap>:
800002c0: ff010113 addi sp,sp,-16
800002c4: 00112623 sw ra,12(sp)
800002c8: 530000ef jal ra,800007f8 <stopSim>
800002cc: 343027f3 csrr a5,mtval
800002d0: 14379073 csrw stval,a5
800002d4: 341027f3 csrr a5,mepc
800002d8: 14179073 csrw sepc,a5
800002dc: 342027f3 csrr a5,mcause
800002e0: 14279073 csrw scause,a5
800002e4: 105027f3 csrr a5,stvec
800002e8: 34179073 csrw mepc,a5
800002ec: 00c12083 lw ra,12(sp)
800002f0: 01010113 addi sp,sp,16
800002f4: 00008067 ret
800002f8 <emulationTrapToSupervisorTrap>:
800002f8: 800007b7 lui a5,0x80000
800002fc: 07c78793 addi a5,a5,124 # 8000007c <_sp+0xffffeef4>
80000300: 30579073 csrw mtvec,a5
80000304: 343027f3 csrr a5,mtval
80000308: 14379073 csrw stval,a5
8000030c: 342027f3 csrr a5,mcause
80000310: 14279073 csrw scause,a5
80000314: 14151073 csrw sepc,a0
80000318: 105027f3 csrr a5,stvec
8000031c: 34179073 csrw mepc,a5
80000320: 0035d793 srli a5,a1,0x3
80000324: 00459713 slli a4,a1,0x4
80000328: 02077713 andi a4,a4,32
8000032c: 1007f793 andi a5,a5,256
80000330: 00e7e7b3 or a5,a5,a4
80000334: ffffe737 lui a4,0xffffe
80000338: 6dd70713 addi a4,a4,1757 # ffffe6dd <_sp+0x7fffd555>
8000033c: 00e5f5b3 and a1,a1,a4
80000340: 00b7e7b3 or a5,a5,a1
80000344: 000015b7 lui a1,0x1
80000348: 88058593 addi a1,a1,-1920 # 880 <__stack_size+0x80>
8000034c: 00b7e7b3 or a5,a5,a1
80000350: 30079073 csrw mstatus,a5
80000354: 00008067 ret
80000358 <readWord>:
80000358: 00020737 lui a4,0x20
8000035c: 30072073 csrs mstatus,a4
80000360: 00000717 auipc a4,0x0
80000364: 01870713 addi a4,a4,24 # 80000378 <readWord+0x20>
80000368: 30571073 csrw mtvec,a4
8000036c: 00100693 li a3,1
80000370: 00052783 lw a5,0(a0)
80000374: 00000693 li a3,0
80000378: 00020737 lui a4,0x20
8000037c: 30073073 csrc mstatus,a4
80000380: 00068513 mv a0,a3
80000384: 00f5a023 sw a5,0(a1)
80000388: 00008067 ret
8000038c <writeWord>:
8000038c: 00020737 lui a4,0x20
80000390: 30072073 csrs mstatus,a4
80000394: 00000717 auipc a4,0x0
80000398: 01870713 addi a4,a4,24 # 800003ac <writeWord+0x20>
8000039c: 30571073 csrw mtvec,a4
800003a0: 00100793 li a5,1
800003a4: 00b52023 sw a1,0(a0)
800003a8: 00000793 li a5,0
800003ac: 00020737 lui a4,0x20
800003b0: 30073073 csrc mstatus,a4
800003b4: 00078513 mv a0,a5
800003b8: 00008067 ret
800003bc <trap>:
800003bc: fe010113 addi sp,sp,-32
800003c0: 00112e23 sw ra,28(sp)
800003c4: 00812c23 sw s0,24(sp)
800003c8: 00912a23 sw s1,20(sp)
800003cc: 01212823 sw s2,16(sp)
800003d0: 01312623 sw s3,12(sp)
800003d4: 342027f3 csrr a5,mcause
800003d8: 0807cc63 bltz a5,80000470 <trap+0xb4>
800003dc: 00200713 li a4,2
800003e0: 0ce78463 beq a5,a4,800004a8 <trap+0xec>
800003e4: 00900693 li a3,9
800003e8: 04d79463 bne a5,a3,80000430 <trap+0x74>
800003ec: 80001437 lui s0,0x80001
800003f0: 18840413 addi s0,s0,392 # 80001188 <_sp+0x0>
800003f4: fc442783 lw a5,-60(s0)
800003f8: 00100693 li a3,1
800003fc: fa842503 lw a0,-88(s0)
80000400: 2ed78463 beq a5,a3,800006e8 <trap+0x32c>
80000404: 2ee78e63 beq a5,a4,80000700 <trap+0x344>
80000408: 2a078c63 beqz a5,800006c0 <trap+0x304>
8000040c: 01812403 lw s0,24(sp)
80000410: 01c12083 lw ra,28(sp)
80000414: 01412483 lw s1,20(sp)
80000418: 01012903 lw s2,16(sp)
8000041c: 00c12983 lw s3,12(sp)
80000420: 02010113 addi sp,sp,32
80000424: 3d40006f j 800007f8 <stopSim>
80000428: 00777713 andi a4,a4,7
8000042c: 12f70c63 beq a4,a5,80000564 <trap+0x1a8>
80000430: 3c8000ef jal ra,800007f8 <stopSim>
80000434: 343027f3 csrr a5,mtval
80000438: 14379073 csrw stval,a5
8000043c: 341027f3 csrr a5,mepc
80000440: 14179073 csrw sepc,a5
80000444: 342027f3 csrr a5,mcause
80000448: 14279073 csrw scause,a5
8000044c: 105027f3 csrr a5,stvec
80000450: 34179073 csrw mepc,a5
80000454: 01c12083 lw ra,28(sp)
80000458: 01812403 lw s0,24(sp)
8000045c: 01412483 lw s1,20(sp)
80000460: 01012903 lw s2,16(sp)
80000464: 00c12983 lw s3,12(sp)
80000468: 02010113 addi sp,sp,32
8000046c: 00008067 ret
80000470: 0ff7f793 andi a5,a5,255
80000474: 00700713 li a4,7
80000478: fae79ce3 bne a5,a4,80000430 <trap+0x74>
8000047c: 02000793 li a5,32
80000480: 1447a073 csrs sip,a5
80000484: 08000793 li a5,128
80000488: 3047b073 csrc mie,a5
8000048c: 01c12083 lw ra,28(sp)
80000490: 01812403 lw s0,24(sp)
80000494: 01412483 lw s1,20(sp)
80000498: 01012903 lw s2,16(sp)
8000049c: 00c12983 lw s3,12(sp)
800004a0: 02010113 addi sp,sp,32
800004a4: 00008067 ret
800004a8: 341024f3 csrr s1,mepc
800004ac: 300025f3 csrr a1,mstatus
800004b0: 34302473 csrr s0,mtval
800004b4: 02f00613 li a2,47
800004b8: 07f47693 andi a3,s0,127
800004bc: 00c45713 srli a4,s0,0xc
800004c0: f6c684e3 beq a3,a2,80000428 <trap+0x6c>
800004c4: 07300613 li a2,115
800004c8: f6c694e3 bne a3,a2,80000430 <trap+0x74>
800004cc: 00377713 andi a4,a4,3
800004d0: 10f70c63 beq a4,a5,800005e8 <trap+0x22c>
800004d4: 00300793 li a5,3
800004d8: 10f70863 beq a4,a5,800005e8 <trap+0x22c>
800004dc: 00100993 li s3,1
800004e0: 03370463 beq a4,s3,80000508 <trap+0x14c>
800004e4: 314000ef jal ra,800007f8 <stopSim>
800004e8: 343027f3 csrr a5,mtval
800004ec: 14379073 csrw stval,a5
800004f0: 341027f3 csrr a5,mepc
800004f4: 14179073 csrw sepc,a5
800004f8: 342027f3 csrr a5,mcause
800004fc: 14279073 csrw scause,a5
80000500: 105027f3 csrr a5,stvec
80000504: 34179073 csrw mepc,a5
80000508: 00001737 lui a4,0x1
8000050c: 01445793 srli a5,s0,0x14
80000510: c0070693 addi a3,a4,-1024 # c00 <__stack_size+0x400>
80000514: 0ed7e263 bltu a5,a3,800005f8 <trap+0x23c>
80000518: c0270713 addi a4,a4,-1022
8000051c: 0cf77063 bgeu a4,a5,800005dc <trap+0x220>
80000520: fffff737 lui a4,0xfffff
80000524: 38070713 addi a4,a4,896 # fffff380 <_sp+0x7fffe1f8>
80000528: 00e787b3 add a5,a5,a4
8000052c: 00200713 li a4,2
80000530: 0cf76463 bltu a4,a5,800005f8 <trap+0x23c>
80000534: 2e4000ef jal ra,80000818 <rdtimeh>
80000538: 00050913 mv s2,a0
8000053c: 1c099e63 bnez s3,80000718 <trap+0x35c>
80000540: 00545413 srli s0,s0,0x5
80000544: 800017b7 lui a5,0x80001
80000548: 10878793 addi a5,a5,264 # 80001108 <_sp+0xffffff80>
8000054c: 07c47413 andi s0,s0,124
80000550: 00f40433 add s0,s0,a5
80000554: 01242023 sw s2,0(s0)
80000558: 00448493 addi s1,s1,4
8000055c: 34149073 csrw mepc,s1
80000560: ef5ff06f j 80000454 <trap+0x98>
80000564: 00d45713 srli a4,s0,0xd
80000568: 01245793 srli a5,s0,0x12
8000056c: 800016b7 lui a3,0x80001
80000570: 10868693 addi a3,a3,264 # 80001108 <_sp+0xffffff80>
80000574: 07c77713 andi a4,a4,124
80000578: 07c7f793 andi a5,a5,124
8000057c: 00d70733 add a4,a4,a3
80000580: 00d787b3 add a5,a5,a3
80000584: 00072703 lw a4,0(a4)
80000588: 0007a603 lw a2,0(a5)
8000058c: 00020537 lui a0,0x20
80000590: 30052073 csrs mstatus,a0
80000594: 00000517 auipc a0,0x0
80000598: 01850513 addi a0,a0,24 # 800005ac <trap+0x1f0>
8000059c: 30551073 csrw mtvec,a0
800005a0: 00100793 li a5,1
800005a4: 00072803 lw a6,0(a4)
800005a8: 00000793 li a5,0
800005ac: 00020537 lui a0,0x20
800005b0: 30053073 csrc mstatus,a0
800005b4: 18079663 bnez a5,80000740 <trap+0x384>
800005b8: 01b45793 srli a5,s0,0x1b
800005bc: 01c00513 li a0,28
800005c0: e6f568e3 bltu a0,a5,80000430 <trap+0x74>
800005c4: 80001537 lui a0,0x80001
800005c8: 00279793 slli a5,a5,0x2
800005cc: 8e450513 addi a0,a0,-1820 # 800008e4 <_sp+0xfffff75c>
800005d0: 00a787b3 add a5,a5,a0
800005d4: 0007a783 lw a5,0(a5)
800005d8: 00078067 jr a5
800005dc: 234000ef jal ra,80000810 <rdtime>
800005e0: 00050913 mv s2,a0
800005e4: f59ff06f j 8000053c <trap+0x180>
800005e8: 00f45993 srli s3,s0,0xf
800005ec: 01f9f993 andi s3,s3,31
800005f0: 013039b3 snez s3,s3
800005f4: f15ff06f j 80000508 <trap+0x14c>
800005f8: 200000ef jal ra,800007f8 <stopSim>
800005fc: 343027f3 csrr a5,mtval
80000600: 14379073 csrw stval,a5
80000604: 341027f3 csrr a5,mepc
80000608: 14179073 csrw sepc,a5
8000060c: 342027f3 csrr a5,mcause
80000610: 14279073 csrw scause,a5
80000614: 105027f3 csrr a5,stvec
80000618: 34179073 csrw mepc,a5
8000061c: f21ff06f j 8000053c <trap+0x180>
80000620: 01067463 bgeu a2,a6,80000628 <trap+0x26c>
80000624: 00080613 mv a2,a6
80000628: 00020537 lui a0,0x20
8000062c: 30052073 csrs mstatus,a0
80000630: 00000517 auipc a0,0x0
80000634: 01850513 addi a0,a0,24 # 80000648 <trap+0x28c>
80000638: 30551073 csrw mtvec,a0
8000063c: 00100793 li a5,1
80000640: 00c72023 sw a2,0(a4)
80000644: 00000793 li a5,0
80000648: 00020537 lui a0,0x20
8000064c: 30053073 csrc mstatus,a0
80000650: 80000737 lui a4,0x80000
80000654: 07c70713 addi a4,a4,124 # 8000007c <_sp+0xffffeef4>
80000658: 14079463 bnez a5,800007a0 <trap+0x3e4>
8000065c: 00545793 srli a5,s0,0x5
80000660: 07c7f793 andi a5,a5,124
80000664: 00d786b3 add a3,a5,a3
80000668: 0106a023 sw a6,0(a3)
8000066c: 00448493 addi s1,s1,4
80000670: 34149073 csrw mepc,s1
80000674: 30571073 csrw mtvec,a4
80000678: dddff06f j 80000454 <trap+0x98>
8000067c: 01064633 xor a2,a2,a6
80000680: fa9ff06f j 80000628 <trap+0x26c>
80000684: fac872e3 bgeu a6,a2,80000628 <trap+0x26c>
80000688: 00080613 mv a2,a6
8000068c: f9dff06f j 80000628 <trap+0x26c>
80000690: f9065ce3 bge a2,a6,80000628 <trap+0x26c>
80000694: 00080613 mv a2,a6
80000698: f91ff06f j 80000628 <trap+0x26c>
8000069c: f8c856e3 bge a6,a2,80000628 <trap+0x26c>
800006a0: 00080613 mv a2,a6
800006a4: f85ff06f j 80000628 <trap+0x26c>
800006a8: 01067633 and a2,a2,a6
800006ac: f7dff06f j 80000628 <trap+0x26c>
800006b0: 01066633 or a2,a2,a6
800006b4: f75ff06f j 80000628 <trap+0x26c>
800006b8: 01060633 add a2,a2,a6
800006bc: f6dff06f j 80000628 <trap+0x26c>
800006c0: fac42583 lw a1,-84(s0)
800006c4: 15c000ef jal ra,80000820 <setMachineTimerCmp>
800006c8: 08000793 li a5,128
800006cc: 3047a073 csrs mie,a5
800006d0: 02000793 li a5,32
800006d4: 1447b073 csrc sip,a5
800006d8: 341027f3 csrr a5,mepc
800006dc: 00478793 addi a5,a5,4
800006e0: 34179073 csrw mepc,a5
800006e4: d71ff06f j 80000454 <trap+0x98>
800006e8: 0ff57513 andi a0,a0,255
800006ec: 114000ef jal ra,80000800 <putC>
800006f0: 341027f3 csrr a5,mepc
800006f4: 00478793 addi a5,a5,4
800006f8: 34179073 csrw mepc,a5
800006fc: d59ff06f j 80000454 <trap+0x98>
80000700: 108000ef jal ra,80000808 <getC>
80000704: faa42423 sw a0,-88(s0)
80000708: 341027f3 csrr a5,mepc
8000070c: 00478793 addi a5,a5,4
80000710: 34179073 csrw mepc,a5
80000714: d41ff06f j 80000454 <trap+0x98>
80000718: 0e0000ef jal ra,800007f8 <stopSim>
8000071c: 343027f3 csrr a5,mtval
80000720: 14379073 csrw stval,a5
80000724: 341027f3 csrr a5,mepc
80000728: 14179073 csrw sepc,a5
8000072c: 342027f3 csrr a5,mcause
80000730: 14279073 csrw scause,a5
80000734: 105027f3 csrr a5,stvec
80000738: 34179073 csrw mepc,a5
8000073c: e05ff06f j 80000540 <trap+0x184>
80000740: 800007b7 lui a5,0x80000
80000744: 07c78793 addi a5,a5,124 # 8000007c <_sp+0xffffeef4>
80000748: 30579073 csrw mtvec,a5
8000074c: 343027f3 csrr a5,mtval
80000750: 14379073 csrw stval,a5
80000754: 342027f3 csrr a5,mcause
80000758: 14279073 csrw scause,a5
8000075c: 14149073 csrw sepc,s1
80000760: 105027f3 csrr a5,stvec
80000764: 34179073 csrw mepc,a5
80000768: 0035d793 srli a5,a1,0x3
8000076c: 00459713 slli a4,a1,0x4
80000770: 02077713 andi a4,a4,32
80000774: 1007f793 andi a5,a5,256
80000778: 00e7e7b3 or a5,a5,a4
8000077c: ffffe737 lui a4,0xffffe
80000780: 6dd70713 addi a4,a4,1757 # ffffe6dd <_sp+0x7fffd555>
80000784: 00e5f5b3 and a1,a1,a4
80000788: 00001737 lui a4,0x1
8000078c: 00b7e7b3 or a5,a5,a1
80000790: 88070713 addi a4,a4,-1920 # 880 <__stack_size+0x80>
80000794: 00e7e7b3 or a5,a5,a4
80000798: 30079073 csrw mstatus,a5
8000079c: cb9ff06f j 80000454 <trap+0x98>
800007a0: 30571073 csrw mtvec,a4
800007a4: 343027f3 csrr a5,mtval
800007a8: 14379073 csrw stval,a5
800007ac: 342027f3 csrr a5,mcause
800007b0: 14279073 csrw scause,a5
800007b4: 14149073 csrw sepc,s1
800007b8: 105027f3 csrr a5,stvec
800007bc: 34179073 csrw mepc,a5
800007c0: 0035d793 srli a5,a1,0x3
800007c4: 00459713 slli a4,a1,0x4
800007c8: 02077713 andi a4,a4,32
800007cc: 1007f793 andi a5,a5,256
800007d0: 00e7e7b3 or a5,a5,a4
800007d4: ffffe737 lui a4,0xffffe
800007d8: 6dd70713 addi a4,a4,1757 # ffffe6dd <_sp+0x7fffd555>
800007dc: 00e5f5b3 and a1,a1,a4
800007e0: 00b7e5b3 or a1,a5,a1
800007e4: 000017b7 lui a5,0x1
800007e8: 88078793 addi a5,a5,-1920 # 880 <__stack_size+0x80>
800007ec: 00f5e7b3 or a5,a1,a5
800007f0: 30079073 csrw mstatus,a5
800007f4: c61ff06f j 80000454 <trap+0x98>
800007f8 <stopSim>:
800007f8: fe002e23 sw zero,-4(zero) # fffffffc <_sp+0x7fffee74>
800007fc: 0000006f j 800007fc <stopSim+0x4>
80000800 <putC>:
80000800: fea02c23 sw a0,-8(zero) # fffffff8 <_sp+0x7fffee70>
80000804: 00008067 ret
80000808 <getC>:
80000808: ff802503 lw a0,-8(zero) # fffffff8 <_sp+0x7fffee70>
8000080c: 00008067 ret
80000810 <rdtime>:
80000810: fe002503 lw a0,-32(zero) # ffffffe0 <_sp+0x7fffee58>
80000814: 00008067 ret
80000818 <rdtimeh>:
80000818: fe402503 lw a0,-28(zero) # ffffffe4 <_sp+0x7fffee5c>
8000081c: 00008067 ret
80000820 <setMachineTimerCmp>:
80000820: fec00793 li a5,-20
80000824: fff00713 li a4,-1
80000828: 00e7a023 sw a4,0(a5)
8000082c: fea02423 sw a0,-24(zero) # ffffffe8 <_sp+0x7fffee60>
80000830: 00b7a023 sw a1,0(a5)
80000834: 00008067 ret
80000838 <halInit>:
80000838: 00008067 ret
8000083c <__libc_init_array>:
8000083c: ff010113 addi sp,sp,-16
80000840: 00000797 auipc a5,0x0
80000844: 0a478793 addi a5,a5,164 # 800008e4 <__init_array_end>
80000848: 00812423 sw s0,8(sp)
8000084c: 00000417 auipc s0,0x0
80000850: 09840413 addi s0,s0,152 # 800008e4 <__init_array_end>
80000854: 40f40433 sub s0,s0,a5
80000858: 00912223 sw s1,4(sp)
8000085c: 01212023 sw s2,0(sp)
80000860: 00112623 sw ra,12(sp)
80000864: 40245413 srai s0,s0,0x2
80000868: 00000493 li s1,0
8000086c: 00078913 mv s2,a5
80000870: 04849263 bne s1,s0,800008b4 <__libc_init_array+0x78>
80000874: 805ff0ef jal ra,80000078 <_init>
80000878: 00000797 auipc a5,0x0
8000087c: 06c78793 addi a5,a5,108 # 800008e4 <__init_array_end>
80000880: 00000417 auipc s0,0x0
80000884: 06440413 addi s0,s0,100 # 800008e4 <__init_array_end>
80000888: 40f40433 sub s0,s0,a5
8000088c: 40245413 srai s0,s0,0x2
80000890: 00000493 li s1,0
80000894: 00078913 mv s2,a5
80000898: 02849a63 bne s1,s0,800008cc <__libc_init_array+0x90>
8000089c: 00c12083 lw ra,12(sp)
800008a0: 00812403 lw s0,8(sp)
800008a4: 00412483 lw s1,4(sp)
800008a8: 00012903 lw s2,0(sp)
800008ac: 01010113 addi sp,sp,16
800008b0: 00008067 ret
800008b4: 00249793 slli a5,s1,0x2
800008b8: 00f907b3 add a5,s2,a5
800008bc: 0007a783 lw a5,0(a5)
800008c0: 00148493 addi s1,s1,1
800008c4: 000780e7 jalr a5
800008c8: fa9ff06f j 80000870 <__libc_init_array+0x34>
800008cc: 00249793 slli a5,s1,0x2
800008d0: 00f907b3 add a5,s2,a5
800008d4: 0007a783 lw a5,0(a5)
800008d8: 00148493 addi s1,s1,1
800008dc: 000780e7 jalr a5
800008e0: fb9ff06f j 80000898 <__libc_init_array+0x5c>

Binary file not shown.

View file

@ -0,0 +1,157 @@
:0200000480007A
:100000001711000013018118171500001305C58D85
:10001000971500009385458D171600001306069767
:1000200063FCC5008322050023A05500130545008D
:1000300093854500E3E8C5FE1715000013050595F7
:1000400097150000938585946378B50023200500FB
:1000500013054500E36CB5FEEF00407EEF0080170E
:10006000970000009380400113050000B70500C30E
:10007000730020306F0000006780000073110134AE
:10008000232211002326310023284100232A510076
:10009000232C6100232E7100232081022322910250
:1000A0002324A1022326B1022328C102232AD1023C
:1000B000232CE102232EF102232001052322110526
:1000C000232421052326310523284105232A510510
:1000D000232C6105232E71052320810723229107FC
:1000E0002324A1072326B1072328C107232AD107E8
:1000F000232CE107232EF107EF00402C8320410041
:100100008321C100032201018322410103238101D4
:100110008323C101032401028324410203258102B8
:100120008325C1020326010383264103032781039C
:100130008327C10303280104832841040329810480
:100140008329C104032A0105832A4105032B810564
:10015000832BC105032C0106832C4106032D810648
:10016000832DC106032E0107832E4107032F81072C
:0C017000832FC10773110134730020308D
:10017C00130101FF23248100232611001304050021
:10018C0003450500630A050013041400EF008066A4
:10019C0003450400E31A05FE8320C10003248100FB
:1001AC0013010101678000009307F0011307F0FFB2
:1001BC009702000093824201739052307310073BF8
:1001CC007390073A67800000130101FF232611008A
:1001DC00232481009307F0011307F0FF970200001E
:1001EC0093824201739052307310073B7390073A1D
:1001FC0037140080EF008063130484951305A0026C
:10020C0013041400EF00005F03450400E31A05FE1D
:10021C00B70700809387C70773905730B7170080D4
:10022C009387871073900734B7170000938707885C
:10023C007390073073504030B70700C07390173479
:10024C00B7B70000938707107390273093072022CD
:10025C0073903730735030143714008013040497A4
:10026C001305A00213041400EF00C058034504004A
:10027C00E31A05FE8320C100032481001301010150
:10028C0067800000B717008093878710131525002F
:10029C003305F5000325050067800000B7170080C3
:1002AC0013152500938787103305F5002320B5001F
:1002BC0067800000130101FF23261100EF0000539B
:1002CC00F327303473903714F327103473901714CA
:1002DC00F327203473902714F3275010739017349E
:1002EC008320C1001301010167800000B707008063
:1002FC009387C70773905730F327303473903714B4
:10030C00F32720347390271473101514F32750100F
:10031C007390173493D73500139745001377070262
:10032C0093F70710B3E7E70037E7FFFF1307D76D25
:10033C00B3F5E500B3E7B700B71500009385058862
:10034C00B3E7B700739007306780000037070200EF
:10035C0073200730170700001307870173105730FD
:10036C009306100083270500930600003707020050
:10037C00733007301385060023A0F500678000005A
:10038C003707020073200730170700001307870197
:10039C0073105730930710002320B500930700000B
:1003AC0037070200733007301385070067800000A1
:1003BC00130101FE232E1100232C8100232A91000E
:1003CC002328210123263101F327203463CC07088D
:1003DC00130720006384E70C930690006394D70402
:1003EC003714008013048418832744FC93061000F0
:1003FC00032584FA6384D72E638EE72E638C072A39
:10040C00032481018320C1018324410103290101BB
:10041C008329C100130101026F00403D137777005F
:10042C00630CF712EF00803CF327303473903714D1
:10043C00F327103473901714F32720347390271478
:10044C00F3275010739017348320C10103248101CA
:10045C0083244101032901018329C10013010102F5
:10046C006780000093F7F70F13077000E39CE7FA1F
:10047C009307000273A047149307000873B047302A
:10048C008320C1010324810183244101032901013B
:10049C008329C1001301010267800000F32410348A
:1004AC00F3250030732430341306F0029376F407EE
:1004BC001357C400E384C6F613063007E394C6F65C
:1004CC0013773700630CF710930730006308F710AD
:1004DC009309100063043703EF004031F3273034E5
:1004EC0073903714F327103473901714F3272034B8
:1004FC0073902714F327501073901734371700009C
:10050C0093574401930607C063E2D70E130727C025
:10051C006370F70C37F7FFFF13070738B387E70053
:10052C00130720006364F70CEF00402E130905003D
:10053C00639E091C13545400B717008093878710CF
:10054C001374C4073304F40023202401938444005F
:10055C00739014346FF05FEF1357D400935724014A
:10056C00B7160080938686101377C70793F7C707D3
:10057C003307D700B387D7000327070003A607006C
:10058C00370502007320053017050000130585019F
:10059C0073105530930710000328070093070000D1
:1005AC003705020073300530639607189357B40172
:1005BC001305C001E368F5E6371500809397270013
:1005CC001305458EB387A70083A707006780070034
:1005DC00EF004023130905006FF09FF59359F400C9
:1005EC0093F9F901B33930016FF05FF1EF0000209E
:1005FC00F327303473903714F32710347390171497
:10060C00F327203473902714F3275010739017346A
:10061C006FF01FF263740601130608003705020021
:10062C007320053017050000130585017310553034
:10063C00930710002320C700930700003705020022
:10064C0073300530370700801307C707639407140E
:10065C009357540093F7C707B386D70023A006011E
:10066C009384440073901434731057306FF0DFDDB3
:10067C00334606016FF09FFAE372C8FA13060800BE
:10068C006FF0DFF9E35C06F9130608006FF01FF951
:10069C00E356C8F8130608006FF05FF833760601CE
:1006AC006FF0DFF7336606016FF05FF73306060174
:1006BC006FF0DFF68325C4FAEF00C015930700082E
:1006CC0073A047309307000273B04714F32710341C
:1006DC0093874700739017346FF01FD71375F50F7E
:1006EC00EF004011F32710349387470073901734B1
:1006FC006FF09FD5EF0080102324A4FAF327103459
:10070C0093874700739017346FF01FD4EF00000EDF
:10071C00F327303473903714F32710347390171475
:10072C00F327203473902714F32750107390173449
:10073C006FF05FE0B70700809387C707739057305F
:10074C00F327303473903714F32720347390271425
:10075C0073901414F32750107390173493D73500FB
:10076C00139745001377070293F70710B3E7E700D9
:10077C0037E7FFFF1307D76DB3F5E5003717000018
:10078C00B3E7B70013070788B3E7E70073900730A8
:10079C006FF09FCB73105730F327303473903714AE
:1007AC00F32720347390271473901414F3275010EC
:1007BC007390173493D735001397450013770702BE
:1007CC0093F70710B3E7E70037E7FFFF1307D76D81
:1007DC00B3F5E500B3E5B700B717000093870788BA
:1007EC00B3E7F500739007306FF01FC6232E00FEA1
:1007FC006F000000232CA0FE67800000032580FF03
:10080C0067800000032500FE67800000032540FE82
:10081C00678000009307C0FE1307F0FF23A0E700DA
:10082C002324A0FE23A0B70067800000678000008F
:10083C00130101FF970700009387470A23248100C7
:10084C0017040000130484093304F440232291009C
:10085C00232021012326110013542440930400006B
:10086C001389070063928404EFF05F809707000000
:10087C009387C70617040000130444063304F4409E
:10088C00135424409304000013890700639A8402D4
:10089C008320C1000324810083244100032901002B
:1008AC00130101016780000093972400B307F9003E
:1008BC0083A7070093841400E78007006FF09FFA6A
:1008CC0093972400B307F90083A7070093841400BF
:0808DC00E78007006FF09FFBAD
:1008E400B8060080280600803004008030040080B0
:1008F4007C060080300400803004008030040080D6
:10090400B006008030040080300400803004008091
:10091400A806008030040080300400803004008089
:100924009C06008030040080300400803004008085
:100934009006008030040080300400803004008081
:10094400840600803004008030040080300400807D
:10095400200600802A2A2A20566578526973637615
:100964002042494F53202A2A2A0A00002A2A2A20F0
:1009740053757065727669736F72202A2A2A0A0089
:04098400000000006F
:040000058000000077
:00000001FF

29
src/main/c/emulator/makefile Executable file
View file

@ -0,0 +1,29 @@
PROJ_NAME=emulator
DEBUG=no
MULDIV=no
COMPRESSED=no
STANDALONE = ..
SRCS = $(wildcard src/*.c) \
$(wildcard src/*.cpp) \
$(wildcard src/*.S)
LDSCRIPT = ${STANDALONE}/common/ram.ld
sim: CFLAGS += -DSIM
sim: all
qemu: CFLAGS += -DQEMU
qemu: all
litex: CFLAGS += -DLITEX -I${LITEX_GENERATED} -I${LITEX_BASE}/litex/soc/software/include
litex: | check_litex all
check_litex:
@[ "${LITEX_BASE}" ] || ( echo ">> LITEX_BASE is not set"; exit 1 )
@[ "${LITEX_GENERATED}" ] || ( echo ">> LITEX_GENERATED is not set"; exit 1 )
include ${STANDALONE}/common/riscv64-unknown-elf.mk
include ${STANDALONE}/common/standalone.mk

View file

@ -0,0 +1,12 @@
#ifndef CONFIG_H
#define CONFIG_H
#ifndef OS_CALL
#define OS_CALL 0xC0000000
#endif
#ifndef DTB
#define DTB 0xC3000000
#endif
#endif

View file

@ -0,0 +1,203 @@
#include "hal.h"
#include "config.h"
#ifdef SIM
void stopSim(){
*((volatile uint32_t*) 0xFFFFFFFC) = 0;
while(1);
}
void putC(char c){
*((volatile uint32_t*) 0xFFFFFFF8) = c;
}
int32_t getC(){
return *((volatile int32_t*) 0xFFFFFFF8);
}
uint32_t rdtime(){
return *((volatile uint32_t*) 0xFFFFFFE0);
}
uint32_t rdtimeh(){
return *((volatile uint32_t*) 0xFFFFFFE4);
}
void setMachineTimerCmp(uint32_t low, uint32_t high){
volatile uint32_t* base = (volatile uint32_t*) 0xFFFFFFE8;
base[1] = 0xffffffff;
base[0] = low;
base[1] = high;
}
void halInit(){
// putC('*');
// putC('*');
// putC('*');
// while(1){
// int32_t c = getC();
// if(c > 0) putC(c);
// }
}
#endif
#ifdef QEMU
#define VIRT_CLINT 0x2000000
#define SIFIVE_TIMECMP_BASE (VIRT_CLINT + 0x4000)
#define SIFIVE_TIME_BASE (VIRT_CLINT + 0xBFF8)
#define NS16550A_UART0_CTRL_ADDR 0x10000000
#define UART0_CLOCK_FREQ 32000000
#define UART0_BAUD_RATE 115200
enum {
UART_RBR = 0x00, /* Receive Buffer Register */
UART_THR = 0x00, /* Transmit Hold Register */
UART_IER = 0x01, /* Interrupt Enable Register */
UART_DLL = 0x00, /* Divisor LSB (LCR_DLAB) */
UART_DLM = 0x01, /* Divisor MSB (LCR_DLAB) */
UART_FCR = 0x02, /* FIFO Control Register */
UART_LCR = 0x03, /* Line Control Register */
UART_MCR = 0x04, /* Modem Control Register */
UART_LSR = 0x05, /* Line Status Register */
UART_MSR = 0x06, /* Modem Status Register */
UART_SCR = 0x07, /* Scratch Register */
UART_LCR_DLAB = 0x80, /* Divisor Latch Bit */
UART_LCR_8BIT = 0x03, /* 8-bit */
UART_LCR_PODD = 0x08, /* Parity Odd */
UART_LSR_DA = 0x01, /* Data Available */
UART_LSR_OE = 0x02, /* Overrun Error */
UART_LSR_PE = 0x04, /* Parity Error */
UART_LSR_FE = 0x08, /* Framing Error */
UART_LSR_BI = 0x10, /* Break indicator */
UART_LSR_RE = 0x20, /* THR is empty */
UART_LSR_RI = 0x40, /* THR is empty and line is idle */
UART_LSR_EF = 0x80, /* Erroneous data in FIFO */
};
static volatile uint8_t *uart;
static void ns16550a_init()
{
uart = (uint8_t *)(void *)(NS16550A_UART0_CTRL_ADDR);
uint32_t uart_freq = (UART0_CLOCK_FREQ);
uint32_t baud_rate = (UART0_BAUD_RATE);
uint32_t divisor = uart_freq / (16 * baud_rate);
uart[UART_LCR] = UART_LCR_DLAB;
uart[UART_DLL] = divisor & 0xff;
uart[UART_DLM] = (divisor >> 8) & 0xff;
uart[UART_LCR] = UART_LCR_PODD | UART_LCR_8BIT;
}
//static int ns16550a_getchar()
//{
// if (uart[UART_LSR] & UART_LSR_DA) {
// return uart[UART_RBR];
// } else {
// return -1;
// }
//}
//
//static int ns16550a_putchar(int ch)
//{
// while ((uart[UART_LSR] & UART_LSR_RI) == 0);
// return uart[UART_THR] = ch & 0xff;
//}
void stopSim(){
while(1);
}
void putC(char ch){
while ((uart[UART_LSR] & UART_LSR_RI) == 0);
uart[UART_THR] = ch & 0xff;
}
int32_t getC(){
if (uart[UART_LSR] & UART_LSR_DA) {
return uart[UART_RBR];
} else {
return -1;
}
}
uint32_t rdtime(){
return *((volatile uint32_t*) SIFIVE_TIME_BASE);
}
uint32_t rdtimeh(){
return *((volatile uint32_t*) (SIFIVE_TIME_BASE + 4));
}
void setMachineTimerCmp(uint32_t low, uint32_t high){
volatile uint32_t* base = (volatile uint32_t*) SIFIVE_TIMECMP_BASE;
base[1] = 0xffffffff;
base[0] = low;
base[1] = high;
}
void halInit(){
ns16550a_init();
}
#endif
#ifdef LITEX
// this is a file generated by LiteX
#include <generated/csr.h>
#if !defined(CSR_UART_BASE) || !defined(CSR_CPU_BASE)
#error LiteX configuration with uart and cpu_timer is required.
#endif
void stopSim(){
while(1);
}
void putC(char ch){
// protect against writing to a full tx fifo
while(uart_txfull_read());
uart_rxtx_write(ch);
}
int32_t getC(){
if(uart_rxempty_read())
{
return -1;
}
// this is required to refresh rexempty status
uart_ev_pending_write(1 << 1);
return uart_rxtx_read();
}
uint32_t rdtime(){
cpu_timer_latch_write(0);
uint32_t result = (uint32_t)cpu_timer_time_read();
cpu_timer_latch_write(1);
return result;
}
uint32_t rdtimeh(){
cpu_timer_latch_write(0);
uint32_t result = (uint32_t)(cpu_timer_time_read() >> 32);
cpu_timer_latch_write(1);
return result;
}
void setMachineTimerCmp(uint32_t low, uint32_t high){
cpu_timer_latch_write(0);
cpu_timer_time_cmp_write((((unsigned long long int)high) << 32) | low);
cpu_timer_latch_write(1);
}
void halInit(){
cpu_timer_latch_write(1);
}
#endif

View file

@ -0,0 +1,25 @@
#ifndef HAL_H
#define HAL_H
#include <stdint.h>
#define SBI_SET_TIMER 0
#define SBI_CONSOLE_PUTCHAR 1
#define SBI_CONSOLE_GETCHAR 2
#define SBI_CLEAR_IPI 3
#define SBI_SEND_IPI 4
#define SBI_REMOTE_FENCE_I 5
#define SBI_REMOTE_SFENCE_VMA 6
#define SBI_REMOTE_SFENCE_VMA_ASID 7
#define SBI_SHUTDOWN 8
void halInit();
void stopSim();
void putC(char c);
int32_t getC();
uint32_t rdtime();
uint32_t rdtimeh();
void setMachineTimerCmp(uint32_t low, uint32_t high);
#endif

288
src/main/c/emulator/src/main.c Executable file
View file

@ -0,0 +1,288 @@
#include <stdint.h>
#include "riscv.h"
#include "config.h"
#include "hal.h"
extern const uint32_t _sp;
extern void trapEntry();
extern void emulationTrap();
void putString(char* s){
while(*s){
putC(*s);
s++;
}
}
//Affect mtvec
void setup_pmp(void)
{
// Set up a PMP to permit access to all of memory.
// Ignore the illegal-instruction trap if PMPs aren't supported.
uintptr_t pmpc = PMP_NAPOT | PMP_R | PMP_W | PMP_X;
asm volatile ("la t0, 1f\n\t"
"csrw mtvec, t0\n\t"
"csrw pmpaddr0, %1\n\t"
"csrw pmpcfg0, %0\n\t"
".align 2\n\t"
"1:"
: : "r" (pmpc), "r" (-1UL) : "t0");
}
void init() {
setup_pmp();
halInit();
putString("*** VexRiscv BIOS ***\n");
uint32_t sp = (uint32_t) (&_sp);
csr_write(mtvec, trapEntry);
csr_write(mscratch, sp -32*4);
csr_write(mstatus, 0x0800 | MSTATUS_MPIE);
csr_write(mie, 0);
csr_write(mepc, OS_CALL);
//In future it would probably need to manage missaligned stuff, now it will stop the simulation
csr_write(medeleg, MEDELEG_INSTRUCTION_PAGE_FAULT | MEDELEG_LOAD_PAGE_FAULT | MEDELEG_STORE_PAGE_FAULT | MEDELEG_USER_ENVIRONNEMENT_CALL);
csr_write(mideleg, MIDELEG_SUPERVISOR_TIMER | MIDELEG_SUPERVISOR_EXTERNAL | MIDELEG_SUPERVISOR_SOFTWARE);
csr_write(sbadaddr, 0); //Used to avoid simulation missmatch
putString("*** Supervisor ***\n");
}
int readRegister(uint32_t id){
unsigned int sp = (unsigned int) (&_sp);
return ((int*) sp)[id-32];
}
void writeRegister(uint32_t id, int value){
uint32_t sp = (uint32_t) (&_sp);
((uint32_t*) sp)[id-32] = value;
}
//Currently, this should not happen, unless kernel things are going wrong
void redirectTrap(){
stopSim();
csr_write(sbadaddr, csr_read(mbadaddr));
csr_write(sepc, csr_read(mepc));
csr_write(scause, csr_read(mcause));
csr_write(mepc, csr_read(stvec));
}
void emulationTrapToSupervisorTrap(uint32_t sepc, uint32_t mstatus){
csr_write(mtvec, trapEntry);
csr_write(sbadaddr, csr_read(mbadaddr));
csr_write(scause, csr_read(mcause));
csr_write(sepc, sepc);
csr_write(mepc, csr_read(stvec));
csr_write(mstatus,
(mstatus & ~(MSTATUS_SPP | MSTATUS_MPP | MSTATUS_SIE | MSTATUS_SPIE))
| ((mstatus >> 3) & MSTATUS_SPP)
| (0x0800 | MSTATUS_MPIE)
| ((mstatus & MSTATUS_SIE) << 4)
);
}
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
//Will modify MTVEC
int32_t readWord(uint32_t address, int32_t *data){
int32_t result, tmp;
int32_t failed;
__asm__ __volatile__ (
" li %[tmp], 0x00020000\n"
" csrs mstatus, %[tmp]\n"
" la %[tmp], 1f\n"
" csrw mtvec, %[tmp]\n"
" li %[failed], 1\n"
" lw %[result], 0(%[address])\n"
" li %[failed], 0\n"
"1:\n"
" li %[tmp], 0x00020000\n"
" csrc mstatus, %[tmp]\n"
: [result]"=&r" (result), [failed]"=&r" (failed), [tmp]"=&r" (tmp)
: [address]"r" (address)
: "memory"
);
*data = result;
return failed;
}
//Will modify MTVEC
int32_t writeWord(uint32_t address, int32_t data){
int32_t result, tmp;
int32_t failed;
__asm__ __volatile__ (
" li %[tmp], 0x00020000\n"
" csrs mstatus, %[tmp]\n"
" la %[tmp], 1f\n"
" csrw mtvec, %[tmp]\n"
" li %[failed], 1\n"
" sw %[data], 0(%[address])\n"
" li %[failed], 0\n"
"1:\n"
" li %[tmp], 0x00020000\n"
" csrc mstatus, %[tmp]\n"
: [failed]"=&r" (failed), [tmp]"=&r" (tmp)
: [address]"r" (address), [data]"r" (data)
: "memory"
);
return failed;
}
void trap(){
int32_t cause = csr_read(mcause);
if(cause < 0){ //interrupt
switch(cause & 0xFF){
case CAUSE_MACHINE_TIMER:{
csr_set(sip, MIP_STIP);
csr_clear(mie, MIE_MTIE);
}break;
default: redirectTrap(); break;
}
} else { //exception
switch(cause){
case CAUSE_ILLEGAL_INSTRUCTION:{
uint32_t mepc = csr_read(mepc);
uint32_t mstatus = csr_read(mstatus);
#ifdef SIM
uint32_t instruction = csr_read(mbadaddr);
#endif
#if defined(QEMU) || defined(LITEX)
uint32_t instruction = 0;
uint32_t i;
if (mepc & 2) {
readWord(mepc - 2, &i);
i >>= 16;
if (i & 3 == 3) {
uint32_t u32Buf;
readWord(mepc+2, &u32Buf);
i |= u32Buf << 16;
}
} else {
readWord(mepc, &i);
}
instruction = i;
csr_write(mtvec, trapEntry); //Restore mtvec
#endif
uint32_t opcode = instruction & 0x7F;
uint32_t funct3 = (instruction >> 12) & 0x7;
switch(opcode){
case 0x2F: //Atomic
switch(funct3){
case 0x2:{
uint32_t sel = instruction >> 27;
uint32_t addr = readRegister((instruction >> 15) & 0x1F);
int32_t src = readRegister((instruction >> 20) & 0x1F);
uint32_t rd = (instruction >> 7) & 0x1F;
int32_t readValue;
if(readWord(addr, &readValue)){
emulationTrapToSupervisorTrap(mepc, mstatus);
return;
}
int writeValue;
switch(sel){
case 0x0: writeValue = src + readValue; break;
case 0x1: writeValue = src; break;
//LR SC done in hardware (cheap), and require to keep track of context switches
// case 0x2:{ //LR
// }break;
// case 0x3:{ //SC
// }break;
case 0x4: writeValue = src ^ readValue; break;
case 0xC: writeValue = src & readValue; break;
case 0x8: writeValue = src | readValue; break;
case 0x10: writeValue = min(src, readValue); break;
case 0x14: writeValue = max(src, readValue); break;
case 0x18: writeValue = min((unsigned int)src, (unsigned int)readValue); break;
case 0x1C: writeValue = max((unsigned int)src, (unsigned int)readValue); break;
default: redirectTrap(); return; break;
}
if(writeWord(addr, writeValue)){
emulationTrapToSupervisorTrap(mepc, mstatus);
return;
}
writeRegister(rd, readValue);
csr_write(mepc, mepc + 4);
csr_write(mtvec, trapEntry); //Restore mtvec
}break;
default: redirectTrap(); break;
} break;
case 0x73:{
//CSR
uint32_t input = (instruction & 0x4000) ? ((instruction >> 15) & 0x1F) : readRegister((instruction >> 15) & 0x1F);;
uint32_t clear, set;
uint32_t write;
switch (funct3 & 0x3) {
case 0: redirectTrap(); break;
case 1: clear = ~0; set = input; write = 1; break;
case 2: clear = 0; set = input; write = ((instruction >> 15) & 0x1F) != 0; break;
case 3: clear = input; set = 0; write = ((instruction >> 15) & 0x1F) != 0; break;
}
uint32_t csrAddress = instruction >> 20;
uint32_t old;
switch(csrAddress){
case RDCYCLE :
case RDINSTRET:
case RDTIME : old = rdtime(); break;
case RDCYCLEH :
case RDINSTRETH:
case RDTIMEH : old = rdtimeh(); break;
default: redirectTrap(); break;
}
if(write) {
uint32_t newValue = (old & ~clear) | set;
switch(csrAddress){
default: redirectTrap(); break;
}
}
writeRegister((instruction >> 7) & 0x1F, old);
csr_write(mepc, mepc + 4);
}break;
default: redirectTrap(); break;
}
}break;
case CAUSE_SCALL:{
uint32_t which = readRegister(17);
uint32_t a0 = readRegister(10);
uint32_t a1 = readRegister(11);
uint32_t a2 = readRegister(12);
switch(which){
case SBI_CONSOLE_PUTCHAR:{
putC(a0);
csr_write(mepc, csr_read(mepc) + 4);
}break;
case SBI_CONSOLE_GETCHAR:{
writeRegister(10, getC()); //no char
csr_write(mepc, csr_read(mepc) + 4);
}break;
case SBI_SET_TIMER:{
setMachineTimerCmp(a0, a1);
csr_set(mie, MIE_MTIE);
csr_clear(sip, MIP_STIP);
csr_write(mepc, csr_read(mepc) + 4);
}break;
default: stopSim(); break;
}
}break;
default: redirectTrap(); break;
}
}
}

View file

@ -0,0 +1,133 @@
#ifndef RISCV_H
#define RISCV_H
#define CAUSE_ILLEGAL_INSTRUCTION 2
#define CAUSE_MACHINE_TIMER 7
#define CAUSE_SCALL 9
#define MEDELEG_INSTRUCTION_PAGE_FAULT (1 << 12)
#define MEDELEG_LOAD_PAGE_FAULT (1 << 13)
#define MEDELEG_STORE_PAGE_FAULT (1 << 15)
#define MEDELEG_USER_ENVIRONNEMENT_CALL (1 << 8)
#define MIDELEG_SUPERVISOR_SOFTWARE (1 << 1)
#define MIDELEG_SUPERVISOR_TIMER (1 << 5)
#define MIDELEG_SUPERVISOR_EXTERNAL (1 << 9)
#define MIE_MTIE (1 << 7)
#define MIP_STIP (1 << 5)
#define MSTATUS_UIE 0x00000001
#define MSTATUS_SIE 0x00000002
#define MSTATUS_HIE 0x00000004
#define MSTATUS_MIE 0x00000008
#define MSTATUS_UPIE 0x00000010
#define MSTATUS_SPIE 0x00000020
#define MSTATUS_HPIE 0x00000040
#define MSTATUS_MPIE 0x00000080
#define MSTATUS_SPP 0x00000100
#define MSTATUS_HPP 0x00000600
#define MSTATUS_MPP 0x00001800
#define MSTATUS_FS 0x00006000
#define MSTATUS_XS 0x00018000
#define MSTATUS_MPRV 0x00020000
#define MSTATUS_SUM 0x00040000
#define MSTATUS_MXR 0x00080000
#define MSTATUS_TVM 0x00100000
#define MSTATUS_TW 0x00200000
#define MSTATUS_TSR 0x00400000
#define MSTATUS32_SD 0x80000000
#define MSTATUS_UXL 0x0000000300000000
#define MSTATUS_SXL 0x0000000C00000000
#define MSTATUS64_SD 0x8000000000000000
#define SSTATUS_UIE 0x00000001
#define SSTATUS_SIE 0x00000002
#define SSTATUS_UPIE 0x00000010
#define SSTATUS_SPIE 0x00000020
#define SSTATUS_SPP 0x00000100
#define SSTATUS_FS 0x00006000
#define SSTATUS_XS 0x00018000
#define SSTATUS_SUM 0x00040000
#define SSTATUS_MXR 0x00080000
#define SSTATUS32_SD 0x80000000
#define SSTATUS_UXL 0x0000000300000000
#define SSTATUS64_SD 0x8000000000000000
#define PMP_R 0x01
#define PMP_W 0x02
#define PMP_X 0x04
#define PMP_A 0x18
#define PMP_L 0x80
#define PMP_SHIFT 2
#define PMP_TOR 0x08
#define PMP_NA4 0x10
#define PMP_NAPOT 0x18
#define RDCYCLE 0xC00 //Read-only cycle Cycle counter for RDCYCLE instruction.
#define RDTIME 0xC01 //Read-only time Timer for RDTIME instruction.
#define RDINSTRET 0xC02 //Read-only instret Instructions-retired counter for RDINSTRET instruction.
#define RDCYCLEH 0xC80 //Read-only cycleh Upper 32 bits of cycle, RV32I only.
#define RDTIMEH 0xC81 //Read-only timeh Upper 32 bits of time, RV32I only.
#define RDINSTRETH 0xC82 //Read-only instreth Upper 32 bits of instret, RV32I only.
#define csr_swap(csr, val) \
({ \
unsigned long __v = (unsigned long)(val); \
__asm__ __volatile__ ("csrrw %0, " #csr ", %1" \
: "=r" (__v) : "rK" (__v)); \
__v; \
})
#define csr_read(csr) \
({ \
register unsigned long __v; \
__asm__ __volatile__ ("csrr %0, " #csr \
: "=r" (__v)); \
__v; \
})
#define csr_write(csr, val) \
({ \
unsigned long __v = (unsigned long)(val); \
__asm__ __volatile__ ("csrw " #csr ", %0" \
: : "rK" (__v)); \
})
#define csr_read_set(csr, val) \
({ \
unsigned long __v = (unsigned long)(val); \
__asm__ __volatile__ ("csrrs %0, " #csr ", %1" \
: "=r" (__v) : "rK" (__v)); \
__v; \
})
#define csr_set(csr, val) \
({ \
unsigned long __v = (unsigned long)(val); \
__asm__ __volatile__ ("csrs " #csr ", %0" \
: : "rK" (__v)); \
})
#define csr_read_clear(csr, val) \
({ \
unsigned long __v = (unsigned long)(val); \
__asm__ __volatile__ ("csrrc %0, " #csr ", %1" \
: "=r" (__v) : "rK" (__v)); \
__v; \
})
#define csr_clear(csr, val) \
({ \
unsigned long __v = (unsigned long)(val); \
__asm__ __volatile__ ("csrc " #csr ", %0" \
: : "rK" (__v)); \
})
#endif

51
src/main/c/emulator/src/start.S Executable file
View file

@ -0,0 +1,51 @@
.section .init
.globl _start
.type _start,@function
#include "config.h"
_start:
/*#ifdef USE_GP
.option push
.option norelax
la gp, __global_pointer$
.option pop
#endif*/
la sp, _sp
/* Load data section */
la a0, _data_lma
la a1, _data
la a2, _edata
bgeu a1, a2, 2f
1:
lw t0, (a0)
sw t0, (a1)
addi a0, a0, 4
addi a1, a1, 4
bltu a1, a2, 1b
2:
/* Clear bss section */
la a0, __bss_start
la a1, _end
bgeu a0, a1, 2f
1:
sw zero, (a0)
addi a0, a0, 4
bltu a0, a1, 1b
2:
call __libc_init_array
call init
la ra, done
li a0, 0
li a1, DTB
mret
done:
j done
.globl _init
_init:
ret

View file

@ -0,0 +1,71 @@
.section .init
.globl trapEntry
.type trapEntry,@function
trapEntry:
csrrw sp, mscratch, sp
sw x1, 1*4(sp)
sw x3, 3*4(sp)
sw x4, 4*4(sp)
sw x5, 5*4(sp)
sw x6, 6*4(sp)
sw x7, 7*4(sp)
sw x8, 8*4(sp)
sw x9, 9*4(sp)
sw x10, 10*4(sp)
sw x11, 11*4(sp)
sw x12, 12*4(sp)
sw x13, 13*4(sp)
sw x14, 14*4(sp)
sw x15, 15*4(sp)
sw x16, 16*4(sp)
sw x17, 17*4(sp)
sw x18, 18*4(sp)
sw x19, 19*4(sp)
sw x20, 20*4(sp)
sw x21, 21*4(sp)
sw x22, 22*4(sp)
sw x23, 23*4(sp)
sw x24, 24*4(sp)
sw x25, 25*4(sp)
sw x26, 26*4(sp)
sw x27, 27*4(sp)
sw x28, 28*4(sp)
sw x29, 29*4(sp)
sw x30, 30*4(sp)
sw x31, 31*4(sp)
call trap
lw x1, 1*4(sp)
lw x3, 3*4(sp)
lw x4, 4*4(sp)
lw x5, 5*4(sp)
lw x6, 6*4(sp)
lw x7, 7*4(sp)
lw x8, 8*4(sp)
lw x9, 9*4(sp)
lw x10, 10*4(sp)
lw x11, 11*4(sp)
lw x12, 12*4(sp)
lw x13, 13*4(sp)
lw x14, 14*4(sp)
lw x15, 15*4(sp)
lw x16, 16*4(sp)
lw x17, 17*4(sp)
lw x18, 18*4(sp)
lw x19, 19*4(sp)
lw x20, 20*4(sp)
lw x21, 21*4(sp)
lw x22, 22*4(sp)
lw x23, 23*4(sp)
lw x24, 24*4(sp)
lw x25, 25*4(sp)
lw x26, 26*4(sp)
lw x27, 27*4(sp)
lw x28, 28*4(sp)
lw x29, 29*4(sp)
lw x30, 30*4(sp)
lw x31, 31*4(sp)
csrrw sp, mscratch, sp
mret

View file

@ -0,0 +1,47 @@
#include "riscv.h"
/*
.section .init
.globl readMemory
.type readMemory,@function
readWord:
csrr a4, mepc
li a2, MSTATUS_MPRV
csrs mstatus, a2
li a3, emulationTrap
csrw mepc, a3
lw a0, 0(a0)
li a3, trapEntry
csrw mepc, a3
csrc mstatus, a2
writeWord:
csrr a4, mepc
li a2, MSTATUS_MPRV
csrs mstatus, a2
li a3, emulationTrap
csrw mepc, a3
sw a1, 0(a0)
li a3, trapEntry
csrw mepc, a3
csrc mstatus, a2
*/
//Redirect trap to supervisor
/*
.section .init
.globl emulationTrap
.type emulationTrap,@function
emulationTrap:
li a0, MSTATUS_MPRV
csrc mstatus, a0
la sp, _sp
csrw sepc, a4
csrr a0, mcause
csrw scause, a0
csrr a0, mbadaddr
csrw sbadaddr, a0
call init
mret
*/

View file

@ -0,0 +1,134 @@
PROJ_NAME=hello_world
DEBUG=no
BENCH=no
MULDIV=no
SRCS = $(wildcard src/*.c) \
$(wildcard src/*.cpp) \
$(wildcard src/*.S)
OBJDIR = build
INC =
LIBS =
LIBSINC = -L$(OBJDIR)
LDSCRIPT = ./src/linker.ld
#include ../../../resources/gcc.mk
# Set it to yes if you are using the sifive precompiled GCC pack
SIFIVE_GCC_PACK ?= yes
ifeq ($(SIFIVE_GCC_PACK),yes)
RISCV_NAME ?= riscv64-unknown-elf
RISCV_PATH ?= /opt/riscv/
else
RISCV_NAME ?= riscv32-unknown-elf
ifeq ($(MULDIV),yes)
RISCV_PATH ?= /opt/riscv32im/
else
RISCV_PATH ?= /opt/riscv32i/
endif
endif
MABI=ilp32
MARCH := rv32i
ifeq ($(MULDIV),yes)
MARCH := $(MARCH)m
endif
ifeq ($(COMPRESSED),yes)
MARCH := $(MARCH)ac
endif
CFLAGS += -march=$(MARCH) -mabi=$(MABI) -DNDEBUG
LDFLAGS += -march=$(MARCH) -mabi=$(MABI)
#include ../../../resources/subproject.mk
ifeq ($(DEBUG),yes)
CFLAGS += -g3 -O0
endif
ifeq ($(DEBUG),no)
CFLAGS += -g -Os
endif
ifeq ($(BENCH),yes)
CFLAGS += -fno-inline
endif
ifeq ($(SIFIVE_GCC_PACK),yes)
RISCV_CLIB=$(RISCV_PATH)/$(RISCV_NAME)/lib/$(MARCH)/$(MABI)/
else
RISCV_CLIB=$(RISCV_PATH)/$(RISCV_NAME)/lib/
endif
RISCV_OBJCOPY = $(RISCV_PATH)/bin/$(RISCV_NAME)-objcopy
RISCV_OBJDUMP = $(RISCV_PATH)/bin/$(RISCV_NAME)-objdump
RISCV_CC=$(RISCV_PATH)/bin/$(RISCV_NAME)-gcc
CFLAGS += -MD -fstrict-volatile-bitfields -fno-strict-aliasing
LDFLAGS += -nostdlib -lgcc -mcmodel=medany -nostartfiles -ffreestanding -Wl,-Bstatic,-T,$(LDSCRIPT),-Map,$(OBJDIR)/$(PROJ_NAME).map,--print-memory-usage
#LDFLAGS += -lgcc -lc -lg -nostdlib -lgcc -msave-restore --strip-debug,
OBJS := $(SRCS)
OBJS := $(OBJS:.c=.o)
OBJS := $(OBJS:.cpp=.o)
OBJS := $(OBJS:.S=.o)
OBJS := $(OBJS:..=miaou)
OBJS := $(addprefix $(OBJDIR)/,$(OBJS))
all: $(OBJDIR)/$(PROJ_NAME).elf $(OBJDIR)/$(PROJ_NAME).hex $(OBJDIR)/$(PROJ_NAME).asm $(OBJDIR)/$(PROJ_NAME).v
$(OBJDIR)/%.elf: $(OBJS) | $(OBJDIR)
$(RISCV_CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBSINC) $(LIBS)
%.hex: %.elf
$(RISCV_OBJCOPY) -O ihex $^ $@
%.bin: %.elf
$(RISCV_OBJCOPY) -O binary $^ $@
%.v: %.elf
$(RISCV_OBJCOPY) -O verilog $^ $@
%.asm: %.elf
$(RISCV_OBJDUMP) -S -d $^ > $@
$(OBJDIR)/%.o: %.c
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
$(RISCV_CC) -S $(CFLAGS) $(INC) -o $@.disasm $^
$(OBJDIR)/%.o: %.cpp
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
$(OBJDIR)/%.o: %.S
mkdir -p $(dir $@)
$(RISCV_CC) -c $(CFLAGS) -o $@ $^ -D__ASSEMBLY__=1
$(OBJDIR):
mkdir -p $@
.PHONY: clean
clean:
rm -rf $(OBJDIR)/src
rm -f $(OBJDIR)/$(PROJ_NAME).elf
rm -f $(OBJDIR)/$(PROJ_NAME).hex
rm -f $(OBJDIR)/$(PROJ_NAME).map
rm -f $(OBJDIR)/$(PROJ_NAME).v
rm -f $(OBJDIR)/$(PROJ_NAME).asm
find $(OBJDIR) -type f -name '*.o' -print0 | xargs -0 -r rm
find $(OBJDIR) -type f -name '*.d' -print0 | xargs -0 -r rm
clean-all : clean
.SECONDARY: $(OBJS)

View file

@ -0,0 +1,98 @@
.global crtStart
.global main
.global irqCallback
.section .start_jump,"ax",@progbits
crtStart:
//long jump to allow crtInit to be anywhere
//do it always in 12 bytes
lui x2, %hi(crtInit)
addi x2, x2, %lo(crtInit)
jalr x1,x2
nop
.section .text
.global trap_entry
.align 5
trap_entry:
sw x1, - 1*4(sp)
sw x5, - 2*4(sp)
sw x6, - 3*4(sp)
sw x7, - 4*4(sp)
sw x10, - 5*4(sp)
sw x11, - 6*4(sp)
sw x12, - 7*4(sp)
sw x13, - 8*4(sp)
sw x14, - 9*4(sp)
sw x15, -10*4(sp)
sw x16, -11*4(sp)
sw x17, -12*4(sp)
sw x28, -13*4(sp)
sw x29, -14*4(sp)
sw x30, -15*4(sp)
sw x31, -16*4(sp)
addi sp,sp,-16*4
call irqCallback
lw x1 , 15*4(sp)
lw x5, 14*4(sp)
lw x6, 13*4(sp)
lw x7, 12*4(sp)
lw x10, 11*4(sp)
lw x11, 10*4(sp)
lw x12, 9*4(sp)
lw x13, 8*4(sp)
lw x14, 7*4(sp)
lw x15, 6*4(sp)
lw x16, 5*4(sp)
lw x17, 4*4(sp)
lw x28, 3*4(sp)
lw x29, 2*4(sp)
lw x30, 1*4(sp)
lw x31, 0*4(sp)
addi sp,sp,16*4
mret
.text
crtInit:
.option push
.option norelax
la gp, __global_pointer$
.option pop
la sp, _stack_start
bss_init:
la a0, _bss_start
la a1, _bss_end
bss_loop:
beq a0,a1,bss_done
sw zero,0(a0)
add a0,a0,4
j bss_loop
bss_done:
ctors_init:
la a0, _ctors_start
addi sp,sp,-4
ctors_loop:
la a1, _ctors_end
beq a0,a1,ctors_done
lw a3,0(a0)
add a0,a0,4
sw a0,0(sp)
jalr a3
lw a0,0(sp)
j ctors_loop
ctors_done:
addi sp,sp,4
li a0, 0x880 //880 enable timer + external interrupts
csrw mie,a0
li a0, 0x1808 //1808 enable interrupts
csrw mstatus,a0
call main
infinitLoop:
j infinitLoop

View file

@ -0,0 +1,15 @@
#ifndef GPIO_H_
#define GPIO_H_
typedef struct
{
volatile uint32_t INPUT;
volatile uint32_t OUTPUT;
volatile uint32_t OUTPUT_ENABLE;
} Gpio_Reg;
#endif /* GPIO_H_ */

View file

@ -0,0 +1,17 @@
#ifndef INTERRUPTCTRL_H_
#define INTERRUPTCTRL_H_
#include <stdint.h>
typedef struct
{
volatile uint32_t PENDINGS;
volatile uint32_t MASKS;
} InterruptCtrl_Reg;
static void interruptCtrl_init(InterruptCtrl_Reg* reg){
reg->MASKS = 0;
reg->PENDINGS = 0xFFFFFFFF;
}
#endif /* INTERRUPTCTRL_H_ */

View file

@ -0,0 +1,110 @@
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
*/
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
OUTPUT_ARCH(riscv)
ENTRY(crtStart)
MEMORY {
RAM (rwx): ORIGIN = 0x80000000, LENGTH = 2k
}
_stack_size = DEFINED(_stack_size) ? _stack_size : 256;
_heap_size = DEFINED(_heap_size) ? _heap_size : 0;
SECTIONS {
._vector ORIGIN(RAM): {
*crt.o(.start_jump);
*crt.o(.text);
} > RAM
._user_heap (NOLOAD):
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
PROVIDE ( _heap_start = .);
. = . + _heap_size;
. = ALIGN(8);
PROVIDE ( _heap_end = .);
} > RAM
._stack (NOLOAD):
{
. = ALIGN(16);
PROVIDE (_stack_end = .);
. = . + _stack_size;
. = ALIGN(16);
PROVIDE (_stack_start = .);
} > RAM
.data :
{
*(.rdata)
*(.rodata .rodata.*)
*(.gnu.linkonce.r.*)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.*)
*(.gnu.linkonce.s.*)
. = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
*(.srodata.cst2)
*(.srodata .srodata.*)
} > RAM
.bss (NOLOAD) : {
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_bss_start = .;
*(.sbss*)
*(.gnu.linkonce.sb.*)
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_bss_end = .;
} > RAM
.rodata :
{
*(.rdata)
*(.rodata .rodata.*)
*(.gnu.linkonce.r.*)
} > RAM
.noinit (NOLOAD) : {
. = ALIGN(4);
*(.noinit .noinit.*)
. = ALIGN(4);
} > RAM
.memory : {
*(.text);
end = .;
} > RAM
.ctors :
{
. = ALIGN(4);
_ctors_start = .;
KEEP(*(.init_array*))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
. = ALIGN(4);
_ctors_end = .;
PROVIDE ( END_OF_SW_IMAGE = . );
} > RAM
}

View file

@ -0,0 +1,42 @@
//#include "stddefs.h"
#include <stdint.h>
#include "murax.h"
void print(const char*str){
while(*str){
uart_write(UART,*str);
str++;
}
}
void println(const char*str){
print(str);
uart_write(UART,'\n');
}
void delay(uint32_t loops){
for(int i=0;i<loops;i++){
int tmp = GPIO_A->OUTPUT;
}
}
void main() {
GPIO_A->OUTPUT_ENABLE = 0x0000000F;
GPIO_A->OUTPUT = 0x00000001;
println("hello world arty a7 v1");
const int nleds = 4;
const int nloops = 2000000;
while(1){
for(unsigned int i=0;i<nleds-1;i++){
GPIO_A->OUTPUT = 1<<i;
delay(nloops);
}
for(unsigned int i=0;i<nleds-1;i++){
GPIO_A->OUTPUT = (1<<(nleds-1))>>i;
delay(nloops);
}
}
}
void irqCallback(){
}

View file

@ -0,0 +1,17 @@
#ifndef __MURAX_H__
#define __MURAX_H__
#include "timer.h"
#include "prescaler.h"
#include "interrupt.h"
#include "gpio.h"
#include "uart.h"
#define GPIO_A ((Gpio_Reg*)(0xF0000000))
#define TIMER_PRESCALER ((Prescaler_Reg*)0xF0020000)
#define TIMER_INTERRUPT ((InterruptCtrl_Reg*)0xF0020010)
#define TIMER_A ((Timer_Reg*)0xF0020040)
#define TIMER_B ((Timer_Reg*)0xF0020050)
#define UART ((Uart_Reg*)(0xF0010000))
#endif /* __MURAX_H__ */

View file

@ -0,0 +1,16 @@
#ifndef PRESCALERCTRL_H_
#define PRESCALERCTRL_H_
#include <stdint.h>
typedef struct
{
volatile uint32_t LIMIT;
} Prescaler_Reg;
static void prescaler_init(Prescaler_Reg* reg){
}
#endif /* PRESCALERCTRL_H_ */

View file

@ -0,0 +1,20 @@
#ifndef TIMERCTRL_H_
#define TIMERCTRL_H_
#include <stdint.h>
typedef struct
{
volatile uint32_t CLEARS_TICKS;
volatile uint32_t LIMIT;
volatile uint32_t VALUE;
} Timer_Reg;
static void timer_init(Timer_Reg *reg){
reg->CLEARS_TICKS = 0;
reg->VALUE = 0;
}
#endif /* TIMERCTRL_H_ */

View file

@ -0,0 +1,42 @@
#ifndef UART_H_
#define UART_H_
typedef struct
{
volatile uint32_t DATA;
volatile uint32_t STATUS;
volatile uint32_t CLOCK_DIVIDER;
volatile uint32_t FRAME_CONFIG;
} Uart_Reg;
enum UartParity {NONE = 0,EVEN = 1,ODD = 2};
enum UartStop {ONE = 0,TWO = 1};
typedef struct {
uint32_t dataLength;
enum UartParity parity;
enum UartStop stop;
uint32_t clockDivider;
} Uart_Config;
static uint32_t uart_writeAvailability(Uart_Reg *reg){
return (reg->STATUS >> 16) & 0xFF;
}
static uint32_t uart_readOccupancy(Uart_Reg *reg){
return reg->STATUS >> 24;
}
static void uart_write(Uart_Reg *reg, uint32_t data){
while(uart_writeAvailability(reg) == 0);
reg->DATA = data;
}
static void uart_applyConfig(Uart_Reg *reg, Uart_Config *config){
reg->CLOCK_DIVIDER = config->clockDivider;
reg->FRAME_CONFIG = ((config->dataLength-1) << 0) | (config->parity << 8) | (config->stop << 16);
}
#endif /* UART_H_ */

View file

@ -42,13 +42,33 @@ crtStart:
li t0, 0x1
sw t0, CTRL_XIP_CONFIG(CTRL)
li t0, XIP_BASE
lw t1, (t0)
li t2, 0xFFFFFFFF
xor t3,t1,t2
beqz t3,retry
//if we are here we have read a value from flash which is not all ones
lw t2, (t0)
xor t3,t1,t2
bnez t3,retry
lw t2, (t0)
xor t3,t1,t2
bnez t3,retry
//if we are here we have read the same value 3 times, so flash seems good, lets's jump
jr t0
retry:
li a0, 0x800
call spiWrite
li t1,100000
loop:
addi t1,t1,-1
bnez t1, loop
j crtStart
spiWrite:
sw a0,CTRL_DATA(CTRL)
spiWrite_wait:
lw t0,CTRL_STATUS(CTRL)
srli t0,t0,0x10
slli t0,t0,0x10
beqz t0,spiWrite_wait
ret

Some files were not shown because too many files have changed in this diff Show more