aboutsummaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-11-19 14:01:16 +0100
committerClifford Wolf <clifford@clifford.at>2015-11-19 14:01:16 +0100
commitd8ffbf044af01391d6fd5ccbb30e6b23e785e487 (patch)
tree2930ebca52c36fc39324f57bd8799169b20203c1 /firmware
parent9d5f8ad8e637cd76ddae99115724b0e6a6aaa31f (diff)
downloadpicorv32-d8ffbf044af01391d6fd5ccbb30e6b23e785e487.tar.gz
picorv32-d8ffbf044af01391d6fd5ccbb30e6b23e785e487.zip
Test firmware: Added print_hex() digits arg
Diffstat (limited to 'firmware')
-rw-r--r--firmware/firmware.h2
-rw-r--r--firmware/irq.c12
-rw-r--r--firmware/multest.c24
-rw-r--r--firmware/print.c4
-rw-r--r--firmware/sieve.c2
5 files changed, 22 insertions, 22 deletions
diff --git a/firmware/firmware.h b/firmware/firmware.h
index ce5e321..59b5c75 100644
--- a/firmware/firmware.h
+++ b/firmware/firmware.h
@@ -18,7 +18,7 @@ uint32_t *irq(uint32_t *regs, uint32_t irqs);
void print_chr(char ch);
void print_str(const char *p);
void print_dec(unsigned int val);
-void print_hex(unsigned int val);
+void print_hex(unsigned int val, int digits);
// sieve.c
void sieve(void);
diff --git a/firmware/irq.c b/firmware/irq.c
index ec37614..5a7ec27 100644
--- a/firmware/irq.c
+++ b/firmware/irq.c
@@ -40,22 +40,22 @@ uint32_t *irq(uint32_t *regs, uint32_t irqs)
if ((irqs & 2) != 0) {
if (instr == 0x00100073) {
print_str("SBREAK instruction at 0x");
- print_hex(pc);
+ print_hex(pc, 8);
print_str("\n");
} else {
print_str("Illegal Instruction at 0x");
- print_hex(pc);
+ print_hex(pc, 8);
print_str(": 0x");
- print_hex(instr);
+ print_hex(instr, ((instr & 3) == 3) ? 8 : 4);
print_str("\n");
}
}
if ((irqs & 4) != 0) {
print_str("Bus error in Instruction at 0x");
- print_hex(pc);
+ print_hex(pc, 8);
print_str(": 0x");
- print_hex(instr);
+ print_hex(instr, ((instr & 3) == 3) ? 8 : 4);
print_str("\n");
}
@@ -91,7 +91,7 @@ uint32_t *irq(uint32_t *regs, uint32_t irqs)
print_chr(' ');
}
- print_hex(regs[r]);
+ print_hex(regs[r], 8);
print_str(k == 3 ? "\n" : " ");
}
diff --git a/firmware/multest.c b/firmware/multest.c
index 37ecf32..5b68555 100644
--- a/firmware/multest.c
+++ b/firmware/multest.c
@@ -26,51 +26,51 @@ void multest(void)
int64_t as = (int32_t)a, bs = (int32_t)b;
print_str("input [");
- print_hex(as >> 32);
+ print_hex(as >> 32, 8);
print_str("] ");
- print_hex(a);
+ print_hex(a, 8);
print_str(" [");
- print_hex(bs >> 32);
+ print_hex(bs >> 32, 8);
print_str("] ");
- print_hex(b);
+ print_hex(b, 8);
print_chr('\n');
uint32_t h_mul, h_mulh, h_mulhsu, h_mulhu;
print_str("hard ");
h_mul = hard_mul(a, b);
- print_hex(h_mul);
+ print_hex(h_mul, 8);
print_str(" ");
h_mulh = hard_mulh(a, b);
- print_hex(h_mulh);
+ print_hex(h_mulh, 8);
print_str(" ");
h_mulhsu = hard_mulhsu(a, b);
- print_hex(h_mulhsu);
+ print_hex(h_mulhsu, 8);
print_str(" ");
h_mulhu = hard_mulhu(a, b);
- print_hex(h_mulhu);
+ print_hex(h_mulhu, 8);
print_chr('\n');
uint32_t s_mul, s_mulh, s_mulhsu, s_mulhu;
print_str("soft ");
s_mul = a * b;
- print_hex(s_mul);
+ print_hex(s_mul, 8);
print_str(" ");
s_mulh = (as * bs) >> 32;
- print_hex(s_mulh);
+ print_hex(s_mulh, 8);
print_str(" ");
s_mulhsu = (as * bu) >> 32;
- print_hex(s_mulhsu);
+ print_hex(s_mulhsu, 8);
print_str(" ");
s_mulhu = (au * bu) >> 32;
- print_hex(s_mulhu);
+ print_hex(s_mulhu, 8);
print_str(" ");
if (s_mul != h_mul || s_mulh != h_mulh || s_mulhsu != h_mulhsu || s_mulhu != h_mulhu) {
diff --git a/firmware/print.c b/firmware/print.c
index a3000f5..accce26 100644
--- a/firmware/print.c
+++ b/firmware/print.c
@@ -33,9 +33,9 @@ void print_dec(unsigned int val)
}
}
-void print_hex(unsigned int val)
+void print_hex(unsigned int val, int digits)
{
- for (int i = 32-4; i >= 0; i -= 4)
+ for (int i = (4*digits)-4; i >= 0; i -= 4)
*((volatile uint32_t*)OUTPORT) = "0123456789ABCDEF"[(val >> i) % 16];
}
diff --git a/firmware/sieve.c b/firmware/sieve.c
index f3350c6..c31e942 100644
--- a/firmware/sieve.c
+++ b/firmware/sieve.c
@@ -72,7 +72,7 @@ void sieve(void)
}
print_str("checksum: ");
- print_hex(hash);
+ print_hex(hash, 8);
if (hash == 0x1772A48F) {
print_str(" OK\n");