Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - simulation problems

 
Thread Tools Search this Thread
Old 12-07-2007, 09:34 PM   #1
Default simulation problems


I am trying to convert a Verilog file to VHDL.

Verilog File =>
module Reg2(Q, D, en, rst, clk);
parameter REGWIDTH = 2;
input clk, en, rst;
input [(REGWIDTH-1):0] D;
output [(REGWIDTH-1):0] Q;
reg [(REGWIDTH-1):0] Q_int;
assign Q = (rst == 0)? Q_int : 2'd0;
always @ (posedge clk)
begin
if (rst == 1)
Q_int <= 2'd0;
else if (en == 1)
Q_int <= D;
else
Q_int <= Q_int;
end
endmodule


VHDL File =>
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY Reg2 IS
PORT( clk, rst, en : IN std_logic;
D : IN std_logic_vector(1 downto 0);
Q : OUT std_logic_vector(1 downto 0)
);
END Reg2;

ARCHITECTURE behavioral OF Reg2 IS
-- register and constant declaration
SIGNAL Q_int : std_logic_vector(1 downto 0);
CONSTANT LO : std_logic := '0';
CONSTANT HI : std_logic := '1';

BEGIN

Q <= Q_int when (rst = LO) else "00";

one : PROCESS (clk)
BEGIN

IF (clk = HI and clk'event) THEN

IF (rst = HI) THEN
Q_int <= "00";
ELSIF (en = HI) THEN
Q_int <= D;
END IF;

END IF;

END PROCESS one;

END behavioral;


VHDL test bench =>
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_Reg2 is
-- testbench entity is ALWAYS EMPTY
END tb_Reg2;
ARCHITECTURE tb of tb_Reg2 is

-- temporary signals
SIGNAL clk_temp : std_logic := '0';
SIGNAL rst_temp, en_temp : std_logic := '0';
SIGNAL D_temp, Q_temp : std_logic_vector(1 downto 0):= "00";

-- component declaration
COMPONENT Reg2 is
PORT( clk, rst, en : IN std_logic;
D : IN std_logic_vector(1 downto 0);
Q : OUT std_logic_vector(1 downto 0)
);
END COMPONENT;

BEGIN
UUT : Reg2
PORT MAP( clk => clk_temp,
rst => rst_temp,
en => en_temp,
D => D_temp,
Q => Q_temp
);

-- Passing values to inputs
clk_temp <= (not clk_temp) after 5 ns;

rst_temp <= '0' after 0 ns,'1' after 3 ns,'0' after 15
ns;

en_temp <= '1' after 5 ns,'0' after 11 ns,'1' after
18 ns,
'0' after 26 ns,'1' after 45 ns;

D_temp <= "11" after 4 ns, "10" after 16 ns,
"01" after 32 ns,"00" after 55 ns;

END tb; -- test bench ends


Whenever i am trying to simulate the test bench, the value of Q_int
and hence Q is always "00".
Please help

Anuja


Anuja
  Reply With Quote
Old 12-07-2007, 09:54 PM   #2
Ann
 
Posts: n/a
Default Re: simulation problems
On Dec 7, 4:34 pm, Anuja <thakkar.an...@gmail.com> wrote:
> I am trying to convert a Verilog file to VHDL.
>
> Verilog File =>
> module Reg2(Q, D, en, rst, clk);
> parameter REGWIDTH = 2;
> input clk, en, rst;
> input [(REGWIDTH-1):0] D;
> output [(REGWIDTH-1):0] Q;
> reg [(REGWIDTH-1):0] Q_int;
> assign Q = (rst == 0)? Q_int : 2'd0;
> always @ (posedge clk)
> begin
> if (rst == 1)
> Q_int <= 2'd0;
> else if (en == 1)
> Q_int <= D;
> else
> Q_int <= Q_int;
> end
> endmodule
>
> VHDL File =>
> LIBRARY IEEE;
> USE IEEE.STD_LOGIC_1164.ALL;
> ENTITY Reg2 IS
> PORT( clk, rst, en : IN std_logic;
> D : IN std_logic_vector(1 downto 0);
> Q : OUT std_logic_vector(1 downto 0)
> );
> END Reg2;
>
> ARCHITECTURE behavioral OF Reg2 IS
> -- register and constant declaration
> SIGNAL Q_int : std_logic_vector(1 downto 0);
> CONSTANT LO : std_logic := '0';
> CONSTANT HI : std_logic := '1';
>
> BEGIN
>
> Q <= Q_int when (rst = LO) else "00";
>
> one : PROCESS (clk)
> BEGIN
>
> IF (clk = HI and clk'event) THEN
>
> IF (rst = HI) THEN
> Q_int <= "00";
> ELSIF (en = HI) THEN
> Q_int <= D;
> END IF;
>
> END IF;
>
> END PROCESS one;
>
> END behavioral;
>
> VHDL test bench =>
> LIBRARY ieee;
> USE ieee.std_logic_1164.ALL;
> ENTITY tb_Reg2 is
> -- testbench entity is ALWAYS EMPTY
> END tb_Reg2;
> ARCHITECTURE tb of tb_Reg2 is
>
> -- temporary signals
> SIGNAL clk_temp : std_logic := '0';
> SIGNAL rst_temp, en_temp : std_logic := '0';
> SIGNAL D_temp, Q_temp : std_logic_vector(1 downto 0):= "00";
>
> -- component declaration
> COMPONENT Reg2 is
> PORT( clk, rst, en : IN std_logic;
> D : IN std_logic_vector(1 downto 0);
> Q : OUT std_logic_vector(1 downto 0)
> );
> END COMPONENT;
>
> BEGIN
> UUT : Reg2
> PORT MAP( clk => clk_temp,
> rst => rst_temp,
> en => en_temp,
> D => D_temp,
> Q => Q_temp
> );
>
> -- Passing values to inputs
> clk_temp <= (not clk_temp) after 5 ns;
>
> rst_temp <= '0' after 0 ns,'1' after 3 ns,'0' after 15
> ns;
>
> en_temp <= '1' after 5 ns,'0' after 11 ns,'1' after
> 18 ns,
> '0' after 26 ns,'1' after 45 ns;
>
> D_temp <= "11" after 4 ns, "10" after 16 ns,
> "01" after 32 ns,"00" after 55 ns;
>
> END tb; -- test bench ends
>
> Whenever i am trying to simulate the test bench, the value of Q_int
> and hence Q is always "00".
> Please help
>
> Anuja


I FOUND THE SOLUTION. INSTEAD OF USING TEMPORARY SIGNAL Q_INT, I
DIRECTLY UPDATED THE VALUE OF OUTPUT Q. IT IS WORKING FINE NOW.


Ann
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Pioneer DVR-105 and Nero Problems grams@oldtown.com DVD Video 1 08-12-2003 04:17 AM
Re: Pioneer DVR-105 and Nero Problems Ron DVD Video 1 08-08-2003 06:33 PM
Re: Pioneer DVR-105 and Nero Problems Flossie DVD Video 0 08-07-2003 02:25 PM
Re: Pioneer DVR-105 and Nero Problems Flossie DVD Video 0 08-07-2003 08:11 AM
Re: Pioneer DVR-105 and Nero Problems CAM DVD Video 0 08-07-2003 02:30 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46