public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Design a microcontroller for gcc
@ 2006-02-14 23:22 Sylvain Munaut
  2006-02-14 23:40 ` DJ Delorie
  2006-02-15 22:10 ` Hans-Peter Nilsson
  0 siblings, 2 replies; 26+ messages in thread
From: Sylvain Munaut @ 2006-02-14 23:22 UTC (permalink / raw)
  To: gcc

Hello,


I'm currently considering writing my own microcontroller to use on
a FPGA. Since I'd like to be able to use C to write
"non-timing-critical" parts of my code, I thought I'd include a gcc port
as part of the design considerations.


I've read the online manual about gcc backend and googled to find
comments about gcc for microcontroller and I found that thread
particulary interesting :

http://gcc.gnu.org/ml/gcc/2003-03/msg01402.html


Here is a small description of the type of microcontroller I'm thinking of :
	* 8 bit RISC microcontroller
	* 16 general purpose registers
	* 16 level deep hardware call stack
	* no special instruction or regs for the stack
	* load/store to a flat "memory" (minimum 1k, up to 16k)
	  (addressing in that memory uses a register for the 8 lsb and
           a special register for the msbs)
	  that memory can be loaded along with the code to have known
	  content at startup for eg.
	* classic add/sub/... have 3 registers operand (dest,src1,src2)
	* no hardware mul, nor shift-by-n (have to be done in software)
	* pipelined with some restriction on instruction scheduling
	  (cfr later)
	* a special "I/O" space (gcc shouldn't care, we should only
	  access it in asm)
	* relative short/long call/branch, absolute short/long
	  call/branch. (The long branch/jump are achieved by preloading
	  a special GPR with the MSBs to use for the next jump)
	* 2 flags Carry & Zero for testing.
	
	

(note these are not random choices, I know how I can implement that in a
FPGA quite efficiently ...)

My first question would be : "Do you see anything that's missing that
would be a great plus ?"

I mentionned earlier that there is some scheduling restriction on the
instructions due to internal pipelining. For example, the result of a
fetch from memory may not be used in the instruction directly following
the fetch. When there is a conditionnal branch, the instruction just
following the branch will always be executed, no matter what the result
is (branch/call/... are not immediate but have a 1 instruction latency
beforce the occur). Is theses kind of limitation 'easily' supported by
gcc ?

I saw several time that gcc works better with a lot of GPRs. I could
increase them to 32 but then arithmetic instructions would have to use
the same register for destination than for src1.

eg. for the add instruction,  I'm planning :

add rD, rA, rB		; rD = rA + rB
add rD, rD, imm8	; rD = rD + immediate_8bits

but if I allow 32 registers, my opcode is too short so I have to limit :

add rD, rD, rA		; rD = rD + rA
add rD, rD, imm8	; rD = rD + immediate_8bits

I'm more in favor of only 16 registers because :
 - Some uc have even less and have working gcc
 - 16 is already a good number
 - 16 uses less space in the FPGA ;p
 - I'd rather have the possibility to store result elsewhere than have
32 registers.

But maybe I'm wrong ...



Any comments, thoughts, ... are welcomed !



	Sylvain

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2006-02-20  8:54 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-14 23:22 Design a microcontroller for gcc Sylvain Munaut
2006-02-14 23:40 ` DJ Delorie
2006-02-15  0:28   ` Sylvain Munaut
2006-02-15  0:41     ` DJ Delorie
2006-02-15 19:59       ` Sylvain Munaut
2006-02-15 20:06         ` DJ Delorie
2006-02-15 20:23           ` Paul Brook
2006-02-15 21:21             ` DJ Delorie
2006-02-15 22:10 ` Hans-Peter Nilsson
2006-02-15 23:10   ` David Daney
2006-02-16  0:26   ` Sylvain Munaut
2006-02-16  0:46     ` DJ Delorie
2006-02-16  2:49     ` Hans-Peter Nilsson
2006-02-16  3:21       ` DJ Delorie
2006-02-16  3:34         ` Hans-Peter Nilsson
2006-02-16  3:37           ` Hans-Peter Nilsson
2006-02-16  3:44             ` DJ Delorie
2006-02-16  3:40           ` DJ Delorie
2006-02-16  3:56             ` Hans-Peter Nilsson
2006-02-16  4:10               ` Hans-Peter Nilsson
2006-02-16  4:17                 ` DJ Delorie
2006-02-16  4:13               ` DJ Delorie
2006-02-16 11:42         ` Hans-Peter Nilsson
2006-02-16 20:49           ` Sylvain Munaut
2006-02-17  0:28             ` Hans-Peter Nilsson
2006-02-20  8:54               ` Sylvain Munaut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).