Quantcast
Channel: Altera Forums
Viewing all 19390 articles
Browse latest View live

LED to clock in Register

$
0
0
How to blink clock (CLK) in register?
Register code
Code:

module reg8 (CLK, D, Q);
input CLK;
input  [7:0]  D;
output [7:0]  Q;
reg [7:0] Q;
always @(posedge CLK)
Q = D;
endmodule

Can i assign output LED = CLK?
Code:

output LED;
...
assign LED = CLK;


Issues with expanding Intel FPGA Sobel Filter example to include Median Filter.

$
0
0
Hi,

I am currently developing on the FPGA Cyclone V board. I have successfully ran the 3x3 sobel filter kernel example, and have expanded this to include a 5x5 example successfully also. I decided I would like to include a median filter to remove noise prior to doing the 5x5 sobel filter. I have also successfully got an output from the median filter. However when I try to implement the two, I get strange results. The code is below.

Code:


#include "../host/inc/imageDims.h"


__kernel
void laplacian33(global unsigned int * restrict frame_in,
          global unsigned char * restrict frame_out,
          const int totalpixels)
{
    //Define convolution matrix
    int h_n_x[3][3] = {{-1,-2,-1},{0,0,0},{1,2,1}};
    int h_n_y[3][3] = {{-1,0,1},{-2,0,2},{-1,0,1}};


    char set_white = 0xff;
    char set_black = 0x00;


    // Pixel buffer of 2 columns and 3 extra pixels
    int pix_buff[3 * COLS + 3];


    // Initial iterations initialize the pixel buffer
    int count = -(3 * COLS + 3);


    //Iterator of the output index for greyscale PGM image
    int outIndex = 0;


    while (count != totalpixels) {


    //Fill pixel buffer
    #pragma unroll
        for (int i = 3 * COLS + 2; i > 0; --i) {
            pix_buff[i] = pix_buff[i - 1];
        }
        pix_buff[0] = count >= 0 ? frame_in[count] : 0;


        //Initialise greyscale variable.
        char grey_scale_x = 0x00;
    char grey_scale_y = 0x00;


        //Compute one convolution each cycle
        #pragma unroll
        for (int filterRow = 0; filterRow < 3; ++filterRow) {


            #pragma unroll
            for (int filterCol = 0; filterCol < 3; ++filterCol) {


        //Get the current pixel
                unsigned int pixel = pix_buff[filterRow * COLS + filterCol];


                unsigned char b = pixel & 0xff0000;
                unsigned char g = pixel & 0x00ff00;
                unsigned char r = pixel & 0x0000ff;
   
            //Approximate version, simply apply a ratio and shift
                unsigned char luma_apprx = ((2 * r) + b + (3 * g)) >> 3;
           
            //Typecast luma as a char and perform convolution
            grey_scale_x += (char)luma_apprx*h_n_x[filterRow][filterCol];
            grey_scale_y += (char)luma_apprx*h_n_y[filterRow][filterCol];


            }
        }


    int sobel_mag = abs(grey_scale_x) + abs(grey_scale_y);
    if(sobel_mag > 0xff) sobel_mag = set_white;
    else if(sobel_mag < 0x00) sobel_mag = set_black;


        if(outIndex != totalpixels) {
            frame_out[outIndex++] = sobel_mag; //Write byte, iterate index
        }


        count++;  //Iterate overall count
    }


}


__kernel
void laplacian55(global unsigned int * restrict frame_in,
          global unsigned char * restrict frame_out, global unsigned char * restrict frame_median,
          const int totalpixels)
{
    //Define convolution matrix
    int h_n_x[5][5] = {{2,2,4,2,2},
                      {1,1,2,1,1},
                      {0,0,0,0,0},
              {-1,-1,-2,-1,-1},
              {-2,-2,-4,-2,-2}};


    int h_n_y[5][5] = {{2,1,0,-1,-2},
                    {2,1,0,-1,-2},
                    {4,2,0,-2,-4},
            {2,1,0,-1,-2},
            {2,1,0,-1,-2}};


unsigned char median_matrix[5][5];
int height = 5;
int width = 5;
int value = 0;
int median = 0;
unsigned char array[25];


    char set_white = 0xff;
    char set_black = 0x00;


    // Pixel buffer.
    int pix_buff[5 * COLS + 3];
    int pix_buff_2[5 * COLS + 3];


    // Initial iterations initialize the pixel buffer
    int count = -(5 * COLS + 3);
    int sobelCount = -(5 * COLS + 3);


    //Iterator of the output index for greyscale PGM image
    int sobel_outIndex = 0;
    int outIndex = 0;
       
    //Initialise greyscale variable.
        char grey_scale_x = 0x00;
    char grey_scale_y = 0x00;


    int filterRow;
    int filterCol;
    unsigned char sobelPixel = 0x00;

    while (count != totalpixels) {

    //Fill pixel buffer
    #pragma unroll
        for (int i = 5 * COLS + 2; i > 0; --i) {
            pix_buff[i] = pix_buff[i - 1];
        }
        pix_buff[0] = count >= 0 ? frame_in[count] : 0;

    //Get values and find median each cycle
        #pragma unroll
        for (filterRow = 0; filterRow < 5; ++filterRow) {

            #pragma unroll
            for (filterCol = 0; filterCol < 5; ++filterCol) {

        //Get the current pixel
                unsigned int pixel = pix_buff[filterRow * COLS + filterCol];

        //Retrieve the individual bytes of pixel by masking.

                unsigned char b = pixel & 0xff0000;
                unsigned char g = pixel & 0x00ff00;
                unsigned char r = pixel & 0x0000ff;

          //Convert 3 bytes of RGB --> 1 byte of greyscale data
            unsigned char luma_apprx = ((2 * r) + b + (3 * g)) >> 3;
   
          //Store appropriate grey level in median matrix
          median_matrix[filterRow][filterCol] = luma_apprx;

            }

        }

//Convert 2d array to 1d vector
for(int rows = 0; rows < 5; rows++) {
    for(int cols = 0; cols < 5; cols++) {
        array[width * rows + cols] = median_matrix[rows][cols];
    }
}

//Sort array
    for(int x = 0; x < 25; x++){
        for(int y = 0; y < 24; y++){
            if(array[y]>array[y+1]){
                int temp = array[y+1];
                array[y+1] = array[y];
                array[y] = temp;
            }
        }
    }

    //Get median
    median = array[12];

      //Write the total number of greyscale bytes
      if(outIndex != totalpixels) {
      frame_median[outIndex++] = median; //Write byte, iterate index
      }
      count++;  //Iterate overall count
    }

    //Do the same, but this time use sobel filter..
    while (sobelCount != totalpixels) {

    //Initialise pixel buffer for sobel
    #pragma unroll
        for (int z = 5 * COLS + 2; z > 0; --z) {
            pix_buff_2[z] = pix_buff_2[z - 1];
        }

    //Fill buffer with median data
        pix_buff_2[0] = sobelCount >= 0 ? frame_median[sobelCount] : 0;

        //Compute one convolution each cycle
        #pragma unroll
        for (filterRow = 0; filterRow < 5; ++filterRow) {

            #pragma unroll
            for (filterCol = 0; filterCol < 5; ++filterCol) {

        //Get the current pixel
                sobelPixel = pix_buff_2[filterRow * COLS + filterCol];

            grey_scale_x += (char)sobelPixel*h_n_x[filterRow][filterCol];
            grey_scale_y += (char)sobelPixel*h_n_y[filterRow][filterCol];

            }
        }

//Threshold
int magnitude = abs(grey_scale_x) + abs(grey_scale_y);

    if(magnitude > 255) magnitude = set_white;
else if(magnitude < 0) magnitude = set_black;
     
      //Write the total number of greyscale bytes
      if(sobel_outIndex != totalpixels) {
      frame_out[sobel_outIndex++] = magnitude;
      }

      sobelCount++;  //Iterate overall count
    }

}

I think I have pinpointed the problem to be with the line of code:

Code:

sobelPixel = pix_buff_2[filterRow * COLS + filterCol];
Since changing this makes the output look different each time. I think this is because of the "boundary pixels", so the image reduces in size after the median filter, and there are no longer COLS number of columns in the resulting image to be processed by the sobel filter. However, I am struggling to find the correct algorithm to index the "current pixel" to get the correct filtered output. Could anyone please assist with this bug?

Kind regards

How was fpga.dts on de10-standard GHRD generated?

$
0
0
Hi,

I sent a support question to Terasic but while I'm waiting for the response, I was wondering if anyone on this forum knew how the fpga.dts file in the Demonstration/SoC_FPGA/DE10_Standard_GHRD example was created.

Thanks,
Raul

Cyclone V (5CSXFC6D6F31C6) DE10 input 5V differential line (RS485)

FatFs header file inclusion in eclipse

$
0
0
Hello,

I have been trying to read and write from/into a file in SD card. For this I need the FatFs library to be included while I program. Since I am new to this platform any help in inclusion of this library is much appreciated. Thanks in advance.:)

Transceiver

$
0
0
hello
i want to do a transceiver using QUARTUS 17.1 but i couldn't merge TX and RX pin in the same Block

PFL update issues

$
0
0
Hi,
I am trying to generate a system with a Max II CPLD with a PFL instantiated on it and a Cyc V being loaded by it over PS configuration scheme. I am able to successfully program flash with my POF over JTAG with the Quartus programmer. In my POF are two pages, each loading the Cyc V, one that acts as a bootloader and one that acts as the application code.

I need to be able to update the application code using the flash programmer in my bootloader code, which I know works. What I can't seem to find out is the file type I need to program the flash with to get something that the PFL recognises. I have checked the output at the application location from the PFL and have found it is similar to the RBF format but not similar enough that the change can easily be manually done.

I am looking for help in identifying the file type I need to program the flash with to update just my application image and not using JTAG. Any pointers to some better information than the Altera ANs would also be appreciated.

Many Thanks!!!

PDN tool for Cyclone V HPS

$
0
0
Hi, everybody.
I'm trying to use PDN2 tool to calculate decoupling capacitors. It's not clear how to include HPS core dynamic current into calculations. In the report (PowerPlay Power Analyzer->Current Drawn From Voltage Supplies) VCCIO_HPS : 0 mA, VCCPD_HPS: 0 mA, VCC_HPS: 12.88 (static), 0 (dynamic), but in HPS Power Calculator Dialog Box it is said that for 2 cores HPS power consumption is 1.4 W. Does it mean that I have to assign 1.4/1.1 V = 1.27 A value for VCC_HPS power rail in the PDN table?
Also gate-level simulation for Cyclone V isn't available, so I'm not sure that Power Analysis is precise...

I use de0-nano-soc as a reference and see that guys from Terrasic use a lot of capacitors with different values (so it seems they used PDN tool too), but I get for my project about 4-5 capacitors for 3.3 V and 4-5 capacitors for 1.1 V and that seems suspicious :)

Create own Avalon MM-Slave

$
0
0
Hi there

I'm trying to create my first Avalon MM-Slave which should be accessible through a NIOS II softcore. In the end I just want a MM-Slave which has a conduit input and output for connecting to my custom logic. I am using a very simple MM-Slave which I have found on the internet to test how the slave behaves and how I have to build up my own slave with my needs. The slave works so far and I'm basically able to read from and wirte to the slave. But there is something I do not understand:

The component uses the following entity:
Code:

entity system_cpu_serial_interface_2 is        port(
                -- Avalon Clock interface
                clk : in std_logic;
                -- Avalon Reset interface
                reset : in std_logic;
                -- Avalon-MM Slave interface
                address : in std_logic_vector(1 downto 0);
                read : in std_logic;
                write : in std_logic;
                readdata : out std_logic_vector(31 downto 0);
                writedata : in std_logic_vector(31 downto 0)
        );
end system_cpu_serial_interface_2;

When reading from the slave I use the following line in my NIOS II code:
Code:

result = IORD_32DIRECT(SYSTEM_CPU_SERIAL_INTERFACE_2_0_BASE, 1);
I was expecting that I see the chosen offset (which is in this case 1) on the address signal. But what I get is the following:
writedata changes to 0x00000001 during read and address stays 0x00 (see attachment read.jpg).

When I try to write to the slave, the behaviour is different. I use the following code in NIOS II:
Code:

IOWR_32DIRECT(SYSTEM_CPU_SERIAL_INTERFACE_2_0_BASE, 2, 0xAAAAAAAA);
In signal tap I can see that writedata now is 0xAAAAAAAA as expected but again, the address signal stays 0x00. I was expecting this time that address should be 0x02 since the offset was 2 (see attachment write.jpg).

Can anyone tell me why the component behaves like this and how can I reach that i see the offset when reading or writing on the address signal?
Attached Images

Cyclone V emac rxcrcerror register

$
0
0
Hi,

I need to return number of IPv6 frames with bad checksum including FCS (frame check sequence).rxcrcerror register is always 0x0 although bad frames are received.

All help is appreciated!

Programming .JIC Trouble

$
0
0
Hi, I have read and followed the directions out the user manual for the DE0-nano for programming the EPCS64 spansion memory and generated the .jic file fine from my .sof file. The problem lies when I try to program the file via the programmer window it reaches 0% and fails when just the .jic file is selected. I can program the .sof file just fine on the device, but cannot see why the .jic file fails. I have tried erasing the device as well and that fails right away also. Any suggestions will be very helpful. Is there a log file I can view or something?

USB Blaster II firmware

$
0
0
Hi,

I accidentally flashed my USB Blaster II. I couldn't find the firmware in order to reprogram it. Can someone give me the link to this firmware or attach it to this thread?

Thank you

System Console unable to link with Trace System (JTAG)

$
0
0
Working with Quartus Pro v17.1.2 and Arria10 SX 660.

Test design consists of HPS+EMIF and video system using VIP components.

Video system: VIP Test Pattern Generator -> VIP Monitor -> (dout) VIP Frame Buffer II and (Capture) Trace System

Inspection of DDR buffer contents pointed to by VIP FB II shows corruption to the test pattern. I've added a VIP Monitor and Trace System components to expose the Test Pattern Generator dout stream for comparison with final buffer contents. However, System Console will not link to the Trace System. This system is using a USB-BlasterII JTAG debugger.

System Console does not list Tools->Trace Table and "get_service_paths trace" returns empty.

Quartus Post-fit Netlist Viewer shows Trace System connected to auto instantiated SLD

how to delete a part of the design using ECOs

$
0
0
Hi all, I have a circuit design containing 2 parts, the first part can run on it own, while the second part gets some input from the first part and gives some outputs.
Is there any way that after compiling, I can use ECOs mode to delete the second part so that I can have two netlists, one with the second part and one without the second part?
Because I want to use side-channel to evaluate what the difference caused by the second part only.
I tried incremental design technique but it didn't give the result I expected. The routing and placement of the first part in 2 designs (one with the second part, one without the second part) are still somewhat slightly different.
I want to keep it exactly the same.

Thank you so much for reading.
:)

how to move a part of the circuit with out changing the routing and placement of it

$
0
0
Hi all,
I have a circuit containing 2 parts. I used logiclock to constrain them into specific regions. Now I want to move the second part around.
I hope to keep the routing and placement of both of them, especially the second part, the same. It means the placement of the second part should only be changed by linearly transforming the whole part into a different place.
But every time I do it, even I keep the net-list as post-fit when recompile, the layout of the moving part still looks different. Do you guys have any idea?
Thank you
:)

Built-in Simulator for Quartus 9.1 not working in Windows 10

$
0
0
Hello, I'm trying to run Quartus 9.1 on Windows 10 and I understand that it is not supported on that OS but it does launch and I am able to compile my project, but it won't run the built-in simulator. Has anyone had that problem?

Thanks,
Joe

Partition that will be filled in by QDB file - shouldn't need an 'entity'

$
0
0
I require some assistance with Quartus Pro Edition (17.1) incremental compilation.

I have a project called 'simple'. It has a single top VHDL file called simple.vhd:
Code:

library ieee;
use ieee.std_logic_1164.all ;
entity simple is
port (
      input: in bit;
      clk : in std_logic ;
      output :out bit
      );
end simple;
architecture rtl of simple is
  component sub
  port (
        input: in bit;
        clk : in std_logic ;
        output :out bit
        );
  end component;
begin
  SC: component sub
      port map(
                  input  => input,
                  clk    => clk,
                  output => output
                  );
end rtl;

The 'sub' module is a very simple module that was compiled in a separate project. It has a single top VHDL file called sub.vhd:
Code:

library ieee;
use ieee.std_logic_1164.all ;
entity sub is
port (
      input: in bit;
      clk : in std_logic ;
      output :out bit
      );
end sub;
architecture rtl of sub is
begin
  output <= input;
end rtl;

In the 'simple' project, I wish to include only the component declaration, component instantiation, and QDB file for 'sub'. The component declaration and instantiations are shown in the VHDL above. I do not want to include the entity declaration here because the entity's inclusion is generally not required when reusing a synthesized netlist (verified in Quartus Standard as well as other HDL compilation tools).

What I mean here, is that generally all that is required for reusing a synthesized netlist, is the netlist itself and a component declaration (i.e. the stub). So, I should not have to include an entity declaration in the project when all I wish to do is use a QDB file that contains the already-synthesized 'sub' module.

I have gone through all of Intel/Altera's Incremental Block-Based Compilation training, and I have not been able to determine how to have 'sub' be truly just a netlist and a component-declaration stub file.

I am having the following issues.
1. I cannot reuse the synthesized 'sub' module if it is the top-module of its project.
  • There must be something wrong here. It does not make sense that I would have to create a wrapper module for 'sub' in its project just so I can reuse the synthesized results of 'sub' elsewhere....
  • I tried exporting the entire 'sub' project via Project -> Export Design, but this did not work because when I imported it in the 'simple' project, it wanted the QDB to represent the 'simple' project itself, not a submodule or partition of the 'simple' project. Similar problem when I used command line quartus_cdb to export the root_partition.

2. I still have problems even if I create a wrapper module for 'sub', set 'sub' as a design partition with Preservation Level=synthesized, and export that partition to a QDB:
  • How can I tell the 'simple' project that it has a sub-module that should be a pre-synthesized partition? I try to run Analysis & Elaboration, but it fails with "Error(16045): Instance "SC" instantiates undefined entity "sub"." So, there is no module hierarchy for me to set design partitions.
  • I manually modified the QSF to set the 'sub' module as a partition with a QDB:
    set_instance_assignment -name PARTITION sub -to SC -entity simple
    set_instance_assignment -name PRESERVE synthesized -to SC -entity simple
    set_instance_assignment -name QDB_FILE_PARTITION /data/workspace/sub.qdb -to SC -entity simple


but this was not successful and resulted in the same error
  • Finally, I tried adding the entity declaration for 'sub' (which I absolutely should not have to do in 'simple' as it is not required in any other HDL compilation tools). I used the same 3 partition assignments in the above bullet, and I see the following error:

Error(19326): The partition "sub" is loaded from a Partition Database File (.qdb) and is set to preserve with a Preservation Level assignment. These two preservation types cannot be combined.

  • It seems like I can get different errors if I do things in different orders.... I was able to get a seg fault by then commenting out the 'sub' entity declaration


Any help here is much appreciated. Ultimately what I would like to do is synthesize 'sub' to a netlist. 'sub' should ideally be the top level of its own project. Again I should not have to put a dummy wrapper module around 'sub' just to get a reusable netlist.... In Quartus Standard, this is as simple as synthesizing a project to a QXP (similar flow is seen in other tools as well). I would then like to instantiate 'sub' in 'simple' with just a component declaration and instantiation without the entity declaration as is possible with Quartus Standard and other tools. Finally, I would like to be able to synthesize 'simple' and proceed from there.

Thanks,
dbanks12

Where is Virtual JTAG Settings on 17.1?

$
0
0
I used to be able to find Virtual JTAG Settings in Compilation Report on older Quartus versions like 16.1. After moving to 17.1, I cannot find the summary table after compilation. Where has it moved?
Thanks.

can we install system console tool separately ?

$
0
0
Hi All,

I would like to know is it possible to install System Console tool separately.i.e. without installing complete Quartus tool.

Actually I want to write into UFM in Max10 device. So I have developed a QSys system with JTAG to Avalon Master Bridge which allows to access UFM through System Console.

Thanks & Regards,
Musthafa V

ALTGX: Byte Ordering is disabled when Rate Match FIFO is enabled

$
0
0
I'm working on Cyclone IV ALTGX @ basic mode, x16, loopback and use Quartus 13.
I want to enable Byte Ordering. The issue is that when Rate Match FIFO is enabled, Quartus automatically disable the Byte Ordering.
I do need Byte Ordering since data are coming in reverse byte order.

1. Why there is a relation between the two Byte Ordering and Rate Match FIFO ?
2. Is this limitation only in Cyclone IV or Quartus 13 ?
3. If I do want Rate Match FIFO is that mean I had to implement Byte Ordering on the Fabric ?

Another Q regards to Rate Match FIFO and x16 mode,
assuming stream is already byte ordered. Is there a guarantee that Rate Match FIFO will add/remove skip bytes in such it keep steam byte order (i.e., 2 bytes or 4 bytes) not to break the byte ordering ?
Handbook mention only that Rate Match FIFO will remove SKP as long as there is at least one SKP in the stream; add up to 4 at most there is up to 5 SKP is the stream.

thanks.
Viewing all 19390 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>