B02 and B26 draft - take 2

From: Stefen Boyd (stefen@boyd.com)
Date: Tue May 26 1998 - 11:47:55 PDT


BAD MSG:
I've incorporated the various comments. I've tried to
aintain the concept of a memory for the sake of the
pli folks, but make it clearer that it's just a special
case of a one dim reg arrays.
Content-Length: 14923
X-Lines: 272
X-Status: $$$$
X-UID: 0000000484
Status: RO

I could really use some better wording for section
3.8 registers. If one of you would like to contribute
something from your verilog class material that is
more presentable, please do so.

Thanks,
  Stefen

<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Generator" CONTENT="Microsoft Word 97">
   <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (Win95; U) [Netscape]">
   <TITLE>- B02 - DRAFT -</TITLE>
</HEAD>
<BODY>
<U><FONT FACE="Arial">B02: Multi-Dimensional Arrays</FONT></U>
<BR><FONT FACE="Arial,Helvetica">
<FONT COLOR="#FF0000">changes are marked in red</FONT></FONT>
<BR><U><FONT FACE="Arial">B26: bit selects of elements in arrayed structures</FONT></U>
<BR><FONT FACE="Arial"> <FONT COLOR="#3366FF">changes
are marked in blue</FONT></FONT>
<BR><U><FONT FACE="Arial">Proposal</FONT></U>

<FONT FACE="Arial">Add Clif's changed bnf to syntax boxes 3-1 and 3-2.</FONT>

<FONT FACE="Arial">Change Section 3.8 (memories get moved into new section
3.10):</FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">3.8 Registers</FONT></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">A reg models hardware registers.
Assignments to a reg are made by procedural assignments (See sections 6.2
and 9.2). Since the reg holds a value between assignments, it can
be used to model hardware registers. Edge-sensitive (i.e. flip-flops)
and level sensitive (i.e. RS and transparent latches) storage elements
can be modeled. A reg need not represent a hardware storage element
since it can also be used to represent combinatorial logic.</FONT></FONT>
<BR>

<FONT FACE="Arial">Change section 3.9</FONT>
<BR><FONT FACE="Arial">Update bnf with Clif's modified version</FONT>
<BR><FONT FACE="Arial">Strike paragraph:</FONT>
<BR><STRIKE><FONT FACE="Arial"><FONT COLOR="#FF0000">Arrays of integer
and time registers shall be declared in the same manner as arrays of reg
type (section 3.8).</FONT></FONT></STRIKE>
<BR><FONT FACE="Arial">change examples:</FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">
integer a;
// integer value</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">
time last_chng;
// time value</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000"> <STRIKE>
integer a[1:64];
// an array of 64 integer values</STRIKE></FONT></FONT>
<BR><STRIKE><FONT FACE="Arial"><FONT COLOR="#FF0000">
time chng_hist[1:1000] // an array of 1000 time values</FONT></FONT></STRIKE>

<FONT FACE="Arial">Add new section 3.10 (push parameters down one section)</FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">3.10 Arrays</FONT></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">Arrays can be used to group
elements of net and reg types. They shall be declared in net and
register declaration statements by specifying the element address range(s)
after the declared identifier. Each dimension shall be represented by an
address range. See sections 3.2.1 and 3.2.2 for net and register
declarations. The expression(s) that specify the indices of the array shall
be constant expressions. The value of the constant expression can be a
positive integer, a negative integer, or zero.</FONT></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">One declaration statement can
be used for declaring both nets or registers and arrays. This makes it
convenient to declare both an array and some nets or registers that will
match the element vector width in the same declaration statement.</FONT></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">An n-bit register or net can
be assigned a value in a single assignment, but a complete or partial array
dimension cannot. Nor can a complete or partial array dimension be used
to provide a value to an expression. To assign a value to an element,
an index for every dimension shall be specified. The index can be an expression.
This option provides a mechanism to reference different array elements
depending on the value of other registers and nets in the circuit. For
example, a program counter register could be used to index into a RAM.</FONT></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">3.10.1 Net Arrays</FONT></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">Arrays of nets can be used
to connect ports of generated instances. Each element of the array
can be used in the same fashion as a scalar or vector net.</FONT></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">3.10.2 Register Arrays</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">Arrays for all register types
(reg, integer, time, real, realtime) shall be possible.</FONT></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000">Examples:</FONT></FONT>
<BR>

<FONT FACE="Arial">3.<FONT COLOR="#FF0000"><STRIKE>8</STRIKE>10.3</FONT>
Memories</FONT>

<FONT FACE="Arial">A<STRIKE><FONT COLOR="#FF0000">n</FONT></STRIKE>
<FONT COLOR="#FF0000">one dimensional</FONT> array of registers can be
used to model read-only memories (ROMs), random access memories (RAMs),
and register files. Each register in the array is known as an element or
word and is addressed by a single array index. <STRIKE><FONT COLOR="#FF0000">There
shall be no arrays with multiple dimensions.</FONT></STRIKE></FONT>

<FONT FACE="Arial"><FONT COLOR="#FF0000"><STRIKE>Memories shall be declared
in register</STRIKE>...</FONT></FONT>

<STRIKE><FONT FACE="Arial"><FONT COLOR="#FF0000">One declaration statement
can be used for declaring registers and memories. This makes it convenient
to declare both a memory and some registers that will hold data to be read
from and written to the memory in the same declaration statement.</FONT></FONT></STRIKE>

<FONT FACE="Arial"><FONT COLOR="#FF0000">3.10.4 Array</FONT> Examples</FONT>

<FONT FACE="Arial">1. <FONT COLOR="#FF0000"><STRIKE>Memory</STRIKE>Array</FONT>
declarations</FONT>
<OL><FONT FACE="Arial">reg [7:0] mema[0:255]; // declare
a memory mema of 256 eight-bit</FONT>
<BR><FONT FACE="Arial">
// eight-bit registers. The indeces are 0 to 255</FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">reg arrayb[7:0][0:255];
// declare a two dimentional array of one bit</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">
// registers</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">wire w_array[7:0][5:0];
// declare array of wires</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">integer inta[1:64];
// an array of 64 integer values</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">time chng_hist[1:1000]
// an array of 1000 time values</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">integer t_index;</FONT></FONT></OL>
<FONT FACE="Arial">2. A memory of n 1-bit registers is different from an
n-bit vector register (no changes)</FONT>

<FONT FACE="Arial">3. Assignment to <FONT COLOR="#FF0000"><STRIKE>memory
</STRIKE>array </FONT>elements</FONT>
<DIR>
<DIR><FONT FACE="Arial">rega = 0; // Legal Syntax</FONT>
<BR><FONT FACE="Arial">mema = 0; // Illegal Syntax</FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">arrayb[1] = 0; // Illegal
Syntax</FONT></FONT>
<BR><FONT FACE="Arial">mema[1] = 0; // Assigns 0 to the <STRIKE><FONT COLOR="#FF0000">first</FONT></STRIKE>
<FONT COLOR="#FF0000">second</FONT> element of mema</FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">arrayb[1][0] = 0; // Assigns
0 to the bit referenced by indices [1][0]</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">inta[4] = 33559; //
Assign decimal number to integer in array</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">chng_hist[t_index] = $time;
// Assign current simulation time to element addressed</FONT></FONT>
<BR><FONT FACE="Arial"><FONT COLOR="#FF0000">
// by integer index</FONT></FONT></DIR>
</DIR>
<FONT FACE="Arial,Helvetica">Section 4: Change next to last line of "An
operand can be one of the following:"</FONT>

<FONT FACE="Arial,Helvetica"> -- <STRIKE><FONT COLOR="#FF0000">memory</FONT></STRIKE>
<FONT COLOR="#FF0000">array </FONT>element</FONT>

<FONT FACE="Arial,Helvetica">Section 4.2.2:</FONT>

<FONT FACE="Arial,Helvetica">4.2.2 <FONT COLOR="#FF0000">Array
and </FONT>Memory addressing</FONT>
<BR><FONT FACE="Arial,Helvetica">Declarations of <FONT COLOR="#FF0000">arrays</FONT>
<FONT COLOR="#FF0000">and </FONT>memor<FONT COLOR="#FF0000"><STRIKE>y</STRIKE>ies
(one dimensional arrays of reg) <STRIKE>is</STRIKE> are</FONT> discussed
in section 3.<FONT COLOR="#FF0000"><STRIKE>8</STRIKE>10</FONT>. This
section discusses <FONT COLOR="#FF0000">array</FONT> <STRIKE><FONT COLOR="#FF0000">memory</FONT></STRIKE>
addressing.</FONT>

<FONT FACE="Arial,Helvetica">Example</FONT>
<BR><FONT FACE="Arial,Helvetica">The next example declares a memory of
1024 8-bit words:</FONT>

<FONT FACE="Arial,Helvetica">
reg [7:0] mem_name[0:1023];</FONT>

<FONT FACE="Arial,Helvetica">The syntax for a memory address shall consist
of the name of the memory and an expression for the address - specified
with the following format:</FONT>

<FONT FACE="Arial,Helvetica">
mem_name[addr_expr]</FONT>

<FONT FACE="Arial,Helvetica">The addr_expr can be any expression; therefore,
memory indirections can be specified in a single expression. Additional
The next example illustrates memory indirection:</FONT>
<BR><FONT FACE="Arial,Helvetica"> </FONT>
<BR><FONT FACE="Arial,Helvetica"> mem_name[mem_name[3]]</FONT>

<FONT FACE="Arial,Helvetica">In the above example, mem_name[3] addresses
word three of the memory called mem_name. The value at word three
is the index into mem_name that is used by the memory address mem_name[mem_name[3]].
As with bit-selects, the address bounds given in the declaration of the
memory determine the effect of the address expression. If the index
is out of the address bounds or if any bit in the address is x or z, then
the value of the reference shall be x.</FONT>

<FONT FACE="Arial,Helvetica"><FONT COLOR="#FF0000">Example</FONT></FONT>
<BR><FONT FACE="Arial,Helvetica"><FONT COLOR="#FF0000">The next example
declares an array of 256 by 256 8-bit elements and an array 256 by 256
by 8 1-bit elements:</FONT></FONT>

<FONT FACE="Arial,Helvetica"><FONT COLOR="#FF0000">
reg [7:0] twod_array[0:255][0:255];</FONT></FONT>
<BR><FONT FACE="Arial,Helvetica"><FONT COLOR="#FF0000">
wire threed_array[0:255][0:255][0:7];</FONT></FONT>

<FONT FACE="Arial,Helvetica"><FONT COLOR="#FF0000">The syntax for access
to the array shall consist of the name of the memory or array and an expression
for each addressed dimension:</FONT></FONT>
<BR><FONT FACE="Arial,Helvetica"><FONT COLOR="#FF0000">
twod_array[addr_expr][addr_expr]</FONT></FONT>
<BR><FONT FACE="Arial,Helvetica"><FONT COLOR="#FF0000">
threed_array[addr_expr][addr_expr][addr_expr]</FONT></FONT>

<FONT FACE="Arial,Helvetica"><FONT COLOR="#FF0000">As before, the addr_expr
can be any expression. The array twod_array accesses a whole 8-bit
vector, while the array threed_array accesses a single bit of the three
dimensional array.</FONT></FONT>

<FONT FACE="Arial,Helvetica"><FONT COLOR="#3366FF">To express bit selects
or part selects of array elements, the desired word shall first be selected
by supplying an address for each dimension. Once selected, bit and
part selects shall be addressed in the same manner as net and register
bit and part selects (Section 4.2.1).</FONT></FONT>

<FONT FACE="Arial,Helvetica"><FONT COLOR="#3366FF">Examples</FONT></FONT>
<BR><FONT FACE="Arial,Helvetica"><FONT COLOR="#3366FF">
twod_mem[14][1][3:0] // access lower
4 bits of word</FONT></FONT>
<BR><FONT FACE="Arial,Helvetica"><FONT COLOR="#3366FF">
twod_mem[1][3][6]
// access bit 6 of word</FONT></FONT>
<BR><FONT FACE="Arial,Helvetica"><FONT COLOR="#3366FF">
twod_mem[1][3][sel] //
use variable bit select</FONT></FONT>
<BR><FONT FACE="Arial,Helvetica"><FONT COLOR="#3366FF">
threed_array[14][1][3:0] // Illegal</FONT></FONT>

<STRIKE><FONT FACE="Arial,Helvetica"><FONT COLOR="#3366FF">NOTE - There
is no mechanism to express bit-selects or part-selects of memory elements
directly. If this is required, then the memory element has to be
first transferred to an appropriately sized temporary register.</FONT></FONT></STRIKE>
<BR>

<FONT FACE="Arial,Helvetica">Section 15.2.1 Syntax
of the value change dump file</FONT>
<BR><FONT FACE="Arial,Helvetica">Value changes for real variables are specified
by real numbers. Value changes for all other variables are specified
in binary format by 0,1,x, or z values. Strength information and <FONT COLOR="#FF0000">arrays
(including </FONT>memories <FONT COLOR="#FF0000">which are one dimensional
arrays) </FONT>are not dumped.</FONT>
</BODY>
</HTML>

--------------------

Stefen Boyd
__
| \ ____
|_/_ |
| \ |__
|___/oyd |
           |___nterprises
stefen@boyd.com
(408)739-BOYD
(408)481-9658 (fax)



This archive was generated by hypermail 2.1.4 : Mon Jul 08 2002 - 12:52:53 PDT and
sponsored by Boyd Technology, Inc.