URL
https://opencores.org/ocsvn/zipcpu/zipcpu/trunk
Subversion Repositories zipcpu
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 207 to Rev 206
- ↔ Reverse comparison
Rev 207 → Rev 206
/zipcpu/trunk/sim/cpp/zipelf.cpp
1,4 → 1,4
//////////////////////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////////////////////// |
// |
// Filename: zipelf.cpp |
// |
10,9 → 10,9
// Creator: Dan Gisselquist, Ph.D. |
// Gisselquist Technology, LLC |
// |
//////////////////////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////////////////////// |
// |
// Copyright (C) 2015-2017, Gisselquist Technology, LLC |
// Copyright (C) 2015-2016, Gisselquist Technology, LLC |
// |
// This program is free software (firmware): you can redistribute it and/or |
// modify it under the terms of the GNU General Public License as published |
24,16 → 24,11
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with this program. (It's in the $(ROOT)/doc directory. Run make with no |
// target there if the PDF file isn't present.) If not, see |
// <http://www.gnu.org/licenses/> for a copy. |
// |
// License: GPL, v3, as defined and found on www.gnu.org, |
// http://www.gnu.org/licenses/gpl.html |
// |
// |
//////////////////////////////////////////////////////////////////////////////// |
/////////////////////////////////////////////////////////////////////////////// |
// |
// |
|
119,17 → 114,17
} |
|
if (dbg) { |
fprintf(stderr," %-20s 0x%jx\n","e_type", (uintmax_t)ehdr.e_type); |
fprintf(stderr," %-20s 0x%jx\n","e_machine", (uintmax_t)ehdr.e_machine); |
fprintf(stderr," %-20s 0x%jx\n","e_version", (uintmax_t)ehdr.e_version); |
fprintf(stderr," %-20s 0x%jx\n","e_entry",(uintmax_t)ehdr.e_entry); |
fprintf(stderr," %-20s 0x%jx\n","e_phoff",(uintmax_t)ehdr.e_phoff); |
fprintf(stderr," %-20s 0x%jx\n","e_shoff",(uintmax_t)ehdr.e_shoff); |
fprintf(stderr," %-20s 0x%jx\n","e_flags",(uintmax_t)ehdr.e_flags); |
fprintf(stderr," %-20s 0x%jx\n","e_ehsize",(uintmax_t)ehdr.e_ehsize); |
fprintf(stderr," %-20s 0x%jx\n","e_phentsize", (uintmax_t)ehdr.e_phentsize); |
fprintf(stderr," %-20s 0x%jx\n","e_shentsize", (uintmax_t)ehdr.e_shentsize); |
fprintf(stderr,"\n"); |
printf(" %-20s 0x%jx\n", "e_type", (uintmax_t)ehdr.e_type); |
printf(" %-20s 0x%jx\n", "e_machine", (uintmax_t)ehdr.e_machine); |
printf(" %-20s 0x%jx\n", "e_version", (uintmax_t)ehdr.e_version); |
printf(" %-20s 0x%jx\n", "e_entry", (uintmax_t)ehdr.e_entry); |
printf(" %-20s 0x%jx\n", "e_phoff", (uintmax_t)ehdr.e_phoff); |
printf(" %-20s 0x%jx\n", "e_shoff", (uintmax_t)ehdr.e_shoff); |
printf(" %-20s 0x%jx\n", "e_flags", (uintmax_t)ehdr.e_flags); |
printf(" %-20s 0x%jx\n", "e_ehsize", (uintmax_t)ehdr.e_ehsize); |
printf(" %-20s 0x%jx\n", "e_phentsize", (uintmax_t)ehdr.e_phentsize); |
printf(" %-20s 0x%jx\n", "e_shentsize", (uintmax_t)ehdr.e_shentsize); |
printf("\n"); |
} |
|
|
161,22 → 156,22
} |
|
if (dbg) { |
fprintf(stderr, " %-20s 0x%x\n", "p_type", phdr.p_type); |
fprintf(stderr, " %-20s 0x%jx\n", "p_offset", phdr.p_offset); |
fprintf(stderr, " %-20s 0x%jx\n", "p_vaddr", phdr.p_vaddr); |
fprintf(stderr, " %-20s 0x%jx\n", "p_paddr", phdr.p_paddr); |
fprintf(stderr, " %-20s 0x%jx\n", "p_filesz", phdr.p_filesz); |
fprintf(stderr, " %-20s 0x%jx\n", "p_memsz", phdr.p_memsz); |
fprintf(stderr, " %-20s 0x%x [", "p_flags", phdr.p_flags); |
printf(" %-20s 0x%x\n", "p_type", phdr.p_type); |
printf(" %-20s 0x%jx\n", "p_offset", phdr.p_offset); |
printf(" %-20s 0x%jx\n", "p_vaddr", phdr.p_vaddr); |
printf(" %-20s 0x%jx\n", "p_paddr", phdr.p_paddr); |
printf(" %-20s 0x%jx\n", "p_filesz", phdr.p_filesz); |
printf(" %-20s 0x%jx\n", "p_memsz", phdr.p_memsz); |
printf(" %-20s 0x%x [", "p_flags", phdr.p_flags); |
|
if (phdr.p_flags & PF_X) fprintf(stderr, " Execute"); |
if (phdr.p_flags & PF_R) fprintf(stderr, " Read"); |
if (phdr.p_flags & PF_W) fprintf(stderr, " Write"); |
fprintf(stderr, "]\n"); |
fprintf(stderr, " %-20s 0x%jx\n", "p_align", phdr.p_align); |
if (phdr.p_flags & PF_X) printf(" Execute"); |
if (phdr.p_flags & PF_R) printf(" Read"); |
if (phdr.p_flags & PF_W) printf(" Write"); |
printf("]\n"); |
printf(" %-20s 0x%jx\n", "p_align", phdr.p_align); |
} |
|
total_octets += phdr.p_filesz; |
total_octets += phdr.p_memsz; |
} |
|
char *d = (char *)malloc(total_octets + sizeof(ELFSECTION)+sizeof(ELFSECTION *)); |
187,7 → 182,6
current_section = 0; |
|
for(i=0; i<(int)n; i++) { |
if (dbg) fprintf(stderr, "Working with &d[%d]\n", current_offset); |
r[i] = (ELFSECTION *)(&d[current_offset]); |
|
if (gelf_getphdr(e, i, &phdr) != &phdr) { |
196,19 → 190,19
} |
|
if (dbg) { |
fprintf(stderr, " %-20s 0x%jx\n", "p_offset", phdr.p_offset); |
fprintf(stderr, " %-20s 0x%jx\n", "p_vaddr", phdr.p_vaddr); |
fprintf(stderr, " %-20s 0x%jx\n", "p_paddr", phdr.p_paddr); |
fprintf(stderr, " %-20s 0x%jx\n", "p_filesz", phdr.p_filesz); |
fprintf(stderr, " %-20s 0x%jx\n", "p_memsz", phdr.p_memsz); |
fprintf(stderr, " %-20s 0x%x [", "p_flags", phdr.p_flags); |
printf(" %-20s 0x%jx\n", "p_offset", phdr.p_offset); |
printf(" %-20s 0x%jx\n", "p_vaddr", phdr.p_vaddr); |
printf(" %-20s 0x%jx\n", "p_paddr", phdr.p_paddr); |
printf(" %-20s 0x%jx\n", "p_filesz", phdr.p_filesz); |
printf(" %-20s 0x%jx\n", "p_memsz", phdr.p_memsz); |
printf(" %-20s 0x%x [", "p_flags", phdr.p_flags); |
|
if (phdr.p_flags & PF_X) fprintf(stderr, " Execute"); |
if (phdr.p_flags & PF_R) fprintf(stderr, " Read"); |
if (phdr.p_flags & PF_W) fprintf(stderr, " Write"); |
fprintf(stderr, "]\n"); |
if (phdr.p_flags & PF_X) printf(" Execute"); |
if (phdr.p_flags & PF_R) printf(" Read"); |
if (phdr.p_flags & PF_W) printf(" Write"); |
printf("]\n"); |
|
fprintf(stderr, " %-20s 0x%jx\n", "p_align", phdr.p_align); |
printf(" %-20s 0x%jx\n", "p_align", phdr.p_align); |
} |
|
current_section++; |
216,7 → 210,7
r[i]->m_start = phdr.p_paddr; |
r[i]->m_len = phdr.p_filesz; |
|
current_offset += phdr.p_filesz + sizeof(ELFSECTION); |
current_offset += phdr.p_memsz + sizeof(ELFSECTION); |
|
// Now, let's read in our section ... |
if (lseek(fd, phdr.p_offset, SEEK_SET) < 0) { |
/zipcpu/trunk/sim/verilator/div_tb.cpp
45,8 → 45,6
#include "testb.h" |
// #include "twoc.h" |
|
#define DIVASSERT(A) do { if (!(A)) { closetrace(); } assert(A); } while(0) |
|
class DIV_TB : public TESTB<Vdiv> { |
public: |
DIV_TB(void) { |
59,6 → 57,11
TESTB<Vdiv>::reset(); |
} |
|
bool on_tick(void) { |
tick(); |
return true; |
} |
|
void bprint(char *str, int nbits, unsigned long v) { |
while(*str) |
str++; |
115,7 → 118,7
|
// The test bench is supposed to assert that we are idle when |
// we come in here. |
DIVASSERT(m_core->o_busy == 0); |
assert(m_core->o_busy == 0); |
|
// Request a divide |
m_core->i_rst = 0; |
138,10 → 141,10
// listed as a valid result. |
if (!m_core->o_busy) { |
closetrace(); |
DIVASSERT(m_core->o_busy); |
assert(m_core->o_busy); |
} if (m_core->o_valid != 0) { |
closetrace(); |
DIVASSERT(m_core->o_valid == 0); |
assert(m_core->o_valid == 0); |
} |
|
// while((!m_core->o_valid)&&(!m_core->o_err)) |
153,7 → 156,7
// is a test failure. |
dbgdump(); |
closetrace(); |
DIVASSERT(m_core->o_busy); |
assert(m_core->o_busy); |
} |
|
// Let the algorithm work for another clock tick. |
164,7 → 167,7
// result has been produced. |
if (m_core->o_busy) { |
closetrace(); |
DIVASSERT(!m_core->o_busy); |
assert(!m_core->o_busy); |
} |
|
if (dbg) { |
188,7 → 191,7
// assert, lest the file not get the final |
// values into it. |
closetrace(); |
DIVASSERT(m_core->o_err); |
assert(m_core->o_err); |
} |
} else if (m_core->o_err) { |
// Otherwise, there should not have been any divide |
196,7 → 199,7
// divide by zero. So, this is an error. Let's |
// stop and report it. |
closetrace(); |
DIVASSERT(!m_core->o_err); |
assert(!m_core->o_err); |
} else if (ans != (uint32_t)m_core->o_quotient) { |
// The other problem we might encounter would be if the |
// result doesn't match the one we are expecting. |
204,14 → 207,8
// Stop on this bug as well. |
// |
closetrace(); |
DIVASSERT(ans == (uint32_t)m_core->o_quotient); |
assert(ans == (uint32_t)m_core->o_quotient); |
} |
|
if(((m_core->o_quotient == 0)&&((m_core->o_flags&1)==0)) |
||((m_core->o_quotient!= 0)&&((m_core->o_flags&1)!=0))){ |
fprintf(stderr, "Z-FLAG DOES NOT MATCH: FLAGS = %d, QUOTIENT = %08x\n", m_core->o_flags, m_core->o_quotient); |
DIVASSERT((m_core->o_quotient!= 0)^(m_core->o_flags&1)); |
} |
} |
|
// Test a signed divide |
257,6 → 254,8
Verilated::commandArgs(argc, argv); |
DIV_TB *tb = new DIV_TB(); |
|
// tb->opentrace("divtrace.vcd"); |
|
tb->reset(); |
// tb->opentrace("div_tb.vcd"); |
|