Re: Question on ROM // Your opinion on reply


Subject: Re: Question on ROM // Your opinion on reply
From: VhdlCohen@aol.com
Date: Sat Jul 13 2002 - 12:17:34 PDT


Change example to a single one for Example 25
Example 25:
module rom_2dimarray_initial (
output wire [3:0] z,
input wire [2:0] a); // address- 8 deep memory
// Declare a memory rom of 8 4-bit registers. The indices are 0 to 7:
(* synthesis, rom_block = "ROM_CELL XYZ01" *) reg [3:0] rom[0:7];
  initial
    begin : ROM_DEF
       integer i;
      for (i=0; i <= 252; i=i+1)
        if (i<100) rom[i] = (i + 1) % 16;
        else rom[i] = (i + 2) % 16;
      rom[253] = 4'b0111; // using constants
      rom[254] = 4'b0101;
      rom[255] = 4'b0100;
    end

  assign z = rom[a];
endmodule

This does not mess up the numbering in the examples.
Ben

In a message dated 7/13/02 11:51:51 AM Pacific Daylight Time,
VhdlCohen@aol.com writes:
> Question
> 5.6.2, pg 13
> Can any variables be used in calculating memory values for a ROM? Can
> those variables be used in other synthesizable constructs after that? Is
> there any assumption that they obtain an initial value because of the
> calculation?
>
> My answer:
> Add the following to 5.6.2
> Local variables can be used for the calculation of memory values.
> Variables outside the scope of the initial statement shall not be allowed.
> Example 25: // <-- that would mess up the numbering of the other
> examples.
> module rom_2dimarray_initial (
> output wire [3:0] z,
> input wire [2:0] a); // address- 8 deep memory
> // Declare a memory rom of 8 4-bit registers. The indices are 0 to 7:
> (* synthesis, rom_block = "ROM_CELL XYZ01" *) reg [3:0] rom[0:7];
> initial
> begin : ROM_DEF
> integer i;
> for (i=0; i <= 255; i=i+1)
> if (i<100) rom[i] = (i + 1) % 16;
> else rom[i] = (i + 2) % 16;
> end
>
> assign z = rom[a];
> endmodule
>
> Rationale: Order of execution of initial statements is non-deterministic.
> Allowing non-local variables would allow one ROM (e.g., ROM1 defined with
> initial) to read content of another ROM or another non-initialized
> variable.
> Like:
> initial
> begin : ROM_DEF
> integer i;
> for (i=0; i <= 255; i=i+1)
> if (i<100) rom[i] = i + 1;
> else rom[i] = rom2[i]* 2; // rom2 is in another initial statement
> // THAT SHOULD NOT BE ALLOWED
> end
>
> Opinions?
>
> Below is same code with earlier vlog style for compilation checks.
> FYI
> ---
> // style (for code debug only. Compiles OK
> module rom(z, a);
> output [3:0] z;
> input [4:0] a;
>
> reg [3:0] rom[0:7];
> // integer i;
> initial
> begin : ROM_DEF
> integer i;
> for (i=0; i <= 255; i=i+1)
> if (i<100) rom[i] = (i + 1) % 16;
> else rom[i] = (i + 2) % 16;
> end
>
> assign z = rom[a];
> endmodule
>
>

 



This archive was generated by hypermail 2b28 : Sat Jul 13 2002 - 12:26:43 PDT