• Non ci sono risultati.

SISTEMI EMBEDDED AA 2013/2014

N/A
N/A
Protected

Academic year: 2021

Condividi "SISTEMI EMBEDDED AA 2013/2014"

Copied!
20
0
0

Testo completo

(1)

SISTEMI  EMBEDDED   AA  2013/2014  

Nios  II  processor:  

Memory  organiza?on  and  access  

Federico  Baron?  

(2)

Memory  and  I/O  access  (1)  

•  Instruc(on  master  port:  An  Avalon  Memory-­‐Mapped   (Avalon-­‐MM)  master  port  that  connects  to  instruc?on   memory  via  system  interconnect  fabric  

–  Instruc(on  cache:  Fast  cache  memory  internal  to  the  Nios   II  core  

•  Data  master  port:  An  Avalon-­‐MM  master  port  that   connects  to  data  memory  and  peripherals  via  system   interconnect    fabric  

–  Data  cache:  Fast  cache  memory  internal  to  the  Nios  II  core  

•  Tightly-­‐coupled  instruc(on  or  data  memory  port:  

Interface  to  fast  on-­‐chip  memory  outside  the  Nios  II   core  

(3)

Memory  and  I/O  access  (2)  

Instruc(on   master  port  

Data   master  port   Instruc(on  

bus  

Data   bus  

(Fast  version)  

(4)

Memory  and  I/O  access  (3)  

•  Separate  instruc?on  and  data  busses,  as  in   Harvard  architecture  

•  Both  data  memory  and  peripherals  are  mapped   into  the  address  space  of  the  data  master  port  

–  The  Nios  II  uses  liOle-­‐endian  byte  ordering  

•  Quan?ty,  type,  and  connec?on  of  memory  and   peripherals  are  system-­‐dependent  

–  Typically,  Nios  II  processor  systems  contain  a  mix  of   fast  on-­‐chip  memory  and  slower  off-­‐chip  memory   –  Peripherals  typically  reside  on-­‐chip,  although  

interfaces  to  off-­‐chip  peripherals  also  exist  

(5)

Instruc?on  master  port  

•  32-­‐bit  pipelined  Avalon-­‐MM  master  port  

•  Used  to  fetch  instruc?ons  to  be  exectued  by  the   processor  

•  The  pipeline  support  increases  the  throughput  of   synchrounous  memory  w/  pipeline  latency    

•  The  Nios  II  can  prefetch  sequen?al  instruc?ons   and  perform  branch  predic?on  to  keep  the  

instruc?on  pipe  as  ac?ve  as  possible    

•  Always  retrieves  32-­‐bit  data  thanks  to  dynamic   bus  sizing  logic  embedded  in  the  system  

interconnect  fabric    

(6)

Data  master  port  

•  The  Nios  II  data  bus  is  implemented  as  a  32-­‐bit   Avalon-­‐MM  master  port.  The  data  master  port   performs  two  func?ons:  

–  Read  data  from  memory  or  a  peripheral  when  the   processor  executes  a  load  instruc?on  

–  Write  data  to  memory  or  a  peripheral  when  the  

processor  executes  a  store  instruc?on  

(7)

Cache  (1)  

•  The  Nios  II  architecture  supports  cache  memories  on   both  the  instruc?on  master  port  (instruc?on  cache)   and  the  data  master  port  (data  cache)  

•  Cache  memory  resides  on-­‐chip  as  an  integral  part  of   the  Nios  II  processor  core  

•  The  cache  memories  can  improve  the  average  memory   access  ?me  for  Nios  II  processor  systems  that  use  slow   off-­‐chip  memory  such  as  SDRAM  for  program  and  data   storage  

•  The  instruc?on  and  data  caches  are  enabled  

perpetually  at  run-­‐?me,  but  methods  are  provided  for   so\ware  to  bypass  the  data  cache  so  that  peripheral   accesses  do  not  return  cached  data  

(8)

Cache  (2)  

•  The  cache  memories  are  op?onal.  The  need  for   higher  memory  performance  (and  by  associa?on,   the  need  for  cache  memory)  is  applica?on  

dependent  

•  Cache  use  improves  performance  if:  

–  Regular  memory  is  located  off-­‐chip,  and  access  ?me  is   long  compared  to  on-­‐chip  memory  

–  The  largest,  performance-­‐cri?cal  instruc?on  loop  is   smaller  than  the  instruc?on  cache  

–  The  largest  block  of  performance-­‐cri?cal  data  is   smaller  than  the  data  cache  

(9)

Cache  bypass  methods  

•  The  Nios  II  architecture  provides  the  following   methods  for  bypassing  the  data  cache:  

•  I/O  load  and  store  instruc(ons  

–  The  load  and  store  I/O  instruc?ons  such  as  ldio  and   s?o  bypass  the  data  cache  and  force  an  Avalon-­‐MM   data  transfer  to  a  specified  address  

•  Bit-­‐31  cache  bypass  

–  The  bit-­‐31  cache  bypass  method  on  the  data  master   port  uses  bit  31  of  the  address  as  a  tag  that  indicates   whether  the  processor  should  transfer  data  to/from   cache,  or  bypass  it  

(10)

Load  instruc?ons  

(11)

Store  instruc?ons  

(12)

Use  load  and  store  IO  in  C  

•  Use  IORD_32DIRECT(),   IOWR_32DIRECT(),…  

macros  defined  in  io.h  

•  Use  compiler  flags:  

–  -­‐mbypass-­‐cache,  -­‐mno-­‐bypass-­‐cache  

Force  all  load  and  store  instruc?ons  to  always  bypass   cache  by  using  I/O  variants  of  the  instruc?ons.  The   default  is  not  to  bypass  the  cache.  

–  -­‐mno-­‐cache-­‐vola?le,  -­‐mcache-­‐vola?le  

Vola?le  memory  access  bypass  the  cache  using  the  I/

O  variants  of  the  load  and  store  instruc?ons.  The   default  is  not  to  bypass  the  cache.  

(13)

Characteris?cs  of  the  Nios  II  cores    

(14)

Nios  II/f:  instr  and  data  cache  (1)  

•  Instruc(on  Cache  

–  Direct-­‐mapped  cache  implementa?on   –  32  bytes  (8  words)  per  cache  line  

–  The  instruc?on  master  port  reads  an  en?re  cache  

line  at  a  ?me  from  memory,  and  issues  one  read  per  

clock  cycle  

(15)

Nios  II/f:  instr  and  data  cache  (2)  

•  Data  Cache  

–  Direct-­‐mapped  cache  implementa?on  

–  Configurable  line  size  of  4,  16,  or  32  bytes  

–  The  data  master  port  reads  an  en?re  cache  line  at   a  ?me  from  memory,  and  issues  one  read  per  

clock  cycle   –  Write-­‐back  

–  Write-­‐allocate  (i.e.,  on  a  store  instruc?on,  a  cache  

miss  allocates  the  line  for  that  address)  

(16)

Cache  implementa?on  

TAG LINE INDEX OFFSET 0  

31   12   5  

COMP  

4   11  

hit/miss  

0  

127  

Cache  size  =  4  KB   Line  size  =  32  B  

V TAG LINE

V TAG LINE

V TAG LINE

(17)

Tightly-­‐coupled  memories  (1)  

•  Tightly-­‐coupled  memory  provides  guaranteed   low-­‐latency  memory  access  for  performance-­‐

cri?cal  applica?ons.  Compared  to  cache  memory,  

?ghtly-­‐coupled  memory  provides  the  following   benefits:  

–  Performance  similar  to  cache  memory  

–  Programmer  can  guarantee  that  performance-­‐cri?cal   code  or  data  is  located  in  ?ghtly-­‐coupled  memory  

–  No  real-­‐?me  caching  overhead,  such  as  loading,   invalida?ng,  or  flushing  memory  

(18)

Tightly-­‐coupled  memories  (2)  

•  Physically,  a  ?ghtly-­‐coupled  memory  port  is  a  separate   master  port  on  the  Nios  II  processor  core,  similar  to  

the  instruc?on  or  data  master  port  

•  A  Nios  II  core  can  have  zero,  one,  or   mul?ple  ?ghtly-­‐coupled  memories  

•  The  Nios  II  architecture  supports  ?ghtly-­‐coupled   memory  for  both  instruc?on  and  data  access  

•  Each  ?ghtly-­‐coupled  memory  port  connects  directly  to   exactly  one  memory  with  guaranteed  low,  fixed  

latency  

•  The  memory  is  external  to  the  Nios  II  core  and  is   located  on  chip  

(19)

Tightly-­‐coupled  memories  (3)  

•  Tightly-­‐coupled  memories  occupy  normal  address   space,  the  same  as  other  memory  devices  

connected  via  system  interconnect  fabric  

–  The  address  ranges  for  ?ghtly-­‐coupled  memories   (if  any)  are  determined  at  system  genera?on  ?me  

•  So\ware  accesses  ?ghtly-­‐coupled  memory  using   regular  load  and  store  instruc?ons  

•  From  the  so\ware’s  perspec?ve,  there  is  no  

difference  accessing  ?ghtly-­‐coupled  memories  

compared  to  other  memories  

(20)

References  

•  Altera,  “Nios  II  Processor  Reference   Handbook,”  n2cpu_niiv1.pdf  

–  2.  Processor  architecture/Memory  and  I/O  

organiza?on  

Riferimenti

Documenti correlati

– The interval timer core generates an IRQ whenever the internal counter reaches zero and the ITO bit of the control register is set to 1. – Acknowledging the IRQ in one of

– Maskable interrupts: the processor takes a maskable interrupt if maskable interrupts are enabled, and if the requested interrupt level is higher than that of the. interrupt

• Application use a standard API independent of the device driver implementation (e.g. for character-mode devices and file subsystems). • Device driver provides a set of

f For more information regarding the Nios II instruction set architecture, refer to the Instruction Set Reference chapter of the Nios II Processor Reference Handbook.. For common

We’ll use as a reference a System on Programmable Chip (SoPC) platform based on an Altera FPGAF. Baronti - Sistemi Embedded - University of

– Ashenden, “Digital Design: An Embedded Systems Approach Using Verilog,” Elsevier 2008.. • A physical system that employs computer control for a specific purpose, rather than

– Store: Write a data operand from a processor register to memory or an output device. – Operate: Perform an arithmetic or logic operation on data operands in

In a single write operation, data is only written to the column address and the bank select address specified by the write command set cycle without regard to the burst