]> AND Private Git Repository - blast.git/blob - lib/implementations/rgb3sx8_to_gs_impl.xml
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
nearly finished GroupBlock VHDL gen
[blast.git] / lib / implementations / rgb3sx8_to_gs_impl.xml
1 <!DOCTYPE rgb3sx8_to_gs>
2 <block_impl ref_name="rgb3sx8_to_gs.xml" ref_md5="">
3   <comments>
4     <author lastname="" mail="" firstname=""/>
5     <date creation="2018-01-10"/>
6     <related_files list=""/>
7     <description>fez</description>
8     <notes>fez</notes>
9   </comments>
10   <libraries>
11     <library name="ieee">
12       <package name="std_logic_1164" use="all"/>
13       <package name="numeric_std" use="all"/>
14     </library>
15   </libraries>
16   <architecture>
17 -- Signals
18 signal do_mult : std_logic;
19 signal do_out : std_logic;
20 signal count : unsigned (2 downto 0);
21 signal accum : unsigned(dsp_in_width-1 downto 0);
22 signal result : unsigned(dsp_out_width-1 downto 0);
23 signal cst_mult : unsigned(dsp_in_width-1 downto 0); -- eq. 87382 to do /3
24
25 begin
26
27 cst_mult &lt;= to_unsigned(87382, 18);
28
29 accum_process : process (@{clk}, @{reset})
30 begin
31 if @{reset} = '1' then
32 count &lt;= to_unsigned(0, 3);
33 accum &lt;= to_unsigned(0, dsp_in_width);
34 do_mult &lt;= '0';
35
36 elsif rising_edge(@{clk}) then
37
38 do_mult &lt;= '0';
39
40 if @{rgb_in_enb} = '1' then
41
42 if count = 0 then
43 accum &lt;= resize(unsigned(@{rgb_in}), dsp_in_width);
44 count &lt;= to_unsigned(1, 3);
45 elsif count = 1 then
46 accum &lt;= accum + resize(unsigned(@{rgb_in}), dsp_in_width);
47 count &lt;= to_unsigned(2, 3);
48 elsif count = 2 then
49 accum &lt;= accum + resize(unsigned(@{rgb_in}), dsp_in_width);
50 count &lt;= to_unsigned(0, 3);
51 do_mult &lt;= '1';
52 end if;
53 end if;
54 end if;
55
56 end process accum_process;
57
58 mult_process : process (@{clk}, @{reset})
59 begin
60 if @{reset} = '1' then
61 result &lt;= to_unsigned(0, dsp_out_width);
62 do_out &lt;= '0';
63 elsif rising_edge(@{clk}) then
64
65 do_out &lt;= '0';
66 if do_mult = '1' then
67 result &lt;= accum * cst_mult;
68 do_out &lt;= '1';
69 end if;
70 end if;
71 end process mult_process;
72
73 @{gs_out} &lt;= std_logic_vector(result(dsp_in_width+7 downto dsp_in_width));
74 @{gs_out_enb} &lt;= do_out;
75 </architecture>
76   <patterns>
77     <delta value="3"/>
78     <consumption>
79       <input pattern="111" name="rgb_in_enb"/>
80     </consumption>
81     <production counter="3">
82       <output pattern="00001" name="gs_out_enb"/>
83     </production>
84   </patterns>
85 </block_impl>