Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Quartus Simulation - initializing registers

Hi guys, I'm new to the FPGA scene and could use some help.

I'm designing a project using Verilog HDL. This project derives some computations from previous data stored in registers (reg type).

I'm trying to run a simulation for verification and I want to initialize these registers to a certain value. I've inserted the registers to the .cvwf file and set their values. However when I run the simulation all the registers are zeroed.

How can I manually set those registers' value?

Thank You.

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If you're just doing it for simulation, you can:

    a) - initialize the register in the declaration like:

    reg  my_reg = 32'hdeadbeef;

    b) - Create an initial block within your code.

    reg  my_reg;
    initial begin
         my_reg = 32'hdeadbeef;
    end

    c) - You can also create a macro that you only define for simulation that initializes the code

    reg  my_reg;
    `ifdef SIMULATION
    always @(posedge clk or negedge reset_n)
    if(!reset_n) my_reg <= 32'hdeadbeef;
    `endif

    Jake
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Okay I'll try your suggestions.

    But just to humor me, is there a way to initialize the registers in the .cvwf file? (Like I would set the clock signal or the reset etc.)

    Thank you.