Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Modulus/reminder operation in FPGA

Status
Not open for further replies.

mjuneja

Advanced Member level 4
Joined
Aug 28, 2016
Messages
105
Helped
12
Reputation
24
Reaction score
10
Trophy points
18
Location
Bangalore, India
Activity points
674
I want to implement modulus or reminder operation in FPGA using VHDL for 2 unsigned nos. I tried using below code.


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
process(clk,rst,pxl_1,pxl_2,DV)
begin
    if(rst = '0') then
        pxl_o2 <= (others => '0');
    elsif(rising_edge(clk)) then
        if(DV = '1') then
            pxl_o2 <= std_logic_vector(unsigned(pxl_1) mod unsigned(pxl_2)); 
        end if; 
    end if;
end process;


but got the following error :-
: Operator <MODULUS> must have constant modulo operand.
Can anyone help me out with some alternate implementation of modulus operation.

Thanks
Madhur
 
Last edited by a moderator:

The question is incomplete. You should show the imported libraries and also tell about the used synthesis tool.

Usage of operator suggests that you are using ieee.numeric_std. Some tools are able to infer a parallel divider for the modulo operation with ieee.numeric_std library, e.g. Altera Quartus. Apparently yours doesn't, so you need to implement a divider component from vendor library.
 

I am using these 2 libraries for my design.

Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

and for synthesis I am using Xilinx XST tool available with ISE project navigator 14.7.
Which parallel divider component are you referring, can you elaborate more on this?
 

Look for Xilinx divider logicore. Maybe there's a way to get simple dividers without pipelining inferred with Xilinx tools as it's possible in Quartus, Xilinx users should tell.
 

Xilinx only supports 2^n divisions, i.e. right shifts.
 
  • Like
Reactions: mjuneja

    V

    Points: 2
    Helpful Answer Positive Rating

    mjuneja

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top