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.

wondering how to make the simulation work with error Error: (vsim-3174)

Status
Not open for further replies.

YL12413

Newbie level 2
Joined
Dec 7, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
47
Hi, there:

First of all, I would like to say thanks for any help.

I just started coding in VHDL and created FSM, but when I tried to start the simulation, there was the error:
Error: (vsim-3174) Package 'H:/VHDL/project1/work.config_pack' requires a body.
which really confused me, maybe any of you may help me out?

the following will be the code:

Code VHDL - [expand]
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
USE STD.TEXTIO.ALL;
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
 
PACKAGE config_pack IS
 
 
    CONSTANT config_clock_period : time   := 1000 ns; -- period of clock as one micro second
    CONSTANT config_post_cycles  : integer := 100; -- idle cycles waiting for new potential new config commands
    CONSTANT post_command_delay  : time    := config_clock_period * config_post_cycles;
 
 
----potential config commands with 3 bits------
    ALIAS slv IS std_logic_vector;
 
    CONSTANT off             : slv(2 DOWNTO 0) := "000"; --pulse generator is inactivated
    CONSTANT vol_m           : slv(2 DOWNTO 0) := "001"; --programmed to voltage mode
    CONSTANT cur_m           : slv(2 DOWNTO 0) := "010"; --programmed to current mode
  CONSTANT vdd             : slv(2 DOWNTO 0) := "011"; --pull the output to VDD
    CONSTANT charge_balance  : slv(2 DOWNTO 0) := "100"; --maybe need to be charge balance
    CONSTANT gnd             : slv(2 DOWNTO 0) := "111"; --maybe gnd
    ----------------------------------------------------------------------
    TYPE STATE_T IS (PNEG, PPOS, PSHT, PINT);
  
  CONSTANT TN : INTEGER;         --NEGATIVE PHASE WIDTH
  CONSTANT TP : INTEGER;         --POSITIVE PHASE WIDTH
  CONSTANT TI : INTEGER;         --INTERMEDIATE PHASE WIDTH
  CONSTANT TS : INTEGER;         --SHORTING PHASE WIDTHx
  CONSTANT PULSE_N : STD_LOGIC_VECTOR(1 DOWNTO 0):="10";
  CONSTANT PULSE_P : STD_LOGIC_VECTOR(1 DOWNTO 0):="01";
  CONSTANT PULSE_S : STD_LOGIC_VECTOR(1 DOWNTO 0):="11";
  CONSTANT PULSE_Z : STD_LOGIC_VECTOR(1 DOWNTO 0):="00";
 
END;
 
 
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.NUMERIC_STD.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE WORK.PROJECT_PACK.ALL;
USE WORK.CONFIG_PACK.ALL;
 
ENTITY FSM_PULSE IS
  PORT(
    CLK, RESET  : IN STD_LOGIC;
    CONFIG      : IN STD_LOGIC_VECTOR(2 DOWNTO 0);
    start       : IN STD_LOGIC;
    Pulse       : OUT STD_LOGIC_VECTOR(1 DOWNTO 0)
  );
END FSM_PULSE;
 
ARCHITECTURE FSM_BEHAV OF FSM_PULSE IS
  SIGNAL STATE, STATE_N : STATE_T;
  SIGNAL COUNTER : INTEGER RANGE 0 TO (TN+TP+TI+TS);
  SIGNAL PULSE1  : STD_LOGIC_VECTOR(1 DOWNTO 0);
  BEGIN
               
  S_PROC: PROCESS(STATE, STATE_N, COUNTER)
  BEGIN
    STATE_N <= STATE;
    CASE STATE IS 
    WHEN PPOS =>
      PULSE1 <= PULSE_P;
      IF (COUNTER = TP) THEN
        STATE_N <= PINT;
      END IF;
    WHEN PINT =>
      PULSE1 <= PULSE_Z;
      IF (COUNTER = TP + TI)THEN
        STATE_N <= PNEG;
      END IF;
    WHEN PNEG =>
      PULSE1 <= PULSE_N;
      IF (COUNTER = TP + TI + TN)THEN
        STATE_N <= PSHT;
      END IF;
    WHEN PSHT =>
      PULSE1 <= PULSE_S;
      IF (COUNTER = TP + TI + TN+ TS)THEN
        STATE_N <= PPOS;
      END IF;
    WHEN OTHERS => NULL;
    END CASE;
 -------------------------OUTPUT THE PULSE ONLY IF IT IS ENABLED-----------------------   
    IF START='1' THEN
      PULSE <= PULSE1;
    END IF;
    
  END PROCESS S_PROC;
    
  C_PROC: PROCESS
  BEGIN
    WAIT UNTIL CLK'EVENT AND CLK='1';
    STATE <= STATE_N;
    
    IF RESET = '1' THEN
      STATE <= PPOS;
      COUNTER <= 0;
    END IF;
    
    COUNTER <= COUNTER + 1;
  END PROCESS C_PROC;
    
END ARCHITECTURE FSM_BEHAV;



and here is the testbench:

Code VHDL - [expand]
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
47
48
49
50
51
52
53
54
55
56
57
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
USE work.project_pack.all;
USE std.textio.ALL;
USE WORK.CONFIG_PACK.ALL;
 
ENTITY FSM_testbench IS
END FSM_testbench;
 
ARCHITECTURE behav OF fsm_testbench IS
   
   -- FSM_PULSE 
    SIGNAL CLK_I         :  STD_LOGIC;
    SIGNAL RESET_I       :  STD_LOGIC;
    SIGNAL CONFIG_I      :  STD_LOGIC_VECTOR(2 DOWNTO 0);
    SIGNAL start_I       :  STD_LOGIC;
    SIGNAL Pulse_I       :  STD_LOGIC_VECTOR(1 DOWNTO 0);
   
   -- needed as parameters for run_command_file but not
   -- used since it is called with ram_mode_v=model
   SIGNAL cycle_init, cycle_done : STD_LOGIC;  -- dummy signals
 
   SIGNAL trace_commands: boolean := false;
 
BEGIN
   FSM1: ENTITY WORK.FSM_PULSE
   PORT MAP(
     CLK        => CLK_I, 
     RESET      => RESET_I,
    CONFIG      => CONFIG_I,
    start       => START_I,
    Pulse       => PULSE_I
   );
 
   P_RST_CLK: PROCESS
      -- generate reset_i & clk_i
      BEGIN
        -- first ten cycles with reset '1'
        reset_i <= '1';
        clk_i <= '0';
        FOR n in 0 TO 9 LOOP
          WAIT FOR config_clock_period / 2;
          clk_i <= '1';
          WAIT FOR config_clock_period / 2;
          clk_i <='0';
        END LOOP;
          reset_i <= '0';
        -- now generate continuous clock with reset '0'
        WHILE TRUE LOOP
           clk_i <= '0';
           WAIT FOR config_clock_period / 2;
           clk_i <= '1';
           WAIT FOR config_clock_period / 2;
        END LOOP;
      END PROCESS P_RST_CLK;
END behav;




Thanks a lot!!!!
 
Last edited by a moderator:

See this link for a package example https://www.asic-world.com/examples/vhdl/package.html

I believe the package body is required, but it can be empty.

Regards

- - - Updated - - -

Just noticed you are using both the numeric_std (actual IEEE library) and the synopsys std_logic_unsigned and std_logic_arith in the FSM_PULSE entity. You should probably stick with using the IEEE library and get rid of the synopsys ones as they aren't part of the IEEE VHDL LRM specification.
 

Thanks for your reply, I'm gonna try
 

I cannot see anything in your config_pack that would require a body.
Did you post all of the code?
What simulator are you using?
 

Has to be using Modelsim as the error is reporting VSIM-3174 and a quick google search shows that exact error for others compiling packages. Most of them are dealing with corrupted package files.

Regards

- - - Updated - - -

Just noticed you didn't end your package with: END config_pack;

Try adding config_pack to the END statement of the PACKAGE.

Regards
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top