[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [openrisc] OR1200 implementation of l.sb and l.sh



On Thursday 23 January 2003 14:52, Marko Mlinar wrote:
> On Thursday 23 January 2003 13:26, Marķa Bolado wrote:
> > On Thursday 23 January 2003 12:30, Marko Mlinar wrote:
> > > On Thursday 23 January 2003 11:50, Marķa Bolado wrote:
> > > > Hi!
> > > >
> > > > I've been looking at the OR1200 rtl, and I've seen that when a l.sb
> > > > insn, i.e,
> > > >
> > > >  l.sb 0(r4), r5 // EA <- 0 + r4
> > > > 		    // (EA) <- r5[7:0]
> > > >
> > > > or1200 writes a whole (re-ordinated) 32-bit word in cache. Thus, when
> > > > you only want to write the byte 3 of a particular word, you are also
> > > > writing bytes 0, 1 and 2, so the rest of the bytes of the word are
> > > > modified in cache, though they mustn't.
> > > >
> > > > Could you please clear up this point?
> > >
> > > What you stated is correct, except proper select bits are set on
> > > Wishbone bus,
> >
> >  Yes, I agree, but that bits are used by main memory, and I am talking
> > about cache memory.
> >
> > > so when writing one byte, you just write one byte, although you put
> > > whole word on wishbone data bus.
> >
> > In or1200 data cache doesn't use that selection bits, so I wonder how it
> > can know if it has to write a byte, a half word or a whole word.
>
> Why does it need to know in the first place?
When you perform a l.sb instruction, you only want to change one byte of a 
particular word. Currently, or1200 modifies the *whole* word in cache. This 
isn't the correct operation of the l.sb (or l.sh) instruction. Morover, this 
leads to unconsistency between cache memory and main memory, since in main 
memory or1200 only modifies the byte (as you said before, wishbone bus 
includes the selection bits to achieve this functionallity). 
For instance, if you have the four-letter string 'memo' and you want to write 
in the first letter an 'n', to form the word 'nemo', you will try to perform 
a l.sb instruction to write in the first byte of the string. With the current 
implementation, the result in cache will be 'nnxn' ( 'x' represents rubbish 
contained in the register rB). However, the word in main memory would be 
correctly changed, resulting the string 'nemo'.

Best wishes,
Marķa Bolado
--
To unsubscribe from openrisc mailing list please visit http://www.opencores.org/mailinglists.shtml