Test firmware: Added print_hex() digits arg
This commit is contained in:
		
							parent
							
								
									9d5f8ad8e6
								
							
						
					
					
						commit
						d8ffbf044a
					
				|  | @ -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); | ||||
|  |  | |||
|  | @ -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" : "    "); | ||||
| 		} | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -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]; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -72,7 +72,7 @@ void sieve(void) | |||
| 	} | ||||
| 
 | ||||
| 	print_str("checksum: "); | ||||
| 	print_hex(hash); | ||||
| 	print_hex(hash, 8); | ||||
| 
 | ||||
| 	if (hash == 0x1772A48F) { | ||||
| 		print_str(" OK\n"); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue