Wednesday 20 September 2017

How to write a simple VHDL Code?


VLSI projects in Chennai :

How to write a simple VHDL Code:

  • Writing a VHDL Code become easy when you are more aware about how the digital elements are working.
  • Digital Elements in the sense i am meaning that digital logic such as gate,flip flops,adders, counter etc
  • In all the digital circuits the most important input element is the clock and global reset or we call it as Hardware reset
  • Before writing a vhdl code for any digital circuit first keep in mind about the flow of clock and control of reset 
  • In my upcoming post i will teach you how to handle those clocks and reset in best way
  • For writing a VHDL code for simple clocked D-flip flop, you need the inputs clock, reset, input d and output q, qbar
  • First plan for a Truth table which will help you understand the input outputs or understand the waveforms or we call it as timing diagram
  • for a simple d-flip flop, the output may be ZERO or ONE which depends upon either the rising edge of the clock or falling edge of the clock
  • Consider if its rising edge, for every rising edge of the clock signal, the input d is kept open ported which means whatever signal input available at D is transferred to q output 
  • The invert of the q is qbar which is also triggered at every rising edge of the clock

Consider the Logic circuit below & Equivalent code too

 

CODE:

< Write Library file >

architecture behave of dff is

begin

dff_block:process(clk,rst)
begin
if rst='1' then
 q<='0';
qbar<='0';
elsif rising_edge(clk) then
q<=d;
qbar<=not d;
end if;
end process dff_block;
end architecture behave;


This is just a simple way of writing a vhdl code for Dflip flop

Key points about D-ff
  • Edge sensitive device
  • Used as a Buffer in fast flowing data path
  • Used as gated flip flop where glitches occurs
  • Low power device
  • Helpful for generating clocks by designing counters
 
For more details & sample codes help contact us!!!




GREETINGS