Create File Template

Hello,

first of all, great tool ;-) makes really a lot of fun working with it.
But just one question from me concerning the templates. Is there a way to create a file template, thus when I go to new, in the menu I can select it there? I would like to use this for testbenches.

Thanks a lot

Yours sincerely

Philipp Nörtersheuser

File Templates

Hi Philipp,

It is currently not possible to add custom file templates directly, but there is a simple workaround:

First create a custom template for your typical testbenches.

To create a new testbench:

  • Create an empty VHDL file
  • Type the beginning of the name of your template and Ctrl-Space

Hi Heeckhau, that is the way

Hi Heeckhau,

that is the way I am curretnly doing this, but I hoped there would be a solution to establish that as a default file.
Are there any plans to automatically create testbenches; so componentns and stuff?

Cheers Phil

Automatic test benches

Hi Philipp,

it is on the roadmap, but the specs are still a bit vague. What do you expect from such a feature?

Hendrik.

Hello Hendrik, I would like

Hello Hendrik,

I would like just the same as in ISE for example, thus
- Entity and Architecture
- Generics if needed for the UUT
- UUT Component instantiation and declaration
- Signal generation and initialization
- Clock generation (only the clock <= not clock after 50 ns) or so
- Basic beginning of the testbench (set and unset Reset pin)
That would be all I think. If I find the time I will have a look what is generated there.

Yours sincerely

Philipp Nörtersheuser

Check out emacs vhdl-mode testbench

If you're still speccing this feature, I'd like something comperehensive and configurable like vhdl-mode in emacs. Like this:

From an entity like this:

entity show is
    generic (
        g : integer := 1);
    port (
        clk, reset : in std_logic;
        a,b : in std_logic;
        c : out std_logic);
end entity show;

I get this (with no further typing other than to name the architecture at a prompt):

<company header>
library ieee;
use ieee.std_logic_1164.all;
 
entity tb_show is
end entity tb_show;
architecture test of tb_show is
    -- component generics
    constant g : integer := 1;
    -- component ports
    signal clk, reset : std_logic;
    signal a, b       : std_logic;
    signal c          : std_logic;
  -- clock
  signal Clk : std_logic := '1';
  -- finished?
  signal finished : std_logic;
begin  -- architecture test
    -- component instantiation
    DUT: entity work.show
        generic map (
            g => g)
        port map (
            clk   => clk,
            reset => reset,
            a     => a,
            b     => b,
            c     => c);
  -- clock generation
  Clk <= not Clk after 10 ns when finished /= '1' else '0';
  -- waveform generation
  WaveGen_Proc: process
  begin
    finished <= '0';
      -- insert signal assignments here
    finished <= '1';
    report (time'image(now) & " Finished");
    wait;
  end process WaveGen_Proc;
end architecture test;
--------------------------------------------------------------------------
configuration tb_show_test_cfg of tb_show is
    for test
    end for;
end tb_show_test_cfg;
--------------------------------------------------------------------------

Some whitespace removed and some '-s' for brevity!

Note that the wavegen proc has some customisations in it - the "finished" signal and its declaration and use in the CLK statement are different from the default, but were easy to add.

Note also that the clk signal ends up declared twice, I haven't figured out how to fix that, so if you could do the right thing there, that'd be even better :)

VHDL Emacs magic

Hi Martin,

Thanks for your request. We were thinking of making all new-file wizards based on configurable templates. I guess we need recursive templates (company header will be a template as well) and intelligent templates (text generation based on the existing entity.

We'll use this for further inspiration.

BTW, can you tell us how to trigger the magic in Emacs VHDL mode for generating a testbench?

Philippe

More magic

Hi Philippe,

If you use C-c C-p C-w (VHDL..Port..Copy) with the cursor ('point' in emacsspeak :) inside the entity, and then C-c C-p C-t (VHDL..Port..Paste as testbench) you'll be prompted for an architecture name, and the rest will be done.

I have the following relevant customisations in my .emacs file:

(custom-set-variables
 '(vhdl-clock-edge-condition (quote function))
 '(vhdl-company-name "TRW Limited")
 '(vhdl-directive-keywords (quote ("pragma" "synopsys" "synthesis")))
 '(vhdl-end-comment-column 130)
 '(vhdl-file-header "-- balh, copyright etc.
<cursor>
")
 '(vhdl-reset-kind (quote none))
 '(vhdl-standard (quote (93 nil)))
 '(vhdl-testbench-declarations "  -- clock
  signal Clk : std_logic := '1';
  -- finished?
  signal finished : std_logic;
")
 '(vhdl-testbench-directory-prefix "./")
 '(vhdl-testbench-entity-name (quote (".*" . "tb_\\&")))
 '(vhdl-testbench-statements "  -- clock generation
  Clk <= not Clk after 10 ns when finished /= '1' else '0';
 
  -- waveform generation
  WaveGen_Proc: process
  begin
    finished <= '0';
      -- insert signal assignments here
    finished <= '1';
    report (time'image(now) & \" Finished\");
    wait;
  end process WaveGen_Proc;
")

Hope this helps!

Cheers,
Martin

Thanks

Hi Martin,

Thanks for refreshing my Emacs knowledge. I wanted to try out its behavior for extra inspiration.

Philippe

New File Wizard!

There is an improved (and configurable) New File wizard in the latest release.
Check out the one minute screencast too!

Post new comment

The content of this field is kept private and will not be shown publicly.
By submitting this form, you accept the Mollom privacy policy.