element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Blog Alternatives to VHDL/Verilog for hardware design
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jpiat
  • Date Created: 28 Oct 2014 5:35 PM Date Created
  • Views 6379 views
  • Likes 2 likes
  • Comments 6 comments
  • python
  • fpga
  • vhdl
  • logi
  • hls
  • verilog
Related
Recommended

Alternatives to VHDL/Verilog for hardware design

jpiat
jpiat
28 Oct 2014

Hardware description languages (HDLs) are a category of programming languages that target digital hardware design. These languages provides special features to design sequential logic( the system evolve over time represented by a clock) or combinational logic (the system output is a direct function of its input). While these language have proved to be efficient to design hardware, they often lack the tool support (editors are far behind what you can get to edit C/java/etc) and the syntax can be hard to master. More-over, these language can generate sub-optimal, faulty hardware which can be very difficult to debug.

 

Over the past-year some alternative languages have arisen to address the main issues of the more popular HDLs (VHDL/Verilog). These new languages can be classified into two categories as follows.

 

Categories of Hardware description Languages (HDLs)

 

  1. HLS (High Level Synthesis) : HLS tools, try to take an existing programming language as an input and generate the corresponding HDL (hardware description language).. Some of these tools are quite popular in the EDA industry such as CatapultC from Mentor Graphics, Matlab HDL coder, but are very expensive. Xilinx recently integrated the support of SystemC and C in their Vivado toolchain but it only supports high-end FPGA.
  2. Alternative syntax : Some tools propose an alternative syntax to VHDL or Verilog. The alternative syntax approach keeps the control of the generated hardware, but gives the advantage of an easier to master syntax and sometimes of ease of debugging.

 

While the HLS seems attractive. there is a good chance it will generate sub-optimal hardware if the designer does not write the “software” with hardware in mind. The approach is a bit magical as you can take existing C/Matlab software and generate hardware in a few clicks.

HLS is very practical to reduce time to first prototype (especially with Matlab) and for people with little (or no) HDL knowledge to produce a functional hardware design.  However,  HLS tools are not good for the users who want to learn digital design and the good HLS tools are usually very expensive (a CatapultC license can cost more than 100k$ [link], and Matlab HDL coder starts at 10k$ [link]).

Over the past year some open-source, free to use alternatives to HDL have emerged. These tools do not pretend to create hardware from behavioral description, but propose to smoothen the learning curve for digital logic design by relying on easier to master syntax and feature rich tools.

In the following we will review two of these alternatives languages (myHDL, PSHDL). To test the languages, we will use them to design and debug a simple PWM module. We chose these two languages based on their distinct properties and community adoption but other tools such as MiGen (python based syntax) which will not be covered here, but use the same kind of design flow.

Category 1 - myHDL [http://www.myhdl.org/]

 

myHDL uses python to design and test hardware components. A hardware component is designed as a python function whose arguments are the inputs and outputs of the component. The component can then describe sub-functions and designate them as combinational or sequential logic using a decorator (some text prefixed by the @ symbol that defines properties for a function/method). Once the design is complete, it can be exported to HDL (VHDL or Verilog) using a small python snippet. The design can also be tested/simulated in the python environment and generate waveform traces.

myhdl_flow.png

Installation of myHDL

Installing myHDL is straightforward and can be done with a single line on a Linux system(not tested with windows).

sudo pip install myhdl

Design of the PWM module in myHDL

 

The pwm component is pretty straightforward. It has two inputs period and t_on that designate respectively the period of the pwm signal and the number of cycles that the pwm edges are triggered on. The module has two outputs: pwm_out that is the pwm signal and period_end that is asserted at the end of a period and de-asserted otherwise. Here is the corresponding myHDL code.


from myhdl import *

 

def pwm_module(period, t_on, pwm, period_end, clk):

 

    count = Signal(intbv(0)[16:])

 

    @always(clk.posedge)

    def logic():

    if count == period:

       count.next = 0

       period_end.next = 1

    else:

       count.next = count + 1

       period_end.next = 0

 

    if count > t_on:

       pwm.next = 0

    else:

       pwm.next = 1

    return logic

 

The module is evaluated/simulated using the following test-bench.

 

def TestBench():

    clk = Signal(bool(0))

    period = Signal(intbv(200)[16:])

    t_on = Signal(intbv(100)[16:])

    pwm_out = Signal(bool(0))

    period_end = Signal(bool(0))

 

    pwm_inst = pwm_module(period, t_on, pwm_out, period_end, clk)     

    @always(delay(1))

    def tb_clkgen():

            clk.next = not clk

  

    @instance

    def tb_stim():

    period = 200

    t_on = 100      

    yield delay(2)

        for ii in xrange(400):

            yield clk.negedge

            print("%3d  %s" % (now(), bin(pwm_out, 1)))

 

        raise StopSimulation

    return tb_clkgen, tb_stim, pwm_inst

 

if __name__ == '__main__':

    Simulation(TestBench()).run()

 

The Corresponding HDL code is generated by changing this line of code:

pwm_inst = pwm_module(period, t_on, pwm_out, period_end, clk)

into this line of code:

pwm_inst = toVHDL(pwm_module, period, t_on, pwm_out, period_end, clk)

and here is the resulting VHDL:

 

 

 

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.numeric_std.all;

use std.textio.all;

 

use work.pck_myhdl_081.all;

 

entity pwm_module is

    port (

        period: in unsigned(15 downto 0);

        t_on: in unsigned(15 downto 0);

        pwm: out std_logic;

        period_end: out std_logic;

        clk: in std_logic

    );

end entity pwm_module;

 

architecture MyHDL of pwm_module is

 

signal count: unsigned(15 downto 0);

begin

 

PWM_MODULE_LOGIC: process (clk) is

begin

    if rising_edge(clk) then

        if (count = period) then

                count <= to_unsigned(0, 16);

                period_end <= '1';

        else

                count <= (count + 1);

                period_end <= '0';

        end if;

        if (count > t_on) then

                pwm <= '0';

        else

                pwm <= '1';

        end if;

    end if;

end process PWM_MODULE_LOGIC;

 

end architecture MyHDL;

 

myHDL lines to VHDL lines : 20 -> 42 = 0.47

Pro and Cons of using myHDL or similar languages

 

Pro:

  • Python syntax is clean and forces the user to structure the code appropriately
  • The syntax elements introduced for hardware design are relevant and does not add much syntax (the next attribute is a great idea and reflects the hardware behavior)
  • The quality of the generated code is great !
  • The simulation has a great potential, you can even generate a waveform
  • One can take advantage of the extensive collection of Python packages to create powerful simulations
  • Small designs can fit in one file.

Cons:

  • The use of decorators is not great for readability (and i’am not a decorator fan …)
  • One really needs to understand digital logic and hardware design before starting a myHDL module
  • One really needs to master the basics of Python before getting started
  • Python will raise errors for syntax errors but simulation does raise warning or errors if there is a design error (incomplete if/case clause or other things that a synthesizer would detect)
  • There is no (that i know of) myHDL specific editor or environment that would ease the beginner experience.

Category 2 - The Custom Syntax Approach - PSDHL [http://pshdl.org/]

 

PSHDL (plain and simple hardware description language) is an HDL language with custom syntax that takes elements inherited from C/SystemC and adds a custom set of keywords and coding elements to represent a hardware module. A module has no arguments but declares some internal variables as “in” or “out”. The nice and clever thing about PSHDL is that only one keyword is used to represent a sequential part of the module. Instead of declaring a computational unit of sequential or combinational logic, a keyword “register” is used to identify the variables/signals that are to be updated in a synchronous process. This is particularly relevant because every HDL design will be translated into  LUTs, MUXs, D-latches or registers.

The PSHDL syntax is fairly easy to understand and there is not much syntactical noise. The best thing about PSHDL is that it runs in the web browser! Just like the mBED initiative (for ARM micro-controllers), the pshdl.org website, proposes to create a workspace in which you can edit, compile (to VHDL) and debug your design all on-line. This means, no tools to install (still need to install the ISE/quartus tools to synthesize), OS independent (no problem with running it under Linux/Windows.  The community is rather small up until now, but the tool deserves a try!

Creating the PWM module using PSHDL

 

Below is the PSHDL code for the pwm module:


 

module de.tuhh.ict.pwmModule {

  @clock in bit clk;

  in uint<16> period, t_on;

  out bit pwm_out, period_end;

  register(clock=clk) uint<16> counter;

  if(counter > period){

    counter = 0;

    period_end = 1 ;

  }

  else{

    counter = counter + 1;

    period_end = 0;

  }

  if(counter > t_on){

   pwm_out = 0;

  }

  else{

    pwm_out = 1;

  }

}

 

Below is the VHDL code generated by PSHDL

 

library ieee;

use ieee.std_logic_1164.all;

use ieee.numeric_std.all;

use work.Casts.ALL;

use work.ShiftOps.ALL;

use work.Types.ALL;

entity de_tuhh_ict_pwmModule is

   port (

       rst : in std_logic;

       clk : in std_logic;

       period : in unsigned(15 downto 0);

       t_on : in unsigned(15 downto 0);

       pwm_out : out std_logic;

       period_end : out std_logic

   );

end;

 

architecture pshdlGenerated of de_tuhh_ict_pwmModule is

   signal counter : unsigned(15 downto 0);

begin

   process(counter, period, t_on)

   begin

       pwm_out <= '0';

       period_end <= '0';

       if (counter > period) then

           period_end <= '1';

       else

           period_end <= '0';

       end if;

       if (counter > t_on) then

           pwm_out <= '0';

       else

           pwm_out <= '1';

       end if;

   end process;

   process(clk)

   begin

       if RISING_EDGE(clk) then

           if rst = '1' then

               counter <= (others => '0');

           else

               if (counter > period) then

                   counter <= (others => '0');

               else

                   counter <= (counter + TO_UNSIGNED(1, 16));

               end if;

           end if;

       end if;

   end process;

end;


PSHDL lines to VHDL lines : 21 -> 51 = 0.41

Pro and cons

Pros :

  • Online tool ! No installation and is OS agnostic
  • Easy to use syntax for people who know C/C++
  • Clever use of the “register” keyword to denote sequential assignments
  • Outputs nicely formatted VHDL
  • Generated VHDL interfaces easily with existing VHDL code

Cons:

  • Online tool - some people may complain that its not great for privacy and intellectual property
  • Some syntax elements like the package prefix for a module create lengthy text
  • A “register” can be associated to a clock and reset by passing arguments to it. This is misleading for C/C++ programmers as it creates a type with an argument (and not a template like the other types) which is not valid C/C++ code.
  • Simulation does not seem to be fully functional in the online tool
  • The community is small (but can grow if you give it a try)

Conclusion

 

These two alternative HDL languages/tools do a great job to ease the process of  writing and debugging HDL. They both rely on different principles.  myHDL defines combinational/sequential functions while PSHDL defines sequential signals for the sequential behavior.  This allows you to pick what works best for you! The main drawback with both of these (tools and other alternatives languages) is that they are not directly supported in the vendor tools (Quartus/ISE) and that they are not recognized as standard hardware design languages in the professional world. This means that you will still have to learn VHDL/Verilog at some point if this is part of your career plan.

 

There is no indication that FPGA vendors are willing to open the access to their synthesis tools for third parties, so for any VHDL/Verilog alternatives you will still have to install and use their tools to synthesize and create the binary files to configure the FPGA.

 

One other language that tends to emerge as a standard for hardware (and system) design is SystemC (at least with Xilinx). While myHDL does not rely on any of the SystemC concepts, PSHDL has the advantage of being (to some extend) C/C++ based.

 

To get more people to use FPGAs there is a need to propose a large diversity of languages/tools. See the diversity of languages available to program microcontrollers. Some years ago you had to use C or assembler to design embedded software, but now you can use C/C++, Arduino (C++ based), javascript, Python and more.  We need the same kind of languages competition for HDL as each new language may attract more users and create new uses for FPGAs.

 

What features do you foresee being needed for a killer hardware description language? 


Creative Commons License

This work is licensed under a Creative Commons Attribution 4.0 International License.

  • Sign in to reply

Top Comments

  • Former Member
    Former Member over 10 years ago +1
    Nice write-up, but one important clarification. You can download a command line (offline) tool of PSHDL https://pshdl.org/releases/ or http://code.pshdl.org/pshdl.commandline/wiki/Home While the syntax…
  • johnbeetem
    johnbeetem over 10 years ago +1
    I don't like Verilog or VHDL. Given the choice, I mostly use Verilog since I don't want to type more than necessary and I have limited storage space for listings. My main problem with Verilog and VHDL…
  • jpiat
    jpiat over 10 years ago in reply to Former Member +1
    Thanks for the clarification on PSHDL, i'll edit the post. For PSHDL being C like but not C compatible, what i wanted to refelect is that learning a brand new syntax can be a hurdle to adoption, but the…
  • johnbeetem
    johnbeetem over 10 years ago in reply to bugless

    Stephen R. van den Berg wrote:

     

    So the only thing missing would be a GCHD to VHDL translator?

    My preference is to bypass the Xilinx tools and go directly from GCHD to FPGA bitstreams using free-as-in-freedom software.  I can do this with Flavia: the Free Logic Array, but only for small CPLD-size designs that don't have aggressive timing.  Running a small design through the Flavia software takes less than a second on a PC that takes a minute to run the same design through the Xilinx tools.  Plus Flavia runs on non-x86 computers like Raspberry Pi and BeagleBone.

     

    I am planning to have the option of going from GCHD to Verilog some day so that I can let Xilinx tools synthesize Boolean equations and do placement and routing.  This will allow large FPGA designs with aggressive timing to be expressed in GCHD, but requires using an x86 PC to run the Xilinx tools and requires the user to wait for those tools to run.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • bugless
    bugless over 10 years ago in reply to johnbeetem

    So the only thing missing would be a GCHD to VHDL translator?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jpiat
    jpiat over 10 years ago in reply to Former Member

    Thanks for the clarification on PSHDL, i'll edit the post. For PSHDL being C like but not C compatible, what i wanted to refelect is that learning a brand new syntax can be a hurdle to adoption, but the C like syntax of PSHDL for conditions, assignments and more makes it easier to learn. One problem with being C like but not fully C compatible (at least in the syntax, not in the semantic) is that you cannot use advanced features of C/C++ editors (syntax coloring, auto-compmletion, ...).

     

    You make a good point when saying that its becoming hard to compete with CPU. I personnaly use FPGA for research work and i keep getting people asking me why i use FPGA while CPU and GPU can do a good work for cheap for the problem i target. My answer is usually :

    - CPU and GPU are sub-optimal for a specific problem because of their general purpose structure

    - Only FPGA can guarantee fixe low-latency when the problem has real-time constraints

    - FPGA can be one step to ASIC design. When you considered the video decoder world a while back, it was all software. Now all media processor have specific computing structure for video-decoding that where once prototyped in FPGA.

     

    One problem i see with HLS, is that it may generate sub-optimal hardware because its behavior based, and it does not make sense. When doing FPGA you have to try to be optimal in every aspect of the design. Some people still think that you have to use ASM to program a micro-controller for the same reasons, so i may be wrong ...

     

    Based on your comments, maybe it would be great to start a HDL comparison page that would display the same example with all the available language (including GCHD). This could help create interest in alternatives languages and stop the VHDL/Verilog hegemony.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • johnbeetem
    johnbeetem over 10 years ago

    I don't like Verilog or VHDL.  Given the choice, I mostly use Verilog since I don't want to type more than necessary and I have limited storage space for listings.

     

    My main problem with Verilog and VHDL is that they were designed for simulation.  Synthesis was added as an afterthought.  It's quite difficult for an inexperienced user to know how to write Verilog to get the synthesizer (I mostly use Xilinx's XST) to create the logic the user wants.  XST matches "language templates" to find things like flip-flops, registers, and RAMs.  "Language templates" are hidden in ISE's Edit menu.  Many new users don't know about the templates, and merrily write Verilog or VHDL from textbooks and it simulates fine.  Then they try to synthesize and get frustrated.

     

    Here's how I write Verilog: I imagine what hardware I want, and then I write my Verilog to match the template for each piece of hardware.  This is basically compiling in reverse: you imagine the object code, and then write your source code so that the compiler does the right thing.  I'm probably better at this than most designers since I've written compilers and digital design tools, so it's easy for me to guess at what Xilinx tools do.

     

    Jonathan makes the comment "these languages can generate sub-optimal, faulty hardware which can be very difficult to debug."  This is quite true.  I'm able to create high-quality hardware using "reverse compilation" and fit complex functionality into inexpensive Spartan-3A chips, but if you write Verilog naïvely you are likely to end up with sub-optimal results.  This is actually advantageous to FPGA vendors and sales reps, because if your logic is too large and/or too slow, you need to use larger, faster, more expensive FPGAs to complete your design.  However, it's also disadvantageous because it makes people think twice about using FPGAs at all.

     

    The Xilinx tools make it hard to tell what the synthesizer actually generated, so if you made a mistake it's hard to track down, as Jonathan said.  If you're doing CPLD design, Xilinx lists the Boolean equations implemented by the macro cells.  There's no equivalent for FPGA design.  They do provide automatically-generated schematics, but IMO those are only useful for simple designs.

     

    My favorite commercial FPGA design language was Altera Hardware Description Language (AHDL).  It was basically registers and Boolean expressions, without any of this Verilog/VHDL behavioral nonsense.  So it was easy to tell AHDL what logic you wanted, and easy to look at the report and see that AHDL actually generated the correct logic.

     

    My favorite non-commercial FPGA design language is GalaxC for Hardware Design (GCHD), which is part of my 21st Century Co-design (XXICC) project [link].  GCHD is a work in progress, but you can read about it in The XXICC Anthology rev 0.0k if you're interested.  You can see some simple working GCHD examples in Flavia: the Free Logic Array.

     

    GCHD is an extension of the GalaxC Programming Language [Programming in the GalaxC Language rev 0.0j], and uses the same compiler for parsing and semantic analysis.  The GalaxC compiler calls module post-processing functions to convert GalaxC's intermediate language PSI (Postfix Stack Interpreter) into executable code for simulation, or logic networks for synthesis.  Unlike Verilog and VHDL, GCHD describes the hardware you want rather than the behavior you want.  Thus what you write is in a form that is easily synthesized.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • johnbeetem
    johnbeetem over 10 years ago in reply to Former Member

    Karsten Becker wrote:

     

    Maybe some-day we don't have to care about the costs of FPGA logic (both from a power and economic point of view), that this becomes viable. But so far even the use-cases for any FPGA are rather limited, or in other words: CPUs are becoming so powerful and cheap that it is hard to compete with them.

    I don't think we'll ever get to the point where we can ignore the cost of FPGA resources.  FPGA logic makes very inefficient use of transistors, especially for routing, so you really can't afford to use logic wastefully.  Block memory is also a precious resource, since the performance hit of going to off-chip memory is so high.

     

    However, I don't agree with it being hard to compete with CPUs -- on a hardware basis.  The advantage of a CPU is that you have a shared computing unit so it's cheap.  The disadvantage is that it's getting harder and harder to get data to that shared unit so that it can do something useful each clock cycle.  A lot of power is now consumed moving that data, with less and less power allocated to arithmetic and logical operations.  With an FPGA, you can pipe data through a computing fabric with short interconnects between operators so that less power and time is wasted by interconnections.

     

    The killer with FPGAs is software: with current vendor tools it's hard to design them well and requires a lot of experience and knowledge of FPGA architecture.  IMO problem gets worse each year.  The obvious solution is to open up the architecture so that others can write FPGA tools and languages, but the FPGA vendors don't seem to realize that they need to do this.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube