« Cours:Vhdl » : différence entre les versions

De troyesGEII
Aller à la navigation Aller à la recherche
Des restrictions d’accès ont été mises en place pour cette page. Si vous voyez ce message, vous n’avez pas accès à cette page.
Bjacquot (discussion | contributions)
Aucun résumé des modifications
Bjacquot (discussion | contributions)
 
(76 versions intermédiaires par le même utilisateur non affichées)
Ligne 5 : Ligne 5 :


===hardware===
===hardware===
<source lang=vhd>
<source lang=vhdl>
entity customPeriph is
entity customPeriph is
     port (
     port (
Ligne 24 : Ligne 24 :
<source lang=cpp>
<source lang=cpp>
IOWR(CUSTOM_0_BASE,regNumber,value);
IOWR(CUSTOM_0_BASE,regNumber,value);
</source>
==pio==
[[Media:Nios_pio.pdf]]
==irq avec le nios2==
===hardware===
<source lang=vhdl>
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;
entity customIRQ is
    port (
        clk        : in  std_logic;
        reset_n    : in  std_logic;
        address    : in  std_logic_vector(1 downto 0);
        write      : in  std_logic;
        read        : in  std_logic;
        chipselect  : in  std_logic;
        writedata  : in  std_logic_vector(31 downto 0);
        irq        : out std_logic;
        readdata    : out std_logic_vector(31 downto 0)
    );
end entity customIRQ;
architecture rtl of customIRQ is
    signal s_irq    : std_logic;
begin
    process(clk, reset_n)
    begin
        if rising_edge(clk) then
            -- prévoir un moyen pour acquitter l'irq
            -- par exemple avec une écriture sur un registre particulier
            if chipselect = '1' and write = '1' then
                s_irq <= '0';
    elsif "condition pour déclencher une interruption" then
s_irq <= '1';
            end if;
        end if;
    end process;
    irq <= s_irq;
end architecture rtl;
</source>
===software===
<source lang=cpp>
#include "sys/stdio.h"
#include <unistd.h>
#include "io.h"
#include "system.h"
#include "sys/alt_irq.h"
#include "drivers/inc/altera_avalon_pio_regs.h"
volatile int n=0;
static void myISR(void * context,alt_u32 id)
{
  // terminer par l'acquittement de l'interruption
  IOWR(BPS_0_BASE,0,0);
}
int main()
{
  // acquitter l'interruption si elle est déjà déclenchée
  IOWR(BPS_0_BASE,0,0);
  alt_ic_isr_register(BPS_0_IRQ_INTERRUPT_CONTROLLER_ID, BPS_0_IRQ ,(void *) myISR,NULL,NULL);
  while (1)
  {
  }
}
</source>
</source>


Ligne 49 : Ligne 132 :
}
}


</source>
=Evaluation=
*[[Cours:evaluation_XR509_a25]]
=de0 nano soc=
**********
*https://forum.digikey.com/t/debian-getting-started-with-the-de0-nano-soc-kit/12434
*https://forum.rocketboards.org/t/missing-dev-fpga0-device-on-de0-nano-soc/526/7
**********
*https://forum.rocketboards.org/t/load-fpga-rbf-from-device-tree-overlay-example/999/17
*https://altera-fpga.github.io/rel-25.3/
*https://www.rocketboards.org/foswiki/Projects/TouchScreenLCDForAlteraSoC
*https://github.com/qtplatz/socfpga_debian
*https://www.rocketboards.org/foswiki/Documentation/GSRD131ProgrammingFPGA
*https://forum.rocketboards.org/t/cyclone-v-frame-buffer-ii-problem-with-device-tree-and-with-understanding-the-address-map/2831/2
*https://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=167&No=941&PartNo=4#contents
*https://github.com/ikwzm/FPGA-SoC-U-Boot-DE0-Nano-SoC
*https://github.com/ikwzm/FPGA-SoC-Linux/blob/master/doc/install/format-disk-de0-nano-soc.md
*https://forum.digikey.com/t/debian-getting-started-with-the-de0-nano-soc-kit/12434
sudo apt-get update
sudo apt-get install -y build-essential git bc bison flex \
  libssl-dev libncurses5-dev libncursesw5-dev \
  lzop u-boot-tools device-tree-compiler
Debian Jessie 8.0 rootfs
The steps required to boot Debian are: This project creates a working install of Debian Jessie 8 on Altera SoC
First create a working Yocto image
Download the attached debian8 image file ( debian8.img.gz)
Decompress the image using:
$ gzip -d debian8.img.gz
Use DD to copy the image over the second partition of your sd card. If your card is /dev/mmcblk0 then this would be:
$ dd if=debian8.img of=/dev/sdb2
Root password is "debian". Ethernet is preconfigured with dhcp. This can be changed through the normal debian method. Access by UART
==installation==
*installer avec balena etcher DE0_Nano_SoC_Linux_Console_3.13.zip
*remplacer la partition root avec une version debian
**debian 10 ok
**debian 12 semble ok avec qques erreurs de démarrage à corriger
***Failed to start e2scrub_reap.servi…line ext4 Metadata Check Snapshots
***Failed to start systemd-timesyncd.…ice - Network Time Synchronizatio
*modifier le fichier fstab
sudo sh -c "echo '/dev/mmcblk0p2  /  auto  errors=remount-ro  0  1' >> /media/rootfs/etc/fstab"
==creation d'un chroot==
<source lang=bash>
chrootRep="choisirUnDossier"
cd $chrootRep
tar -xvf /home/bas/Téléchargements/de0NanoSoc/debian-12.12-minimal-armhf-2025-12-01/armhf-rootfs-debian-bookworm.tar ./
apt install qemu-user-static binfmt-support debootstrap schroot
cp /usr/bin/qemu-arm-static  $rep/usr/bin/
# créer un fichier /etc/schroot/chroot.d/de0.conf
[de0]
description=Chroot ARMHF (Cortex-A9)
directory $chrootRep
type=directory
users=debian
groups=root
root-groups=root
preserve-environment=true
personality=linux
#utiliser le chroot
schroot -c de0 --directory /root
#dans le chroot :
sudo sh -c "echo '/dev/mmcblk0p2  /  auto  errors=remount-ro  0  1' >> /etc/fstab"
ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service
dpkg-reconfigure locales
apt install libc6-dev-armel-cross
</source>
==creation de sysroot==
<source lang=bash>
rep="monDossier"
cd $rep
rsync -av chroot/lib sysroot/
rsync -av chroot/usr/include sysroot/usr/
rsync -av chroot/usr/lib sysroot/usr/
rsync -av chroot/usr/arm-linux-gnueabi rsync -av sysroot/usr/
apt install symlinks
symlinks -rc sysroot
cd sysroot/usr/include/
ln -s ../arm-linux-gnueabi/include/gnu ./
</source>
==utiliser arm v12 !!==
changer les liens ou installer le paquet
==cross compilation qt==
<source lang=bash>
rep="monDossier"
cd $rep
mkdir qt5Source
cd qt5Source
git clone https://code.qt.io/qt/qt5.git -b 5.15
cd qt5
./init-repository --module-subset=essential,qtserialport
git submodule foreach --recursive "git clean -dfx"
# qtwebengine doit être exclu car il ne compile pas pour ARMv7/Cortex-A9 du Cyclone V.
mkdir qtbase/mkspecs/devices/linux-cyclonev-g++
cd qtbase/mkspecs/devices/linux-cyclonev-g++
nano  qmake.conf
#-------------------------------------------------
# Qt mkspec for DE0-Nano-SoC (Cyclone V, ARMv7-A, hard-float)
# Cross-compilation using Linaro or Intel SoC EDS toolchain
#-------------------------------------------------
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental global_init_link_order
CONFIG += cross_compile qpa
# QPA platforms
QMAKE_QPA_PLATFORM = linuxfb eglfs
#-------------------------------------------------
# Toolchain
#-------------------------------------------------
QMAKE_CC        = $$CROSS_COMPILEgcc
QMAKE_CXX      = $$CROSS_COMPILEg++
QMAKE_LINK      = $$CROSS_COMPILEg++
QMAKE_LINK_SHLIB= $$CROSS_COMPILEg++
QMAKE_AR        = $$CROSS_COMPILEar cqs
QMAKE_OBJCOPY  = $$CROSS_COMPILEobjcopy
QMAKE_STRIP    = $$CROSS_COMPILEstrip
#-------------------------------------------------
# CPU architecture flags (Cyclone V = ARMv7-A + NEON)
#-------------------------------------------------
QMAKE_CFLAGS  += -march=armv7-a -mfloat-abi=hard -mfpu=neon
QMAKE_CXXFLAGS += -march=armv7-a -mfloat-abi=hard -mfpu=neon
#-------------------------------------------------
# Sysroot
#-------------------------------------------------
QMAKE_INCDIR += $$[QT_SYSROOT]/usr/include $$[QT_SYSROOT]/usr/arm-linux-gnueabi/include
QMAKE_LIBDIR += $$[QT_SYSROOT]/usr/lib $$[QT_SYSROOT]/lib
# Avoid RPATH for embedded targets
QMAKE_LFLAGS_RPATH =
# Default QPA platform
QT_QPA_DEFAULT_PLATFORM = linuxfb
# EGLFS backend (requires SGX drivers)
EGLFS_DEVICE_INTEGRATION = eglfs
#-------------------------------------------------
# Common includes for embedded Linux
#-------------------------------------------------
DISTRO_OPTS += hard-float
QT_CPU_FEATURES.arm = neon
load(device_config)
include(../common/linux_device_pre.conf)
include(../common/linux_arm_device_post.conf)
load(qt_config)
nano qplatformdefs.h
#include "../../linux-g++/qplatformdefs.h"
cd $rep/qt5Source/qt5
git submodule foreach --recursive "git clean -dfx"
cp -R $rep/linux-cyclonev-g++ qtbase/mkspecs/devices/
export CFLAGS="-std=gnu11"
export CXXFLAGS="-std=gnu++11"
./configure -release -device linux-cyclonev-g++ -no-eglfs \
-device-option CROSS_COMPILE=arm-linux-gnueabihf- \
-sysroot $rep/sysroot -opensource -confirm-license -make libs \
-prefix /usr/local/qt5pi -extprefix $rep/qt5_de0 -hostprefix $rep/qt5 -v \
-R $rep/sysroot/usr/lib/arm-linux-gnueabihf -no-gbm -no-use-gold-linker -v -no-opengl -release \
-R $rep/usr/arm-linux-gnueabi/include \
-R $rep/usr/arm-linux-gnueabi/include/gnu \
  -nomake tests -nomake examples -system-sqlite\
  -skip qtwebengine -no-feature-imageformat_xpm -no-xcb -no-feature-kms -no-feature-bearermanagement -skip qtmultimedia -no-sql-psql
read -p "verifier la config puis appuyer pour continuer"
make -j12
rm -R $rep/qt5_de0
make install -j12
</source>
==uboot==
setenv ethaddr 00:11:22:33:44:55
saveenv
==bug==
ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service
==kernel==
<source lang=bash>
make ARCH=arm modules_install INSTALL_MOD_PATH="tmp"
</source>
==linux==
===fstab===
ajouter dans le fstab le montage de la partition root :
<source lang=bash>
/dev/mmcblk0p2 / ext4 errors=remount-ro,relatime      0 1
</source>
===pb de fsck ext4 : erreur FEATURE_C12===
si version trop vieille de ext tools, insérer la carte sd sur une ditrib linux récente
<source lang=bash>
tune2fs -O ^orphan_file /dev/mydevice
e2fsck -f /dev/mydevice
</source>
</source>

Dernière version du 13 décembre 2025 à 17:46

Nios 2

interface pour le bus avalon

hardware

entity customPeriph is
    port (
        clk         : in  std_logic;
        reset_n     : in  std_logic;
        address     : in  std_logic_vector(1 downto 0);
        write       : in  std_logic;
        read        : in  std_logic;
        chipselect  : in  std_logic;
        writedata   : in  std_logic_vector(31 downto 0);
        readdata    : out std_logic_vector(31 downto 0)
    );
end entity customPeriph;

software

IOWR(CUSTOM_0_BASE,regNumber,value);

pio

Media:Nios_pio.pdf


irq avec le nios2

hardware

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;


entity customIRQ is
    port (
        clk         : in  std_logic;
        reset_n     : in  std_logic;
        address     : in  std_logic_vector(1 downto 0);
        write       : in  std_logic;
        read        : in  std_logic;
        chipselect  : in  std_logic;
        writedata   : in  std_logic_vector(31 downto 0);
        irq         : out std_logic;
        readdata    : out std_logic_vector(31 downto 0)
    );
end entity customIRQ;

architecture rtl of customIRQ is

    signal s_irq     : std_logic;
	 
begin

    process(clk, reset_n)
    begin
        if rising_edge(clk) then
            -- prévoir un moyen pour acquitter l'irq
            -- par exemple avec une écriture sur un registre particulier
            if chipselect = '1' and write = '1' then
                s_irq <= '0';
	    elsif "condition pour déclencher une interruption" then
		s_irq <= '1';
            end if;
        end if;
    end process;
    irq <= s_irq;
end architecture rtl;

software

#include "sys/stdio.h"
#include <unistd.h>
#include "io.h"
#include "system.h"
#include "sys/alt_irq.h"
#include "drivers/inc/altera_avalon_pio_regs.h"

volatile int n=0;


static void myISR(void * context,alt_u32 id)
{
  // terminer par l'acquittement de l'interruption
  IOWR(BPS_0_BASE,0,0);
}

int main()
{ 
  // acquitter l'interruption si elle est déjà déclenchée
  IOWR(BPS_0_BASE,0,0);
  alt_ic_isr_register(BPS_0_IRQ_INTERRUPT_CONTROLLER_ID, BPS_0_IRQ ,(void *) myISR,NULL,NULL);

  while (1)
  {
  }
}

PIO

interruptions

static void myISR(void * context,alt_u32 id)
{
        // terminer par l'acquittement de l'interruption
	IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_0_BASE, 0);
	IORD_ALTERA_AVALON_PIO_EDGE_CAP(PIO_0_BASE);
}

int main()
{ 
  // choix des PIO déclenchant l'interruption
  IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_0_BASE, 0xff);
  // initialisation des fronts
  IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_0_BASE, 0);
  alt_ic_isr_register(PIO_0_IRQ_INTERRUPT_CONTROLLER_ID, PIO_0_IRQ ,(void *) myISR,NULL,NULL);
  while (1)
  {
  }
}

Evaluation

de0 nano soc

**********
**********




sudo apt-get update sudo apt-get install -y build-essential git bc bison flex \

 libssl-dev libncurses5-dev libncursesw5-dev \
 lzop u-boot-tools device-tree-compiler


Debian Jessie 8.0 rootfs The steps required to boot Debian are: This project creates a working install of Debian Jessie 8 on Altera SoC First create a working Yocto image Download the attached debian8 image file ( debian8.img.gz) Decompress the image using: $ gzip -d debian8.img.gz

Use DD to copy the image over the second partition of your sd card. If your card is /dev/mmcblk0 then this would be: $ dd if=debian8.img of=/dev/sdb2

Root password is "debian". Ethernet is preconfigured with dhcp. This can be changed through the normal debian method. Access by UART


installation

  • installer avec balena etcher DE0_Nano_SoC_Linux_Console_3.13.zip
  • remplacer la partition root avec une version debian
    • debian 10 ok
    • debian 12 semble ok avec qques erreurs de démarrage à corriger
      • Failed to start e2scrub_reap.servi…line ext4 Metadata Check Snapshots
      • Failed to start systemd-timesyncd.…ice - Network Time Synchronizatio
  • modifier le fichier fstab
sudo sh -c "echo '/dev/mmcblk0p2  /  auto  errors=remount-ro  0  1' >> /media/rootfs/etc/fstab"

creation d'un chroot

chrootRep="choisirUnDossier"
cd $chrootRep
tar -xvf /home/bas/Téléchargements/de0NanoSoc/debian-12.12-minimal-armhf-2025-12-01/armhf-rootfs-debian-bookworm.tar ./
apt install qemu-user-static binfmt-support debootstrap schroot
cp /usr/bin/qemu-arm-static  $rep/usr/bin/
# créer un fichier /etc/schroot/chroot.d/de0.conf
[de0]
description=Chroot ARMHF (Cortex-A9)
directory $chrootRep
type=directory
users=debian
groups=root
root-groups=root
preserve-environment=true
personality=linux


#utiliser le chroot
schroot -c de0 --directory /root
#dans le chroot :
sudo sh -c "echo '/dev/mmcblk0p2  /  auto  errors=remount-ro  0  1' >> /etc/fstab"
ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service
dpkg-reconfigure locales
apt install libc6-dev-armel-cross

creation de sysroot

rep="monDossier"
cd $rep
rsync -av chroot/lib sysroot/
rsync -av chroot/usr/include sysroot/usr/
rsync -av chroot/usr/lib sysroot/usr/
rsync -av chroot/usr/arm-linux-gnueabi rsync -av sysroot/usr/
apt install symlinks
symlinks -rc sysroot

cd sysroot/usr/include/
ln -s ../arm-linux-gnueabi/include/gnu ./

utiliser arm v12 !!

changer les liens ou installer le paquet

cross compilation qt

rep="monDossier"
cd $rep
mkdir qt5Source
cd qt5Source
git clone https://code.qt.io/qt/qt5.git -b 5.15
cd qt5
./init-repository --module-subset=essential,qtserialport
git submodule foreach --recursive "git clean -dfx"

# qtwebengine doit être exclu car il ne compile pas pour ARMv7/Cortex-A9 du Cyclone V.
mkdir qtbase/mkspecs/devices/linux-cyclonev-g++
cd qtbase/mkspecs/devices/linux-cyclonev-g++
nano  qmake.conf


#-------------------------------------------------
# Qt mkspec for DE0-Nano-SoC (Cyclone V, ARMv7-A, hard-float)
# Cross-compilation using Linaro or Intel SoC EDS toolchain
#-------------------------------------------------

MAKEFILE_GENERATOR = UNIX
CONFIG += incremental global_init_link_order
CONFIG += cross_compile qpa

# QPA platforms
QMAKE_QPA_PLATFORM = linuxfb eglfs

#-------------------------------------------------
# Toolchain
#-------------------------------------------------
QMAKE_CC        = $$CROSS_COMPILEgcc
QMAKE_CXX       = $$CROSS_COMPILEg++
QMAKE_LINK      = $$CROSS_COMPILEg++
QMAKE_LINK_SHLIB= $$CROSS_COMPILEg++
QMAKE_AR        = $$CROSS_COMPILEar cqs
QMAKE_OBJCOPY   = $$CROSS_COMPILEobjcopy
QMAKE_STRIP     = $$CROSS_COMPILEstrip

#-------------------------------------------------
# CPU architecture flags (Cyclone V = ARMv7-A + NEON)
#-------------------------------------------------
QMAKE_CFLAGS   += -march=armv7-a -mfloat-abi=hard -mfpu=neon
QMAKE_CXXFLAGS += -march=armv7-a -mfloat-abi=hard -mfpu=neon

#-------------------------------------------------
# Sysroot
#-------------------------------------------------
QMAKE_INCDIR += $$[QT_SYSROOT]/usr/include $$[QT_SYSROOT]/usr/arm-linux-gnueabi/include
QMAKE_LIBDIR += $$[QT_SYSROOT]/usr/lib $$[QT_SYSROOT]/lib

# Avoid RPATH for embedded targets
QMAKE_LFLAGS_RPATH =

# Default QPA platform
QT_QPA_DEFAULT_PLATFORM = linuxfb

# EGLFS backend (requires SGX drivers)
EGLFS_DEVICE_INTEGRATION = eglfs

#-------------------------------------------------
# Common includes for embedded Linux
#-------------------------------------------------
DISTRO_OPTS += hard-float

QT_CPU_FEATURES.arm = neon

load(device_config)
include(../common/linux_device_pre.conf)
include(../common/linux_arm_device_post.conf)
load(qt_config)


nano qplatformdefs.h
#include "../../linux-g++/qplatformdefs.h"


cd $rep/qt5Source/qt5
git submodule foreach --recursive "git clean -dfx"
cp -R $rep/linux-cyclonev-g++ qtbase/mkspecs/devices/

export CFLAGS="-std=gnu11"
export CXXFLAGS="-std=gnu++11"

./configure -release -device linux-cyclonev-g++ -no-eglfs \
-device-option CROSS_COMPILE=arm-linux-gnueabihf- \
-sysroot $rep/sysroot -opensource -confirm-license -make libs \
-prefix /usr/local/qt5pi -extprefix $rep/qt5_de0 -hostprefix $rep/qt5 -v \
-R $rep/sysroot/usr/lib/arm-linux-gnueabihf -no-gbm -no-use-gold-linker -v -no-opengl -release \
-R $rep/usr/arm-linux-gnueabi/include \
-R $rep/usr/arm-linux-gnueabi/include/gnu \
  -nomake tests -nomake examples -system-sqlite\
  -skip qtwebengine -no-feature-imageformat_xpm -no-xcb -no-feature-kms -no-feature-bearermanagement -skip qtmultimedia -no-sql-psql


read -p "verifier la config puis appuyer pour continuer"



make -j12

rm -R $rep/qt5_de0
make install -j12

uboot

setenv ethaddr 00:11:22:33:44:55

saveenv

bug

ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service

kernel

make ARCH=arm modules_install INSTALL_MOD_PATH="tmp"

linux

fstab

ajouter dans le fstab le montage de la partition root :

/dev/mmcblk0p2 / ext4 errors=remount-ro,relatime      0 1

pb de fsck ext4 : erreur FEATURE_C12

si version trop vieille de ext tools, insérer la carte sd sur une ditrib linux récente

tune2fs -O ^orphan_file /dev/mydevice
e2fsck -f /dev/mydevice