Forum Discussion

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

How to hold data in a register

Hi all!

It's probably a naive question but i came from microcontroller's world.

When i write:

DATA_BUF <= DATA_BUS when (some condition)

So if DATA_BUS = 10 and after 5 sec it is 20 , DATA_BUF changes its value accordingly. How can i hold the previous vale in DATA_BUF?

2 Replies

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

    --- Quote Start ---

    Hi all!

    It's probably a naive question but i came from microcontroller's world.

    When i write:

    DATA_BUF <= DATA_BUS when (some condition)

    So if DATA_BUS = 10 and after 5 sec it is 20 , DATA_BUF changes its value accordingly. How can i hold the previous vale in DATA_BUF?

    --- Quote End ---

    Hi,

    do have any background in digital RTL design? If not, you need to go through some basics.

    In Verilog you could write:

    wire [7:0] DATA_BUS;

    wire CLK;

    reg [7:0] DATA_BUF;

    always @(posedge CLK) begin

    DATA_BUF <= DATA_BUS;

    end

    This code segment describes a register which stores with the positive edge of the signal CLK the value of DATA_BUS.