cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
asai9493
Adventurer
Adventurer
673 Views
Registered: ‎12-10-2020

VHDL : Multiple Declarations of one Component

Hello everyone!

Hope that you are staying healthy and at a safe place, despite the ongoing lockdown.

I have a problem with a component declaration.

In the simulation I am going to use one component two times.

 PS I dont want to rewrite the component and create two input and two output signals.

I declare the component two times as :

```

 

U_FIR_1 : FIR -- inphase signal
PORT MAP
(
input => input_inphase,
out => out_inphase
);

U_FIR_2 : FIR-- quadrature
PORT MAP
(
input => input_quadrature,
out => out_quadrature
);

 


```

in the main process, I have to define the inputs of the `U_FIR_1` ( is `input_quadrature`) and `U_FIR_2 ` ( is `input_quadrature`) .

 

```

 

-- For U_FIR_1
input <= input_quadrature; ???
-- For U_FIR_2
input <= input_inphase; ???

 

```

Is it possible to declare the component (FIR) 2 times ( as I have described above)?

0 Kudos
16 Replies
bruce_karaffa
Scholar
Scholar
662 Views
Registered: ‎06-21-2017

Do you mean something like this?

FirI_d1 : dec1_101t_16ch
  PORT Map(
    aresetn                         => FIR1_resetn,
    aclk                            => clk200,
    s_axis_data_tvalid              => input_tvalid,
    s_axis_data_tready              => input_tready,
    s_axis_data_tuser               => input_tuser,
    s_axis_data_tdata               => input_inphase,
    m_axis_data_tvalid              => output_tvalid,
    m_axis_data_tuser               => output_tuser,
    m_axis_data_tdata               => output_inphase,
    event_s_data_chanid_incorrect   => chanid_incorrect
  );

FirQ_d1 : dec1_101t_16ch
  PORT Map(
    aresetn                         => FIR1_resetn,
    aclk                            => clk200,
    s_axis_data_tvalid              => input_tvalid,
    s_axis_data_tready              => OPEN,
    s_axis_data_tuser               => input_tuser,
    s_axis_data_tdata               => input_quadrature,
    m_axis_data_tvalid              => OPEN,
    m_axis_data_tuser               => OPEN,
    m_axis_data_tdata               => output_quadrature,
    event_s_data_chanid_incorrect   => OPEN
  );
0 Kudos
asai9493
Adventurer
Adventurer
656 Views
Registered: ‎12-10-2020

@bruce_karaffa I did the same in my simualtion. My doubt is I dont know how to define the input signals of two components in the main process.

 

0 Kudos
bruce_karaffa
Scholar
Scholar
630 Views
Registered: ‎06-21-2017

I don't understand your question.  Are you asking how to define input_inphase and input_quadrature?  What is the input to your top level process?  Does the input to the top level process come in on the same clock that the filters are using?  The filters are using a clock, right?   Are input_inphase and input_quadrature signed, unsinged, std_logic_vectors or something else? 

0 Kudos
drjohnsmith
Teacher
Teacher
629 Views
Registered: ‎07-09-2009

Are you mixing up instantiating and declaration ?

http://freerangefactory.org/pdf/df344hdh4h8kjfh3500ft2/free_range_vhdl.pdf

 

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
asai9493
Adventurer
Adventurer
557 Views
Registered: ‎12-10-2020

@bruce_karaffa 

FIR is a function ( another .vhd file), which I use two time. I apply it for a signal "input_inphase" and for a signal "input_quadrature". 

I added two signal (new version):

 

signal fir_filter_input_inphase    : std_logic_vector ( (bits-1) downto 0);
signal fir_filter_input_quadrature : std_logic_vector ( (bits-1) downto 0);

 

 

and in the CLK process:

 

 

if (counter = 0) then
    fir_filter_input_quadrature <= input_quadrature;
    fir_filter_input_inphase    <= input_inphase;
                 
--                 input_quadrature<= input_quadrature;
--                 input_inphase<= input_inphase;
 else
              --if the counter is not equal tp 0 a 0 goes into the output,
    fir_filter_input_quadrature <= (others => '0');
    ir_filter_input_inphase    <= (others => '0');

 

 

My goal : add zero-valued samples between the samples and then filtere  the signal ( I have two signal)

 

and I have changed

U_FIR_1 : FIR -- inphase signal
PORT MAP
(
input => fir_filter_input_inphase,
out => out_inphase
);

U_FIR_2 : FIR-- quadrature
PORT MAP
(
input => fir_filter_input_quadrature ,
out => out_quadrature
);

 

 

 

 

0 Kudos
drjohnsmith
Teacher
Teacher
543 Views
Registered: ‎07-09-2009

is FIR a function in another file, or is it another entity ?

Did you read that free download on VHDL , 

The problem Im seeing 

    is that you are trying to describe a technical question, using the correct language , but the wrong words, 

         so we are at best confused, at worst liable to offer you the wrong advise.

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
viviany
Xilinx Employee
Xilinx Employee
537 Views
Registered: ‎05-14-2008

Your new version of code looks good.

You can run simulation to verify the function.

-------------------------------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos
asai9493
Adventurer
Adventurer
509 Views
Registered: ‎12-10-2020

@drjohnsmith @bruce_karaffa @viviany 

Thank you, I understand how I can fix it.

As you have already probably understand, I am using "counter" to add 0s into input signals.

counter:= counter + 1;
--if the counter is 0 a data sample goes into the output,
if (counter = 0) then
    fir_filter_input_quadrature <= input_quadrature;
    fir_filter_input_inphase    <= input_inphase;
else
 --if the counter is not equal tp 0 a 0 goes into the output,
     fir_filter_input_quadrature <= (others => '0');
     fir_filter_input_inphase    <= (others => '0');
end if;  -- if(counter=0) then
 --if the counter is > 3 ( M = 4), 
if (counter > ( M - 1)) then
counter:= 0;
end if;

 

it is a part of the second file " IntFiR" ( the first one is FIR). IntFiR adds 0s between two adjacent elements of the input vectors and creates the new inputs for FIR file.

I am trying to merge two files in one and have only one FIR, which will add 0s and filters the signals. My idea is to use clk instead of counter. " the data is available only in each 4s clk..." smth like this.

Is it possible to implement in vhdl? if yes, could you provide me some example of such simulation?

 

 

0 Kudos
bruce_karaffa
Scholar
Scholar
504 Views
Registered: ‎06-21-2017

@asai9493 What you are describing is an interpolating filter with two parallel paths.  While writing your own is a good learning experience, the FIR Compiler Product Guide (PG149) describes exactly this.  The FIR IP is resource efficient and in most cases, fairly easy to use.  It is worth the time lo look into the FIR Compiler.

drjohnsmith
Teacher
Teacher
483 Views
Registered: ‎07-09-2009

so how are you defining counter, Std_logic_vector, integer, unsigned ?

the if counter = 0 line is implementing a wide gate , depending upon the counter width,

    you would probably be better off decoding the counter max value, i.e. th eone beofre 0, and generating a logic '1', for one clock, which is registered to arrive at same time as counter = 0 would,

    this would give you a nice compact, de glitched control signal for the wide input MUX you have created.

If you can convert the MUX to a synchronous MUX, i.e. with a clock also better, 

 it adds to the pipeline delay , but will make routing and timing much easier,

  You already have a huge delay through thr FIR, so I'd say that a few more clocks will not matter to your design.

I'm also guessing that your FIR is not a VHDL function , but a VHDL entity which your instantiating in a higher level architecture,

   As such ,  FIR can be instantiated any number of times in the higher architecture.

Its good to get the correct wording form the beginning, it helps every one.

Note, if you instantiate two FIRs, then you will double the amount of logic in the FPGA. 

   this may or may not be what you intend.

You can think of instantiation like putting chips into sockets,

   Once ou have defined the chip, you can put many of the same type into a board.

https://www.doulos.com/knowhow/vhdl/chips-into-sockets/

 

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
maps-mpls
Mentor
Mentor
465 Views
Registered: ‎06-20-2017

>Did you read that free download on VHDL

You get what you pay for.  The book by a "he/him/his" is as silly as thinking it necessary to tell me he is a he.  Please look for a better book to recommend.

*** Destination: Rapid design and development cycles *** Unappreciated answers get deleted, unappreciative OPs get put on ignored list ***
0 Kudos
maps-mpls
Mentor
Mentor
454 Views
Registered: ‎06-20-2017

>My goal : add zero-valued samples between the samples and then filtere the signal  - @asai9493 

Just upload your code.  It's probably not as valuable as you might think, has been done better by a lot of engineers, and it will allow us to help you better.

With the snippets you posted, it sounds like you're trying to do an interpolating upsampling filter and are on the right track.  The only thing I would do differently is to generate a CE based on the counter.  Xilinx calls it a CE for "clock enable" but it is really a "data enable"--sometimes they call it "chip enable". 

In any event, something like this (not syntax checked) might be useful:

  constant kMAX_CNT : integer := 4; -- set to whatever the interpolation rate is
  signal   counter  : integer range 0 to kMAX_CNT - 1 := 0;

begin -- architecture 

  PROC_GEN_CE : process (iClk)
  begin
    if (rising_edge(iClk)) then
      if((kMAX_CNT -1) = counter) then      
        counter <= 0;
        myce    <= '1';
      else
        counter <= counter + 1;
        myce    <= '0';
      end if;
  end process PROC_GEN_CE;
  
  PROC_ZERO_STUFF : process (iClk)
  begin
    if (rising_edge(iClk)) then
      if('1' = myce) then
        fir_filter_quadrature <= input_quadrature; -- assumes stable, may need input valid and pipelining depending on your actual design
        fir_filter_inphase    <= input_inphase;
      else -- the CE in this case muxes between valid data and constant literal 0s, so it will probably infer a synchronous reset
        fir_filter_quadrature <= (others => '0');
        fir_filter_inphase    <= (others => '0');
      end if;
    end if;
  end process PROC_ZERO_STUFF;

 I am assuming you're just trying to learn.  If this were a real problem, I agree with @bruce_karaffa to go first to the IP catalog, and add you should also take a look at UG901 in docNav as it has FIR code you can compare yours against.

*** Destination: Rapid design and development cycles *** Unappreciated answers get deleted, unappreciative OPs get put on ignored list ***
asai9493
Adventurer
Adventurer
391 Views
Registered: ‎12-10-2020

@drjohnsmith 

so how are you defining counter, Std_logic_vector, integer, unsigned ?

I defined it as 

variable counter : integer range 0 to (M - 1) := 0;

 

I cant use FIR IP, my task is implementation of FIR interpolation filter.  "FIR" is my implementation of the filter with adders, multipliers und shift datas.

0 Kudos
asai9493
Adventurer
Adventurer
389 Views
Registered: ‎12-10-2020

@maps-mpls @drjohnsmith @bruce_karaffa @viviany 

I have added my simulation of the interpolation. it was implemented as 2 files: filter and interpolation ( counter, add 0s ).

I am trying to merge them and using clk in filter to add 0s

 

0 Kudos
asai9493
Adventurer
Adventurer
388 Views
Registered: ‎12-10-2020

@maps-mpls 

  signal   counter  : integer range 0 to kMAX_CNT - 1 := 0;

 

Should it be after the following line ?

 

 

architecture Behavioral of FIR is

 

 2)  myce, should be defined in "entity" as 

 

myce : out std_logic;

 

?

 

0 Kudos
asai9493
Adventurer
Adventurer
387 Views
Registered: ‎12-10-2020

@maps-mpls 

>I am assuming you're just trying to learn.  If this were a real problem, I agree with @bruce_karaffa to go first to the IP catalog, and add you should also take a look at UG901 in docNav as it has FIR code you can compare yours against.

I have seen FIR in IP catalog, but I cant use it. I have to implement it without IP catalog. I can use IP catalog for math functions

 

0 Kudos