Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL Variables Question

Status
Not open for further replies.

cobolt_dink

Newbie level 1
Joined
May 2, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,289
I'm building a simple processor for one of my classes. I am just using the behavior view to handle all the details going on inside of the register file. I've got an array of four registers and I give them default values inside of the register file. Everything seems to be working but a few nanoseconds after the register was written with the new value it goes back to what the default value was. I'm not sure if I should be giving them the default values somewhere or if I'm doing something else wrong.

I think all the relevant code is pasted below, intval() just takes a bit_vector and returns a integer value.

Code:
process
   --define register file
    type register_unit is array(0 to 3) of bit_vector(7 downto 0);
    variable registers: register_unit;
         
begin   
   -- initial the registers values
      registers(0) := "00000000";
      registers(1) := "00000001";
      registers(2) := "00000010";
      registers(3) := "00000011";
   
   -- write data to register 
   if ((W = '1') and (CLOCK='1') ) then       
      registers(intval(Write_Reg)) := Write_Data;
      
   end if;
 

You have assigned initial values for the registers inside process. These can be updated only when the execution of the process finished first time.

If you want to make default values for the registers, you need to declame them as signals outside the process and assign initial values. If you do this, whenever the device is powered up, the registers will have the default values.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top