[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] HDL coding rules



Hi,

I have forgot some thing

Just an Illusion wrote:

> Hi,
>
> Yann Guidon wrote:

<cut>

>>
>> maybe you can look at the code and see yourself.
>>
> Ok, I have done it.
>
> Please, Etienne forgive me, but your code can be a good example to 
> illustrated this subject.
>
> In the eu_inc.vhd file :
>
> * some keywords are in capital letter, some others not.
> * The generic parameter eu_inc_width can be put in capital letter, to 
> help distinction with signal and variable value.
> * The interface signals aren't globally in capital letter except for 
> function  abs_chunk.
>
> That doesn't change the result, but can help the code reading.
>
> The next remark is not a "coding rule", but more a "coding style" rule.
>
> I thing is better if you create a package which embedded all the 
> necessary component (and perhaps functions) needed for your eu_inc and 
> eu_cmp rather than "use work.find_lsb;" notation.

I have an other one (coding style) :

Defined each value of eu_inc_mode by a constant, and use them into the 
case structure. Something like :
...
architecture simple of eu_inc is
...
 constant C_EU_INC_MODE_NEG  : natural := "000"
 constant C_EU_INC_MODE_DEC   : natural := "001"
 constant C_EU_INC_MODE_INC    : natural := "010"
 constant C_EU_INC_MODE_ABS   : natural := "011"
 constant C_EU_INC_MODE_LSB0 : natural := "100"
 constant C_EU_INC_MODE_LSB1 : natural := "101"
...
begin
...
   eu_inc_in : process(eu_inc_A, eu_inc_simd, eu_inc_mode) is
   begin
     -- Input of unit
     case eu_inc_mode is
        when C_EU_INC_MODE_NEG   => tree_in <= not eu_inc_A;
        when C_EU_INC_MODE_DEC   => tree_in <= not eu_inc_A;
        when C_EU_INC_MODE_INC    => tree_in <= eu_inc_A;
        when C_EU_INC_MODE_ABS    => tree_in <= not eu_inc_A;
        when C_EU_INC_MODE_LSB0  => tree_in <= eu_inc_A;
        when C_EU_INC_MODE_LSB1  => tree_in <= not eu_inc_A;
        when others => tree_in <= eu_inc_A;
     end case;
   end process;
...

Now, if you want change the eu_inc_mode coding values, you need modify 
it only in one place.

See the coding rule I have use to immediatly link (when read) the 
constant value with the content of eu_inc_mode.

>
>>
>>> Cheers,
>>> Just an Illusion
>>>
>> WHYGEE
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> *************************************************************
>> To unsubscribe, send an e-mail to majordomo@seul.org with
>> unsubscribe f-cpu       in the body. http://f-cpu.seul.org/
>>
> Just an Illusion
>

-- 
______________________________
"The matrix is my world, I am a shadow.
Shadow in world, shadow in life. Don't try to keep me,
I am a Corpo's Killer.
Don't follow me or die..."
		The KingWalker - 1996



*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/