View unanswered posts | View active topics It is currently Thu Mar 28, 2024 1:51 pm



Reply to topic  [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
 nPower 
Author Message

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
Quote:
I just wonder: is your subset the minimal operative set that you have distilled? Or are you going to extend it as soon as your code got a stable milestone?

I plan on focusing on instructions the compiler might use. Eventually I'd like to add all the instructions. But that will take a while and maybe too much for the FPGA. As it is now a large FPGA is required (40,000 LUTs or so). Also segmentation and virtual memory is not being supported so finding and running an OS might be challenging.
Code stability and bugs are an issue with hobby type projects. Verifying that all the instructions work as expected is an issue. I spent some time looking around on the web for a processor test program.

I believe the following instructions are now supported. (System calls and interrupts are not supported yet). Half-word algebraic loads are missing. Multiply high instructions are missing. I believe divides are now supported but I don't have them listed.
Code:
ADD   ADDI  ADDIS   ADDME   ADDZE   ADDC
AND   ANDI  ANDIS   ANDC
B     BC    BCCTR   BCLR
CMP   CMPI  CMPL    CMPLI
CNTLZW
CRAND CROR  CRXOR                     
CRNAND CRNOR CREQV                     
CRANDC  CRORC                         
EQV   EXTB  EXTH
OR    ORC   ORI   ORIS   
MULLI MULLW
NAND  NEG   NOR           
SUBF  SUBFIC  SUBFME  SUBFZE  SUBFC
RLWIMI RLWINM RLWNM
SLW   SRW 
SRAW  SRAWI
XOR   XORI  XORIS   

LBZ   LBZU  LBZX  LBZUX   MFCR    MTCRF
LHZ   LHZU  LHZX  LHZUX   MFSPR   MTSPR
LWZ   LWZU  LWZX  LWZUX   MFLR    MTLR
STB   STBU  STBX  STBUX   MFCTR   MTCTR
STH   STHU  STHX  STHUX   MFXER   MTXER
STW   STWU  STWX  STWUX   MCRXR       

RFI

_________________
Robert Finch http://www.finitron.ca


Mon Dec 21, 2020 5:59 am
Profile WWW

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
<hardware> A branch flag was updated for the wrong pipeline. This line led to a branch to the reset address.

I am having trouble getting the compiler to co-operate :x The latest issue is that it is not recognizing a constant value and so cannot compile a file correctly. It gets the following error for xloctab.c part of Plauger's standard C library:
Code:
\ D:\cores2020\nPower\v1\software\c_standard_lib-master\c_standard_lib-master\LOCALE>vc -ID:\cores2020\nPower\v1\software\inc\ -v xloctab.c
vc frontend for vbcc (c) in 1995-2016 by Volker Barthelmann
vbccppc -ID:\cores2020\nPower\v1\software\inc\ "xloctab.c"
vbcc V0.9f (c) in 1995-2017 by Volker Barthelmann
vbcc code-generator for PPC V0.6c (c) in 1997-2008 by Volker Barthelmann
>       {"LOCALE", OFF(_Name),
error 46 in line 9 of "xloctab.c": initializer not a constant
>       {"collate", OFF(_Costate._Tab),
error 46 in line 13 of "xloctab.c": initializer not a constant
>       {"ctype", OFF(_Ctype),
error 46 in line 15 of "xloctab.c": initializer not a constant
>       {"tolower", OFF(_Tolower),
error 46 in line 16 of "xloctab.c": initializer not a constant
>       {"toupper", OFF(_Toupper),
error 46 in line 17 of "xloctab.c": initializer not a constant
>       {"mb_cur_max", OFF(_Mbcurmax),
error 46 in line 18 of "xloctab.c": initializer not a constant
>       {"mbtowc", OFF(_Mbstate._Tab),
error 46 in line 19 of "xloctab.c": initializer not a constant
>       {"wctomb", OFF(_Wcstate._Tab),
error 46 in line 20 of "xloctab.c": initializer not a constant
>       {"currency_symbol", OFF(_Lc.currency_symbol),
error 46 in line 22 of "xloctab.c": initializer not a constant
>       {"int_curr_symbol", OFF(_Lc.int_curr_symbol),
error 46 in line 23 of "xloctab.c": initializer not a constant
Maximum number of errors reached!
unexpected end of file
10 errors found!

The source code is (only partly shown):
Code:
/* _Loctab data object */
#include <stddef.h>
#include "xlocale.h"

      /* macros */
#define OFF(member)      offsetof(_Linfo, member)
      /* static data */
_Locitem _Loctab[] = {   /* locale file info */
   {"LOCALE", OFF(_Name), L_NAME},
   {"NOTE", 0, L_NOTE},
   {"SET", 0, L_SET},

Notice it uses the offsetof() function which returns a constant value. The macro should be expanding out to an offsetof() which the compiler should recognize as a constant.

I believe my own compiler compiles this :) I shall look furthur into the issue but if it is in the front-end I cannot modify it. It will have to wait for a fix.

_________________
Robert Finch http://www.finitron.ca


Tue Dec 22, 2020 7:29 am
Profile WWW

Joined: Wed Nov 20, 2019 12:56 pm
Posts: 92
Does it compile OK if you use __offsetof() instead?


Tue Dec 22, 2020 8:45 am
Profile

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
offsetof() is just a macro, not a function :oops:

I tried __offsetof() and get this response:
Code:
 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\nmake.exe" /C LOCALE
        vbccppc -c99 -ID:\cores2020\nPower\v1\software\inc xloctab.c
vbcc V0.9f (c) in 1995-2017 by Volker Barthelmann
vbcc code-generator for PPC V0.6c (c) in 1997-2008 by Volker Barthelmann
>       {"collate", OFF(_Costate._Tab)
warning 59 in line 13 of "xloctab.c": ) expected
>       {"collate", OFF(_Costate._Tab)
warning 128 in line 13 of "xloctab.c": } expected
>       {"collate", OFF(_Costate._Tab)
warning 128 in line 13 of "xloctab.c": } expected
>       {"collate", OFF(_Costate._Tab)
warning 54 in line 13 of "xloctab.c": ; expected
>       {"collate", OFF(_Costate._Tab)
error 0 in line 13 of "xloctab.c": declaration expected
aborting...
1 error found!
NMAKE :  U1077: 'D:\cores2020\nPower\v1\software\CC64\vbcc\bin\vbccppc.EXE' : return code '0x1'
Stop.
NMAKE :  U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x86\nmake.exe"' : return code '0x2'

_________________
Robert Finch http://www.finitron.ca


Tue Dec 22, 2020 9:12 am
Profile WWW

Joined: Wed Nov 20, 2019 12:56 pm
Posts: 92
robfinch wrote:
offsetof() is just a macro, not a function :oops:

I tried __offsetof() and get this response:


Hmmm - I presume it's choking on the request for the offset of a nested struct's member? I'll have a closer look tonight.
Might be possible to work around it by adding __offsetof(_Linfo,_Mbstate) and _offsetof(<whatever _Mbstate's type is>,Tab)
...etc.

Otherwise, maybe get in touch with Volker - I've found him to be pretty approchable, responsive and friendly.


Tue Dec 22, 2020 1:27 pm
Profile

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
Bypassing the one issue by leaving the file out of the build, now the following error is happening:
Code:
vasm 1.8i (c) in 2002-2020 Volker Barthelmann
vasm PowerPC cpu backend 3.1 (c) 2002-2019 Frank Wille
vasm std syntax module 5.3 (c) 2002-2020 Volker Barthelmann
vasm ELF output module 2.7 (c) 2002-2016,2020 Frank Wille

.text(acrwx16):          688 bytes
        vlink -T rom_bios.lnk rom_bios.out

INTERNAL ERROR: next_pattern(): PHDR  load missing.
Aborting.
NMAKE : fatal error U1077: 'D:\cores2020\nPower\v1\software\cc64\vbcc\bin\vlink.EXE' : return code '0x1'
Stop.

Does this mean that something is missing from the .lnk file? And how do I add it? I would have thought the compiler/assembler would insert PHDR records.

_________________
Robert Finch http://www.finitron.ca


Wed Dec 23, 2020 4:41 am
Profile WWW

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
In vasm, the origin point of a section needs to be set to the end of the previous section rounded to a 4k block. How can that be specified?
I tried defining a label at the end of the previous section then origining + 0x1000 but that results in an error message that the origin must be a constant.

I wrote a little utility "secsrt" which sorts and groups the sections in an assembler file, so all the .text is together, followed by .rodata, followed by .data.
Now the origin point of the various sections needs to be set so they do not overlap.

_________________
Robert Finch http://www.finitron.ca


Thu Dec 24, 2020 2:17 pm
Profile WWW

Joined: Wed Nov 20, 2019 12:56 pm
Posts: 92
robfinch wrote:
In vasm, the origin point of a section needs to be set to the end of the previous section rounded to a 4k block. How can that be specified?
I tried defining a label at the end of the previous section then origining + 0x1000 but that results in an error message that the origin must be a constant.

I wrote a little utility "secsrt" which sorts and groups the sections in an assembler file, so all the .text is together, followed by .rodata, followed by .data.
Now the origin point of the various sections needs to be set so they do not overlap.


I must admit I've not used vasm with PPC code, but would all of that not be the responsibility of the linker rather than the assembler?
Have a look at the linker scripts documentation in this file: http://sun.hasenbraten.de/vlink/release/vlink.pdf
I think the syntax is fairly similar to gcc's link scripts.


Thu Dec 24, 2020 2:31 pm
Profile

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
Yes, it should be possible to do that through the linker, but the linker gives me a PHDRS missing message that I have not figured out yet. I don’t know why a PHDR is needed.

I am trying to generate a binary that can be placed in ROM. Since the assembler can generate binaries all by itself, I thought I’d just put in a few .orgs.
At the moment the assembler is being used as a linker. All the asm files are concatenated together into one master file called build.asm. That is then run through the secsrt program to sort and group the sections. secsrt inserts origin statements at the start of each section.

The linker script for doing things in a proper manner (which doesn’t work) looks like:
Code:
 ENTRY (_start)

MEMORY {
   BIOS_ROM : ORIGIN = 0xFFFC0000, LENGTH = 256K
}

MEMORY {
   BIOS_DATA : ORIGIN = 0xFF400000, LENGTH = 64K
}

SECTIONS {
   .text: {
      . = ALIGN(4);
      *(.text);
      . = ALIGN(4);
      _etext = .;
   } >BIOS_ROM
   .rodata: {
      . = (_etext + 0x1000) & 0xFFFFF000;
      . = ALIGN(4);
      _start_rodata = .;
      *(.rodata);
      . = ALIGN(4);
      _end_rodata = .;
   } >BIOS_ROM
   .data: AT (0xFF400000) {
      . = (_end_rodata + 0x1000) & 0xFFFFF000;
      . = ALIGN(4);
      _start_data = .;
      *(.data);
      . = ALIGN(4);
      _end_data = .;
   } >BIOS_ROM
}

The plan is to have the startup code copy the .data section to ram at $FF400000.

_________________
Robert Finch http://www.finitron.ca


Thu Dec 24, 2020 2:55 pm
Profile WWW

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
I should mention that I want the linker to produce a binary regardless of the fact that there are unresolved externals.
The C standard library is being linked in and it has a number of external references to routines that should be supplied by the OS. Eventuallly, I would write the routines, but for now they can be left as undefined. There are only a few functions like rand() and memset() that would be in use shortly.

_________________
Robert Finch http://www.finitron.ca


Thu Dec 24, 2020 3:09 pm
Profile WWW

Joined: Wed Nov 20, 2019 12:56 pm
Posts: 92
By default the linker's going to try to create an ELF executable I think? What happens if you add "-b rawbin1" to the vlink command line?

Edit - ah, the unresolved externals may be the problem - you might have to create stubs for those before the linker will cooperate.


Thu Dec 24, 2020 3:14 pm
Profile

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
Quote:
Edit - ah, the unresolved externals may be the problem - you might have to create stubs for those before the linker will cooperate.
I figured it would be faster just to use the assembler to link things :)

I would create stubs but it is a lot of work to track down the functions and variables that are missing. (Finding the prototypes and variable types). To create decent stubs, one
needs to know how the code works so sensible return values can be setup. I was rather hoping there would just be a switch in the linker, but I do not see one. I am trying to get a small demo running to see if the core will work in an FPGA. I do not care if it crashes at this point. This is super-rapid app development. Abusing toolsets.

_________________
Robert Finch http://www.finitron.ca


Thu Dec 24, 2020 3:36 pm
Profile WWW

Joined: Wed Nov 20, 2019 12:56 pm
Posts: 92
robfinch wrote:
I would create stubs but it is a lot of work to track down the functions and variables that are missing. (Finding the prototypes and variable types). To create decent stubs, one needs to know how the code works so sensible return values can be setup.


Right - but I suppose for a quick-and-dirty solution you can just list them as xdeffed labels in an assembly file, just to get a binary? Might even be possible to define them as symbols in the linkscript itself, again just to get a binary built.

Quote:
I was rather hoping there would just be a switch in the linker, but I do not see one. I am trying to get a small demo running to see if the core will work in an FPGA. I do not care if it crashes at this point. This is super-rapid app development. Abusing toolsets.


Right, I see. In that case maybe it's too soon to be getting a full C library up and running? For 832 I collected together a tiny subset of C library code, just enough to run Hello World and Dhrystone, plus a few test programs: https://github.com/robinsonb5/EightThir ... ter/lib832


Thu Dec 24, 2020 3:55 pm
Profile

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
I may have to alter code to get past this one 'internal error', can't be good.
Code:
vbcc V0.9f (c) in 1995-2017 by Volker Barthelmann
vbcc code-generator for PPC V0.6c (c) in 1997-2008 by Volker Barthelmann
>EOF
error 158 in line 33 of "xfreeloc.c": internal error 0 in line 510 of file opt.c !!
aborting...
unexpected end of file
1 error found!

It looks like it optimizes away the whole function.

_________________
Robert Finch http://www.finitron.ca


Thu Dec 24, 2020 9:55 pm
Profile WWW

Joined: Sat Feb 02, 2013 9:40 am
Posts: 2095
Location: Canada
I am having lots of fun with the compiler / assembler. I got past the last issue by disabling optimization. I also stubbed out the one table. Having got it all to compile, a master .asm file was built. Origin statements were inserted at the start of .text, .data, and .rodata. Then the master file was assembled. Even though the origin statements placed the .text first, in the output file it was placed last.
The assembler file looks like:
Code:
.text
.org $00000
….
.rodata
.org $10000

.data
.org $20000

Apparently the assembler does not seem to be able to follow the .org directives. I am sure it is just an option I am missing.

_________________
Robert Finch http://www.finitron.ca


Mon Dec 28, 2020 6:07 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

Who is online

Users browsing this forum: SemrushBot and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software