racing condition in vhdl

Discussion in 'VHDL' started by lazyant118, Nov 30, 2013.

  1. lazyant118

    lazyant118

    Joined:
    Nov 29, 2013
    Messages:
    1
    Likes Received:
    0
    Below is a piece of VHDL code snippet implementing register file of a single cycle 32 bits mips processor. In this implementation, a combinational process is for data reading and a sequential process is for data writing. My question is that will it cause racing condition if a register is written followed by read it in two consecutive assembly instructions. It looks like both read and write instruction can be executed first. Your comments are highly welcome.

    library IEEE; use IEEE.STD_LOGIC_1164.all;
    use IEEE.STD_LOGIC_UNSIGNED.all;
    entity regfile is — — three-port register file
    port(clk: in STD_LOGIC;
    we3: in STD_LOGIC;
    ra1, ra2, wa3:in STD_LOGIC_VECTOR(4 downto 0);
    wd3: in STD_LOGIC_VECTOR(31 downto 0);
    rd1, rd2: out STD_LOGIC_VECTOR(31 downto 0));
    end;
    architecture behave of regfile is
    type ramtype is array (31 downto 0) of STD_LOGIC_VECTOR (31
    downto 0);
    signal mem: ramtype;
    begin
    — — three-ported register file
    — — read two ports combinationally
    — — write third port on rising edge of clock
    process(clk) begin
    if clk'event and clk  '1' then
    if we3  '1' then mem(CONV_INTEGER(wa3))  wd3;
    end if;
    end if;
    end process;
    process (ra1, ra2) begin
    if (conv_integer (ra1)  0) then rd1  X"00000000";
    — — register 0 holds 0
    else rd1  mem(CONV_INTEGER (ra1));
    end if;
    if (conv_integer(ra2)  0) then rd2  X"00000000";
    else rd2  mem(CONV_INTEGER(ra2));
    end if;
    end process;
    end;
     
    lazyant118, Nov 30, 2013
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    5,186
    walala
    Sep 18, 2003
  2. albert.neu@gmail.com
    Replies:
    2
    Views:
    9,704
    Jim Lewis
    Mar 21, 2006
  3. dude

    VHDL 2002 vs VHDL 1993

    dude, Mar 23, 2006, in forum: VHDL
    Replies:
    1
    Views:
    1,670
    Nicolas Matringe
    Mar 23, 2006
  4. -
    Replies:
    12
    Views:
    973
    Remon van Vliet
    Jun 15, 2005
  5. pygmalion
    Replies:
    6
    Views:
    6,441
    Dave Higton
    Jun 23, 2006
  6. afd
    Replies:
    1
    Views:
    9,961
    Colin Paul Gloster
    Mar 23, 2007
  7. vish_dude
    Replies:
    1
    Views:
    1,302
    mdtsdca
    Nov 1, 2007
  8. Bill W.
    Replies:
    13
    Views:
    553
    Phillip Gawlowski
    May 9, 2011
Loading...