EmbDev.net

Forum: FPGA, VHDL & Verilog VHDL instantiation in modelSim


von Hareesh M. (Company: Mindteck) (hareeshp)


Rate this post
useful
not useful
Hi i have written a vhdl code along with the testbench..when i simulate 
it in the modelSim i don't get an expected result

The VHDL Code is given below

 Library ieee;
    use ieee.std_logic_1164.all;
    entity PowerSeq is
        port(fpga_clk: in std_logic;
                Enable_Bias_1V, Enable_3V3, Enable_1P5V, Enable_1V: out 
std_logic;
                PG_3V3: in std_logic);
    end PowerSeq;

    architecture MPU_PowerSeq of PowerSeq is

        signal pon_state: integer:= 0;
    begin

        process(fpga_clk)
        begin
            if(rising_edge(fpga_clk)) then

                if(pon_state = 0) then
                    Enable_3V3 <= '1';
                    Enable_1P5V <= '1';
                    Enable_1V <= '0';
                    Enable_Bias_1V <= '1';
                    pon_state <= 1;
                end if;
                    if(pon_state = 1) then
                        if(PG_3V3 = '1') then
                            Enable_1V <= '1';
                        end if;
                    end if;

                end if;
            end process;
    end MPU_PowerSeq;

------------------------------------------------------------------------ 
------------------------------------------------------------------------ 
------

 and the Test bench is also given below

  library ieee;
 use ieee.std_logic_1164.all;
 use ieee.numeric_std.all;
 use ieee.std_logic_unsigned.all;
 entity PowerSeq is
 end PowerSeq;

 architecture MPU_PowerSeq of PowerSeq is

 component Sequence is
    port(fpga_clk : in std_logic;
        Reset: in std_logic;
             Enable_Bias_1V, Enable_3V3, Enable_1P5V, Enable_1V: out 
std_logic;

         PG_3V3: in std_logic);
    end component;

 signal  Reset: std_logic:= '0';
 signal  fpga_clk : std_logic:= '0';
 signal  Enable_Bias_1V: std_logic:= '0';
 signal  Enable_3V3: std_logic:= '0';
 signal  Enable_1P5V: std_logic:= '0';
 signal  Enable_1V: std_logic:= '0';
 signal  pon_state: integer:= 0;
 signal PG_3V3: std_logic:= '0';
 constant tb_time: time:= 15.5 ns;

 begin
 uut: sequence port map(
    Reset => Reset,
    fpga_clk => fpga_clk,
    Enable_Bias_1V => Enable_Bias_1V,
    Enable_3V3 => Enable_3V3,
    Enable_1P5V => Enable_1P5V,
    Enable_1V => Enable_1V,
    PG_3V3 => PG_3V3
    );

 stimlus: process
 begin
    fpga_clk <= '0' after tb_time, '1' after 2 * tb_time;
    wait for 2 * tb_time;
 end process;

 tb: process
 begin
  wait for 50 ns ;
  Reset <= '0';
  Enable_3V3 <= '0';
  Enable_3V3 <= '0';
  Enable_1V <= '0';
  wait for 50 ns;
  Reset <= '1';
  wait for 1 us;
  end process;

end;

von Erik (Guest)


Rate this post
useful
not useful
1) What do you expect?
2) I assume this code is not to be synthesized
3) 
https://stackoverflow.com/questions/17904514/vhdl-how-should-i-create-a-clock-in-a-testbench

Erik

von Hareesh M. (Company: Mindteck) (hareeshp)


Rate this post
useful
not useful
thanks for your reply
 but what things should i change in testbench to make it synthesizable?

von guest (Guest)


Rate this post
useful
not useful
Nothing. Testbench has nothing todo with synthesiser.

Again, what is not working in your simulation?


maybe you are fooled by your resets etc?
1
tb: process
2
 begin
3
  wait for 50 ns ;
4
  Reset <= '0';
5
  Enable_3V3 <= '0';
6
  Enable_3V3 <= '0';
7
  Enable_1V <= '0';
8
  wait for 50 ns;
9
  Reset <= '1';
10
  wait for 1 us;
11
  end process;
12
13
14
15
16
tb: process
17
 begin
18
  wait for 50 ns ;
19
  Reset <= '0';
20
  Enable_3V3 <= '0';
21
  Enable_3V3 <= '0';
22
  Enable_1V <= '0';
23
  wait for 50 ns;
24
  Reset <= '1';
25
26
  wait; -- STOP THIS PROCESS HERE?
27
28
29
  end process;

von Hareesh M. (Company: Mindteck) (hareeshp)


Rate this post
useful
not useful
I have changed the above testbench.


library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;
entity PowerSeq is
end PowerSeq;
architecture MPU_PowerSeq of PowerSeq is
component Sequence is
  port(fpga_clk      : in std_logic;
       Reset         : in std_logic;
       Enable_Bias_1V, Enable_3V3, Enable_1P5V, Enable_1V: out 
std_logic;
       PG_3V3        : in std_logic
       );
  end component;

    signal   Reset          : std_logic:= '0';
    signal   fpga_clk       : std_logic:= '0';
    signal   Enable_Bias_1V : std_logic:= '0';
    signal   Enable_3V3     : std_logic:= '0';
    signal   Enable_1P5V    : std_logic:= '0';
    signal   Enable_1V      : std_logic:= '0';
    signal   pon_state      : integer:= 0;
    signal   PG_3V3         : std_logic:= '0';
    constant tb_time        : time:= 1 ns;
begin

uut: sequence port map(
  Reset => Reset,
  fpga_clk => fpga_clk,
  Enable_Bias_1V => Enable_Bias_1V,
  Enable_3V3 => Enable_3V3,
  Enable_1P5V => Enable_1P5V,
  Enable_1V => Enable_1V,
  PG_3V3 => PG_3V3
  );

stimlus: process
begin
  fpga_clk <= '0' after tb_time, '1' after  2 * tb_time;
  wait for 2 * tb_time;
end process;

tb: process
    begin
    wait for 5 ns ;
    Reset <= '0';
    Enable_Bias_1V <= '1';
    Enable_3V3 <= '1';
    Enable_1P5V <= '1';
    wait for 5 ns;
    if(pon_state = 0) then
    Enable_Bias_1V <= '1';
    Enable_3V3 <= '1';
    Enable_1P5V <= '1';
    pon_state <= 1;
    end if;
    if(pon_state = 1) then
    PG_3V3 <= '1';
    Enable_1v <= '1';
    end if;
    -- wait for 5 ns;
    --Reset <= '1';
    end process;

end;

von Duke Scarring (Guest)


Attached files:

Rate this post
useful
not useful
1
$ vlib work
2
3
$ vcom sequencer.vhd
4
Model Technology ModelSim SE-64 vcom 10.3d Compiler 2014.10 Oct  7 2014
5
-- Loading package STANDARD
6
-- Loading package TEXTIO
7
-- Loading package std_logic_1164
8
-- Compiling entity PowerSeq
9
-- Compiling architecture MPU_PowerSeq of PowerSeq
10
Errors: 0, Warnings: 0
11
12
$ vcom sequencer_tb.vhd
13
Model Technology ModelSim SE-64 vcom 10.3d Compiler 2014.10 Oct  7 2014
14
-- Loading package STANDARD
15
-- Loading package TEXTIO
16
-- Loading package std_logic_1164
17
-- Loading package NUMERIC_STD
18
-- Loading package std_logic_arith
19
-- Loading package STD_LOGIC_UNSIGNED
20
-- Compiling entity PowerSeq
21
-- Compiling architecture MPU_PowerSeq of PowerSeq
22
###### sequencer_tb.vhd(8): component Sequence is
23
** Error: sequencer_tb.vhd(8): near "Sequence": expecting IDENTIFIER
24
Errors: 1, Warnings: 0

After fixing some identifiers errors.
Than I had to fix mismatched component/entity description and - maybe 
this is the important thing - add additional delay after "if(pon_state = 
0) then ... end if;" in your stimulus generation.
Take a look again for the concept of signals in VHDL.

See simulation results in the picture. I also attach the modified 
testbench.

Duke

von world's best FPGA-Pongo (Guest)


Rate this post
useful
not useful
I am always impressed that people spend time on analyzizng other 
people's code to find the syntax issues. Shouldn't it be a task to learn 
to do that by one self?

BTW:  Duke, you seem to be using and old MOdelSIM with data 2014.

>"Model Technology ModelSim SE-64 vcom 10.3d Compiler 2014.10 Oct  7 2014"

Why is this?
Are you using an old dongle, too? :D :D :D

von Duke Scarring (Guest)


Rate this post
useful
not useful
world's best FPGA-Pongo wrote:
Syntax errors are easy to remedy.

> Why is this?
No time for update :-)
(And I don't need the new features yet.)

Duke

von Hareesh M. (Company: Mindteck) (hareeshp)


Rate this post
useful
not useful
Hi Duke,
Actually i have a doubt about the code you have edited. can we use 'if' 
statement inside a uut process?

von Duke Scarring (Guest)


Rate this post
useful
not useful
Hareesh M. wrote:
> can we use 'if'
> statement inside a uut process?
Yes of course.

See LRM (p. 125):
https://edg.uchicago.edu/~tang/VHDLref.pdf

Duke

von Hareesh M. (Company: Mindteck) (hareeshp)


Rate this post
useful
not useful
thanks for your reply..I will go through this pdf.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.