fusesoc / blinky

Example LED blinking project for your FPGA dev board of choice
MIT License
162 stars 70 forks source link

LED does not blink, Alhambra board #21

Closed imuguruza closed 4 years ago

imuguruza commented 4 years ago

Hi there,

I am trying to support the blinky example in an Alhambra board. For that I have added a pcf file and the board support in the blinky.core file (here and here), following the tinyfpga_bx as example.

In order to load it in fusesoc this repo, I have used fusesoc library add blinky /path/to/repo command.

I am able to synth the example using fusesoc run --target=alhambra_II fusesoc:utils:blinky command.

The issue is that, once I upload the bin file, it doesn't blink. I have checked the clk input pin and it is fine. The LED I have assigned, once the FPGA is programmed, goes from high-impedance to OFF.

Am I missing something?

imuguruza commented 4 years ago

Ok, I think I now which is the problem. It looks like the paremeter clk_freq_hz is not bind correctly at compilation time. I have changed its value from 0 => 12000000 (in blinky.v), and now is blinking.

I have observed that nextpnr was throwing the next warning:

Warning: No clocks found in design
Warning: No clocks found in design
olofk commented 4 years ago

Yes, I should document that somewhere. The nextpnr error message isn't very clear about the fact that yosys basically removed the whole design. I have been scratching my head over why my design didn't work for the exact same reason :)

olofk commented 4 years ago

So if it works, I'm happy to take a PR

imuguruza commented 4 years ago

So if it works, I'm happy to take a PR

It works if I hardcode the clk_freq_hz value in blinky.v file. If that is fine, I will open a PR

olofk commented 4 years ago

Ah sorry. I misunderstood. That definitely doesn't seem right. Could you look in build/fusesoc_utils_blinky_0/alhambra_II-icestorm and see what value you have for clk_freq_hz in the .eda.yml file and in yosys.log. I'm wondering if there is some issue with your FuseSoC or Edalize version. I know there were some issues related to parameters in the latest edalize release. Perhaps it was more broken than I thought

imuguruza commented 4 years ago

eda.yml file looks good, the clk is ok:

dependencies:
  fusesoc:utils:blinky:0: []
files:
- core: fusesoc:utils:blinky:0
  file_type: verilogSource
  is_include_file: false
  logical_name: ''
  name: ../src/fusesoc_utils_blinky_0/blinky.v
- core: fusesoc:utils:blinky:0
  file_type: user
  is_include_file: false
  logical_name: ''
  name: proginfo.py
- core: fusesoc:utils:blinky:0
  file_type: PCF
  is_include_file: false
  logical_name: ''
  name: ../src/fusesoc_utils_blinky_0/alhambra_II/pinout.pcf
hooks:
  post_run:
  - cmd:
    - python
    - proginfo.py
    - iceprog
    env:
      FILES_ROOT: ../src/fusesoc_utils_blinky_0
    name: iceprog
name: fusesoc_utils_blinky_0
parameters:
  clk_freq_hz:
    datatype: int
    default: 12000000
    description: Clock frequency in Hz
    paramtype: vlogparam
tool_options:
  icestorm:
    nextpnr_options:
    - --hx8k
    - --package
    - tq144:4k
    pnr: next
toplevel: blinky
version: 0.2.1
vpi: []

the only warning I see in yosys.log is the next one:

1. Executing Verilog-2005 frontend: ../src/fusesoc_utils_blinky_0/blinky.v
Parsing Verilog input from `../src/fusesoc_utils_blinky_0/blinky.v' to AST representation.
Storing AST representation for module `$abstract\blinky'.
Successfully finished Verilog frontend.
Warning: Selection "$abstractlinky" did not match any module.

In case you want to have a look on it, here

I see also this in the tcl file

chparam -set clk_freq_hz 12000000 \$abstract\blinky
verilog_defaults -pop

I installed fusesoc using python2, pip install fusesoc, just in case the versions is different from the one installed with pip3 install fusesoc (as fusesoc doc states)

olofk commented 4 years ago

Aha! I think I got it now. When I wrote the code for calling yosys, you had to use chparam \$abstract\toplevel to set a toplevel parameter. Now it seems like that is no longer allowed and only chparam toplevel works. I actually made a commit to change that in edalize just last week https://github.com/olofk/edalize/commit/9620f85e4b3fee98d7bf16ba1dd144093adbc410

So you can either try to get the latest edalize version from git, or you can do a quick test by running fusesoc run --target=alhamba_II --setup fusesoc:utils:blinky. This will just create the config files. Then you can go into build/fusesoc_utils_blinky_0/alhambra_II-icestorm, remove \$abstract\ from the chparam lines in the .ys file and run make

imuguruza commented 4 years ago

I will go for the quick test. If I write $ fusesoc list-cores, I see how blinky is local:

fusesoc:utils:blinky:0                 : local

But If I try yo create the config file you mention for the alhambra, I am not able:

fusesoc run --target=tinyfpga_bx --setup fusesoc:utils:blinky
INFO: Preparing fusesoc:utils:blinky:0
INFO: Setting up project
INFO: Setting up project

$ fusesoc run --target=alhamba_II --setup fusesoc:utils:blinky
ERROR: No tool was supplied on command line or found in 'fusesoc:utils:blinky' core description

I guess I am missing something

olofk commented 4 years ago

Likely, you missed setting default_tool : icestorm in your target

imuguruza commented 4 years ago

No, it was a typing error :man_facepalming: I did what you mention and it works! Let me check it again and once it looks OK to me, I will open a PR

olofk commented 4 years ago

Great!

imuguruza commented 4 years ago

I install from sources edalize and I see that this version goes under python3. I installed fusesoc using pip install fusesoc, where my default python version is 2. Should I remove the installation, using pip uninstall fusesoc and install all from sources? So when fusesoc calls edalize uses the version with the commit you did?

imuguruza commented 4 years ago

I haven't been able to install fusesoc and edalize properly from sources... Any requisites? Should python3 be default python interpreter?

imuguruza commented 4 years ago

Closing this as it is not blinky related