From fb4cf0462b591532de349bbbbeba1bbd93ca87da Mon Sep 17 00:00:00 2001 From: Martin Schoeberl Date: Thu, 18 Jul 2024 12:36:01 +0200 Subject: [PATCH] Blinking LED --- Makefile | 2 +- TODO.md | 1 + asm/blink.s | 19 ++++++++++++ asm/test/blink.s | 79 ------------------------------------------------ 4 files changed, 21 insertions(+), 80 deletions(-) create mode 100644 asm/blink.s delete mode 100644 asm/test/blink.s diff --git a/Makefile b/Makefile index e477fe8..bbfb8eb 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ swsim: sbt -Dprogram=$(APP) "testOnly leros.sim.LerosSimTest" hw: - sbt "runMain leros.Leros asm/test/$(APP).s" + sbt "runMain leros.Leros asm/$(APP).s" test-alu: sbt "test:runMain leros.AluTester" diff --git a/TODO.md b/TODO.md index c84e308..01f684e 100644 --- a/TODO.md +++ b/TODO.md @@ -44,6 +44,7 @@ * wondering on timing and layout in Quartus - [ ] Get rid of code duplication in Decode - [ ] Do memory mapped IO + - [ ] Be able to simulate source in asm - [x] Setup FPGA (Nexys A7) - [x] Use chipdesign1 for synthesis, OpenOCD for configuration - [ ] get a blinking LED running diff --git a/asm/blink.s b/asm/blink.s new file mode 100644 index 0000000..698b720 --- /dev/null +++ b/asm/blink.s @@ -0,0 +1,19 @@ +// Blinking LEDs + +// We need 2.500.000 iterations for a 100 ms tick +// + + loadi 0 + store r2 +loop: + loadi 255 + loadhi 255 + loadh2i 38 +l1: + subi 1 + brnz l1 // one loop iteration is 4 cc + load r2 + stind 0 + addi 1 + store r2 + br loop \ No newline at end of file diff --git a/asm/test/blink.s b/asm/test/blink.s deleted file mode 100644 index d29fa64..0000000 --- a/asm/test/blink.s +++ /dev/null @@ -1,79 +0,0 @@ -// work in progress -// branch does not yet work!!! - - loadi 0 - scall 0 - store r2 -loop: - loadi 127 -// loadhi ... -l1: - subi 1 - nop - brnz l1 - - - loadi 0 - store r5 -start: - loadi 0 -// loadhi 2 - store r0 -ll1: - loadi 127 -// loadhi 255 -ll2: - subi 1 - nop - brnz ll2 - nop - load r0 - subi 1 - store r0 - brnz ll1 - nop - - load r5 - addi 3 - store r5 - // loadi 0 - stind 0 - - // loadi 1 - // nop - // brnz start - - loadi 0 -// loadhi 2 - store r0 -ll3: - loadi 255 -// loadhi 255 -ll4: - subi 1 - nop - brnz ll4 - nop - load r0 - subi 1 - store r0 - brnz ll3 - nop - - loadi 2 - stind 0 - - loadi 1 - nop - nop - nop - brnz start - - loadi 2 - nop - nop - nop - - loadi 0 - scall 0 -