bit referencing in Memory Array 
Author Message
 bit referencing in Memory Array

Verilog Cerebral Giants

        If I have a Memory

        reg[7:0] mem[255:0];

        How do I reference a single bit??

for example:  How do I get to bit 4 of mem location 120

          I would like to do it without assigning it to
           a temp variable first.  Is it possible?

--DAVE



Mon, 16 Aug 1999 03:00:00 GMT  
 bit referencing in Memory Array


: Verilog Cerebral Giants

:       If I have a Memory

:       reg[7:0] mem[255:0];

:       How do I reference a single bit??

There is no verilog syntax to do this in one statement. You have to
do it by assigning the word of memory to a temporary register, and
then selecting the desired bit.

reg[7:0] mem[255:0];
reg[7:0] temp;

initial
begin

    temp = mem[120];
    $display("Bit 4 of memory element 12o is %b",temp[4]);
end

--

Avrum Warshawsky

Hewlett-Packard Co.
Integrated Circuit Business Division



Tue, 17 Aug 1999 03:00:00 GMT  
 bit referencing in Memory Array

Quote:

> Verilog Cerebral Giants

>         If I have a Memory

>         reg[7:0] mem[255:0];

>         How do I reference a single bit??

> for example:  How do I get to bit 4 of mem location 120

>           I would like to do it without assigning it to
>            a temp variable first.  Is it possible?

> --DAVE

The Verilog HDL allows aonly single dimensional access to data objects,
to do what you want, you can do

         MEM[ i ] & 0x08   (read)

or
         MEM[i] = MEM[i] & ~0x08) | ( expression << 3 )   (store)

Hope this help

tan
silicon-sorcery



Tue, 17 Aug 1999 03:00:00 GMT  
 bit referencing in Memory Array


Quote:
>Verilog Cerebral Giants

>    If I have a Memory

>    reg[7:0] mem[255:0];

>    How do I reference a single bit??

>for example:  How do I get to bit 4 of mem location 120

>      I would like to do it without assigning it to
>           a temp variable first.  Is it possible?

Having just returned from Cadence's Verilog-XL class, I can tell you that it is impossible to address a single bit without assigning it to a temp variable first.  That example was given in class and the same question asked.

--

| Motorola ADCD  M/S: CH275 | phone: (602)814-4920             |
| 1300 N. Alma School Rd.   | fax:   (602)814-4963             |
| Chandler, AZ 85224        |                                  |



Wed, 18 Aug 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. (typep (make-array 10 :element-type 'bit) '(array bit (10)))

2. Access Array Elements by Arrays Reference

3. HOWTO: reference elements of an array if array name is in a variable

4. Memory usage of PHP script/arrays and memory restriction/error

5. 32 bit api calls - some references

6. HELP: Referencing address in 32-bit PLEASE

7. Division 32-Bit/32-Bit with 16-Bit Register

8. Memory running full (de-reference ole objects)

9. local variable of a reference to a user defined control - how much memory it takes

10. WWW: Memory Management Reference

11. Persistent memory and functional langs--references desired.

12. WWW: Memory Management Reference

 

 
Powered by phpBB® Forum Software