top of page

व्यवहारिक (Behavioral) मॉडलिंग

Behavioral Modeling क्या है:

Behavioral modeling को “behavioral” इसलिए कहा जाता है क्योंकि यह दिखाता है कि अलग-अलग इनपुट पर सर्किट कैसे behave करता है।

इस स्टाइल में हम यह नहीं बताते कि अंदर कौन-कौन से गेट जुड़े हैं या उसकी संरचना (structure) क्या है।

हम सिर्फ सर्किट के नियम या शर्तें लिखते हैं, जैसे — अगर दोनों इनपुट 1 हैं तो आउटपुट 1 होगा, वरना आउटपुट 0 होगा।

इसका फोकस functionality पर होता है, न कि यह कैसे बनाया गया है।

असल gate-level implementation बाद में synthesis tool तय करता है।

इसीलिए इसे behavioral modeling कहा जाता है।

एक उदाहरण (Analogy)

मान लो आपके पास पंखे का रिमोट है:

  • अगर आप 1 दबाते हैं → पंखा धीरे चलेगा।
     

  • अगर आप 2 दबाते हैं → पंखा थोड़ा तेज़ चलेगा।
     

  • अगर आप 3 दबाते हैं → पंखा और तेज़ चलेगा।
     

  • अगर आप 0 दबाते हैं → पंखा बंद हो जाएगा।
     

यहाँ आप सिर्फ इतना बता रहे हैं कि कौन-सा बटन दबाने पर क्या होगा।
आप यह नहीं बता रहे कि रिमोट के अंदर कौन-सी चिप लगी है, कौन-सी वायर लगी है, या मोटर कैसे जुड़ा है।

यही behavioral modeling का आइडिया है: आप सिर्फ व्यवहार (rules) बताते हैं, अंदर की structure नहीं।

Behavioral Modeling क्यों:

मान लीजिए 8×1 multiplexer है।

  • हमें बस उसकी functionality से मतलब है।
     

  • हमें यह नहीं जानना कि अंदर कौन-से गेट जुड़े हैं या कैसे connect हुए हैं।
     

  • असली बात यह है कि हर select line value पर कौन-सा इनपुट आउटपुट पर आएगा।
     

इसीलिए इसे behavioral modeling कहते हैं: हम behavior (rules) बताते हैं, structure नहीं।

यहाँ हम process के अंदर case statement का उपयोग करते हैं। Case सीधे बता देता है कि किस इनपुट condition पर आउटपुट क्या होगा।

Behavioral modeling तब इस्तेमाल करते हैं जब हमें सर्किट की functionality पता हो और यह पता हो कि वह functionality किन इनपुट और आउटपुट पर depend करती है।

हमें “black box” के अंदर क्या हो रहा है इसकी चिंता करने की ज़रूरत नहीं होती, क्योंकि वह synthesis / EDA tool की जिम्मेदारी है।

ज्यादातर डिज़ाइन इसी स्टाइल में लिखे जाते हैं, क्योंकि डिज़ाइनर को बस functional specification और working पता होनी चाहिए।

एक ज़रूरी बात: behavioral code हमेशा process statement के अंदर लिखा जाता है, जिसमें sensitivity list होती है। इसमें वे इनपुट होते हैं जिनसे आउटपुट बदलता है।

Behavioral Modeling का उपयोग कैसे करें:

Verilog

library ieee;

use ieee.std_logic_1164.all;

entity mux8x1 is

    port (

        sel : in  std_logic_vector(2 downto 0); -- 3-bit select input

        i0  : in  std_logic;

        i1  : in  std_logic;

        i2  : in  std_logic;

        i3  : in  std_logic;

        i4  : in  std_logic;

        i5  : in  std_logic;

        i6  : in  std_logic;

        i7  : in  std_logic;

        y   : out std_logic

    );

end entity mux8x1;

 

architecture behavioral of mux8x1 is

begin

    process(sel, i0, i1, i2, i3, i4, i5, i6, i7)

    begin

        case sel is

            when "000" => y <= i0;

            when "001" => y <= i1;

            when "010" => y <= i2;

            when "011" => y <= i3;

            when "100" => y <= i4;

            when "101" => y <= i5;

            when "110" => y <= i6;

            when "111" => y <= i7;

            when others => y <= '0';  -- default (safety)

        end case;

    end process;

end architecture;

VHDL में case statement का syntax लगभग C language के switch–case जैसा ही है।

फर्क:

  • जब inputs ज़्यादा होते हैं, if–else से nested structure वाले mux बनते हैं। इससे propagation delay बढ़ता है क्योंकि आउटपुट कई levels से होकर आता है।
     

  • Case statement में tool एक single multiplexer बनाता है, जो तेज़ होता है और delay कम होता है।
     

  • If–else chain में पहला condition high priority पर होता है और tool उन्हें एक-एक करके check करता है।
     

  • Case statement में सारे options बराबर माने जाते हैं, और output जल्दी decide हो जाता है।
     

इसीलिए case ज़्यादा inputs होने पर prefer किया जाता है।

Note:

Synthesizer कभी-कभी if–else और case दोनों को same hardware में optimize कर देता है। लेकिन conceptually →

  • case balanced होता है (no priority)
     

  • if–else priority-based होता है।
     

Case Statement को MUX के साथ समझना

यहाँ हमें सिर्फ MUX की functionality और उसके inputs से मतलब है।

एक multiplexer को दो तरीकों से लिखा जा सकता है:

  1. if–else statements से
     

  2. या case statement से

1. VHDL semantics

  • If–else और case दोनों ही sequential statements हैं।
     

  • मतलब ये process के अंदर एक-एक करके execute होते हैं।
     

  • कोई भी statement “एक साथ सारे conditions check” नहीं करता।
     

2. असली फर्क

  • If–else chain: conditions क्रम से check होती हैं। जो पहले true हो गया वही लिया जाता है → priority logic बनती है।
     

  • Case statement: selector value सारे choices से compare होती है, लेकिन सिर्फ एक match होता है → priority नहीं होती।
     

3. क्यों कहा जाता है “case सारे inputs एक साथ check करता है”

यह hardware के नज़रिए से समझाया जाता है:

  • If–else → priority multiplexer (nested levels)।
     

  • Case → balanced multiplexer (सारे inputs एक mux block में जुड़े)।

  • Simulation में दोनों sequential हैं।
     

  • Hardware में if–else → priority chain, case → balanced mux।
     

Code (4×1 MUX using if–else):

Verilog

library ieee;

use ieee.std_logic_1164.all;

 

entity mux4_if is

    port (

        sel : in  std_logic_vector(1 downto 0); -- select lines (MSB = sel(1))

        i0  : in  std_logic;

        i1  : in  std_logic;

        i2  : in  std_logic;

        i3  : in  std_logic;

        y   : out std_logic

    );

end entity mux4_if;

 

architecture behavioral of mux4_if is

begin

    process(sel, i0, i1, i2, i3)

    begin

        if sel = "00" then

            y <= i0;

        elsif sel = "01" then

            y <= i1;

        elsif sel = "10" then

            y <= i2;

        else

            y <= i3; -- when "11" or others treated as i3

        end if;

    end process;

end architecture behavioral;

HARDWARE:

vivado_if_eles.png

Verilog

library ieee;

use ieee.std_logic_1164.all;

 

entity mux4_case is

    port (

        sel : in  std_logic_vector(1 downto 0); -- select lines

        i0  : in  std_logic;

        i1  : in  std_logic;

        i2  : in  std_logic;

        i3  : in  std_logic;

        y   : out std_logic

    );

end entity mux4_case;

architecture behavioral of mux4_case is

begin

    process(sel, i0, i1, i2, i3)

    begin

        case sel is

            when "00" => y <= i0;

            when "01" => y <= i1;

            when "10" => y <= i2;

            when "11" => y <= i3;

            when others => y <= '0'; -- safety default

        end case;

    end process;

end architecture behavioral;

HARDWARE:

Vivado01.png

 इसलिए case statement hardware में ऐसा बनता है जहाँ parallel inputs directly जाते हैं और output जल्दी मिलता है।

If–Else कब use करें और Case कब:

🔹 If–Else

  • जब priority logic चाहिए।
     

  • Example: traffic light controller — अगर reset=1 है तो output reset होना चाहिए, बाकी signals बाद में check हों।
     

  • Synthesizer → priority chain (nested muxes)।
     

🔹 Case

  • जब कई choices हों और सब equal हों (no priority)।
     

  • Example: Multiplexer — sel = 00/01/10/11 तय करता है कि कौन-सा input output बनेगा।
     

  • Synthesizer → single balanced mux (faster, cleaner)।
     

Process/Sequential Statement

Structural Modeling

© Copyright 2025 VLSI Mentor. All Rights Reserved.©

Connect with us

  • Instagram
  • Facebook
  • Twitter
  • LinkedIn
  • YouTube
bottom of page