Difference between revisions of "Migen"

From ArmadeusWiki
Jump to: navigation, search
(APF51)
(APF6SP)
 
(10 intermediate revisions by the same user not shown)
Line 4: Line 4:
  
 
APF27 and APF51 platforms have been integrated under Migen in July 2014, so designs can be done with it for these APF.
 
APF27 and APF51 platforms have been integrated under Migen in July 2014, so designs can be done with it for these APF.
 +
 +
== Installing Migen ==
 +
 +
=== Requirements ===
 +
 +
* Python 3.4 minimum
 +
* git
 +
* python setuptools: to use in developpement python module
 +
<pre class="host">
 +
# On debian:
 +
sudo apt-get install python-setuptools
 +
</pre>
 +
* [[ISE_WebPack_installation_on_Linux | ISE webpack]]: to generate bitstream for apf27, apf51
 +
* [[Quartus_installation_on_Linux |Quartus web edition]]: to generate bitstream for apf6sp
 +
 +
=== installation ===
 +
 +
Migen is an under developpement python3 module. To install it python 3.4 is required.
 +
 +
* first download the git tree:
 +
<pre class="host">
 +
$ git clone https://github.com/m-labs/migen.git
 +
</pre>
 +
 +
* Then install it as developpement module:
 +
<pre class="host">
 +
$ cd migen
 +
$ sudo python setup.py develop
 +
</pre>
 +
 +
* To be up-to-date with the github tree, do not forget to pull fresh version regularly :
 +
<pre class="host">
 +
$ cd migen
 +
$ git pull
 +
</pre>
  
 
== Blink LED example ==
 
== Blink LED example ==
Line 13: Line 48:
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8 -*-
  
from migen.fhdl.std import *
+
from migen import *
from mibuild.generic_platform import Pins, IOStandard
+
from migen.fhdl import *
from mibuild.platforms import apf27
+
from migen.build.generic_platform import Pins, IOStandard
 
+
from migen.build.platforms import apf27
 +
 
ios = [
 
ios = [
 
     ("user_led", 0, Pins("J2:22"), IOStandard("LVCMOS33"))
 
     ("user_led", 0, Pins("J2:22"), IOStandard("LVCMOS33"))
Line 28: Line 64:
 
m.comb += led.eq(counter[25])
 
m.comb += led.eq(counter[25])
 
m.sync += counter.eq(counter + 1)
 
m.sync += counter.eq(counter + 1)
plat.build_cmdline(m)
+
plat.build(m)
 
</source>
 
</source>
  
Line 37: Line 73:
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8 -*-
  
from migen.fhdl.std import *
+
from migen import *
from mibuild.generic_platform import Pins, IOStandard
+
from migen.fhdl import *
from mibuild.platforms import apf51
+
from migen.build.generic_platform import Pins, IOStandard
 
+
from migen.build.platforms import apf51
 +
 
ios = [
 
ios = [
 
     ("user_led", 0, Pins("J2:15"), IOStandard("LVCMOS33"))
 
     ("user_led", 0, Pins("J2:15"), IOStandard("LVCMOS33"))
 
]
 
]
 
+
 
plat = apf51.Platform()
 
plat = apf51.Platform()
 
plat.add_extension(ios)
 
plat.add_extension(ios)
Line 52: Line 89:
 
m.comb += led.eq(counter[25])
 
m.comb += led.eq(counter[25])
 
m.sync += counter.eq(counter + 1)
 
m.sync += counter.eq(counter + 1)
plat.build_cmdline(m)
+
plat.build(m)
 
</source>
 
</source>
  
 
=== APF6SP ===
 
=== APF6SP ===
  
  TODO
+
<source lang="python">
 +
#!/usr/local/bin/python3.4
 +
# -*- coding: utf-8 -*-
 +
 
 +
from migen import *
 +
from migen.fhdl import *
 +
from migen.build.generic_platform import Pins, IOStandard, Subsignal
 +
from migen.build.platforms import apf6sp
 +
 
 +
ios = [ ("user_led", 0, Pins("HIROSE:D0")),]
 +
 
 +
plat = apf6sp.Platform()
 +
plat.add_extension(ios)
 +
led = plat.request("user_led", 0) # led pin on apf6sp_dev
 +
 
 +
m = apf6sp.PciePllClockedModule(platform=plat)
 +
counter = Signal(26)
 +
m.comb += led.eq(counter[25])
 +
m.sync += counter.eq(counter + 1)
 +
 
 +
plat.build(m)
 +
</source>
  
 
== Links ==
 
== Links ==
Line 63: Line 121:
 
* [http://m-labs.hk/gateware.html Official migen presentation]
 
* [http://m-labs.hk/gateware.html Official migen presentation]
 
* [http://connect.ed-diamond.com/GNU-Linux-Magazine/GLMF-149/Migen-une-boite-a-outils-en-Python-pour-concevoir-des-circuits-logiques-complexes An article in GLMF 149 (french Linux Magazine)]
 
* [http://connect.ed-diamond.com/GNU-Linux-Magazine/GLMF-149/Migen-une-boite-a-outils-en-Python-pour-concevoir-des-circuits-logiques-complexes An article in GLMF 149 (french Linux Magazine)]
* [http://www.martoni.fr/wordpress/?p=706 Some experiments for APF27 (fr)]
+
* [http://www.fabienm.eu/flf/experimentations-de-migen-sur-apf27-avec-debian/ Some experiments for APF27 (fr)]

Latest revision as of 09:00, 11 April 2016

Introduction

Migen is a Python module that makes FPGA design possible without VHDL or Verilog. Writing a Migen design for FPGA is like writing Python program. If it's correctly configured with ISE or Quartus, Migen is also capable of generating the bitstream directly.

APF27 and APF51 platforms have been integrated under Migen in July 2014, so designs can be done with it for these APF.

Installing Migen

Requirements

  • Python 3.4 minimum
  • git
  • python setuptools: to use in developpement python module
# On debian:
sudo apt-get install python-setuptools

installation

Migen is an under developpement python3 module. To install it python 3.4 is required.

  • first download the git tree:
$ git clone https://github.com/m-labs/migen.git
  • Then install it as developpement module:
$ cd migen
$ sudo python setup.py develop
  • To be up-to-date with the github tree, do not forget to pull fresh version regularly :
$ cd migen
$ git pull

Blink LED example

APF27

#!/usr/local/bin/python3.4
# -*- coding: utf-8 -*-

from migen import *
from migen.fhdl import *
from migen.build.generic_platform import Pins, IOStandard
from migen.build.platforms import apf27
 
ios = [
    ("user_led", 0, Pins("J2:22"), IOStandard("LVCMOS33"))
]

plat = apf27.Platform()
plat.add_extension(ios)
led = plat.request("user_led", 0)  # led pin on apf27dev
m = Module()
counter = Signal(26)
m.comb += led.eq(counter[25])
m.sync += counter.eq(counter + 1)
plat.build(m)

APF51

#!/usr/local/bin/python3.4
# -*- coding: utf-8 -*-

from migen import *
from migen.fhdl import *
from migen.build.generic_platform import Pins, IOStandard
from migen.build.platforms import apf51
 
ios = [
    ("user_led", 0, Pins("J2:15"), IOStandard("LVCMOS33"))
]
 
plat = apf51.Platform()
plat.add_extension(ios)
led = plat.request("user_led", 0)  # led pin on apf51dev
m = Module()
counter = Signal(26)
m.comb += led.eq(counter[25])
m.sync += counter.eq(counter + 1)
plat.build(m)

APF6SP

#!/usr/local/bin/python3.4
# -*- coding: utf-8 -*-

from migen import *
from migen.fhdl import *
from migen.build.generic_platform import Pins, IOStandard, Subsignal
from migen.build.platforms import apf6sp

ios = [ ("user_led", 0, Pins("HIROSE:D0")),]

plat = apf6sp.Platform()
plat.add_extension(ios)
led = plat.request("user_led", 0)  # led pin on apf6sp_dev

m = apf6sp.PciePllClockedModule(platform=plat)
counter = Signal(26)
m.comb += led.eq(counter[25])
m.sync += counter.eq(counter + 1)

plat.build(m)

Links