8. Memory

The “memory” is a syntax to arrange and to memorize a large amount of information,
and declares in the declaration list of the internal structure element.

The “memory” registers the value at the relevant address at the next clock to the one that wrote in it.
The declaration method of the “memory” is as follows.

mem Memory_name [Number_of_words_of_memory][Bit_width]

It is also possible to initialize the “memory” when it declares.
The initializing method of the “memory” is as follows.

mem Memory_name [Number_of_words_of_memory][Bit_width] = {Data_at_address0, Data_at_address1, … , Data_at_addressX}

The “memory” uses the same transfer method as the register.
The transfer of “:=” is used to write in the “memory”.
The transfer of “=” is used to read in the “memory”.
As an example, when it describes a 4-bit width/256-word memory that is possible to read/write,
it becomes as the following Example 39.

<<Example39. Memory>>
declare ex39 {
   input in[4], adr[8] ;
   output f[4] ;

   func_in write ;
   func_in read ;
module ex39 {
   mem m[256][4] ;

   function write m[adr] := in ;
   function read  f = m[adr] ;

The memory that is defined by “mem m[256][4]” is 256 words per 4 bits/word.
In this example, it implements transferring a value to/from the memory,
that uses the control input terminal “read” and “write”.
The logical simulation result is shown as follows.