📄 readme.txt
字号:
Scratch Ring Example code Readme file
Copyright 2001 Intel
Introduction
============
This is a MEv2 microcode example that illustrates how to use hardware rings in scratch
memory by showing a single producer - single consumer ring. Rings are nothing but
circular buffer/ FIFO. The scratch pad memory supports upto 16 rings. Each ring
has associated with it a head, tail and count, all maintained by the scratch
hardware automatically.
The producer produces(puts) n words at a time on to the ring and the consumer
consumes(gets) n words at a time. The producer and the consumer mutually agree
on what "n" is, though it need not be the case.
The important thing to note here is that before producing, producer should always
check if the ring is full and the consumer, before consuming, should always check
if the ring is empty.
Ring full can be checked using the input state SCR_Ring#_Full (where # is the ring number
0-F). Note that the Ring full indication is asserted when the ring is near full (actually
at 50% capacity). As a result, it may not be possible to utilize the entire ring capacity
efficiently. This should be kept in mind when deciding the ring size.
The hardware does not prevent overfilling the ring. It is the responsility of the
programmer.
There is not input state for Ring Empty. Instead, the ring will return a zero if you
try to get (consume) from an empty ring. This has the implication that we cannot
put zero onto the ring because when we get from the ring, we won't be able to say if
the ring is empty or the data returned is zero :-(
All scratch operations have a latency of about 50 cycles.
What the example does
=====================
ME 0 is the producer and produces(puts) one word (4 bytes) at a time on to the ring.
ME 1 is the consumer which gets one word at a time. For simplicity and illustration
purposes, Only one thread produces and only one thread consumes.
The size of the ring is 128 and and is at offset 0x1000 in scratch memory.
This offset should be aligned on a 4 byte boundary. And we use ring number 0.
In order to hit the ring full and empty conditions, the producer keeps producing until
the ring is full and then signals the consumer. The consumer keeps consuming until
the ring is empty and then signals the producer to continue producing.
This example uses inter-thread signal mechanisms. Pls see the "signal" exmaples on how
they work.
Files
=====
single_producer.uc : contains producer code for ME 0
consumer.uc : contains consumer code for ME 1
scratchring.h : contains #defines for the ring.
sig_macros.uc : contains a set of reusable signal macros that are used
by ME0 & ME1 code.
How to run the code and verify the result
============================================
Set break points in each thread and see the sequence in which the threads are
woken up.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -