Author Topic: Lattice iCE40 Ultra internal oscillator  (Read 10065 times)

0 Members and 1 Guest are viewing this topic.

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Lattice iCE40 Ultra internal oscillator
« on: April 02, 2018, 01:47:02 pm »
Recently acquired the iCE40Ultra breakout board to test some FPGA designs as the iCE40 Ultra devices come in smaller packages...

The iCEcube2 software lists no options to include the two built-in oscillators HFOSC and LFOSC...there is a document "iCE40 Oscillator Usage Guide" describing how to instantiate but this doesn't work at all....

Code: [Select]
SB_HFOSC OSCInst0 (
.CLKHF_EN(ENCLKHF),
.CLKHF_PU(CLKHF_POWERUP),
.CLKHF(CLKHF)
);

Anyone used the internal oscillators? Preferably with Verilog?

Well the iCEcube2 software has some other bugs as it suddenly assigns an output as register driven by a logical "1" and clocked by internal oscillator..


thanks in advance
davorin

 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #1 on: April 02, 2018, 01:52:29 pm »
I've not only used them, but reverse engineered and documented the oscillators in the iCE40 UltraPlus for Project IceStorm and I understand they are the same on the iCE40 Ultra.

Can you post the whole of the design file? I've never seen any problems in iCEcube2. In particular, could you post the definitions of ENCLKHF, CLKHF_POWERUP and CLKHF, and the assignments to ENCLKHF and CLKHF_POWERUP?

A minimal template for the SB_HFOSC is at https://github.com/cliffordwolf/icestorm/blob/master/icefuzz/tests/intosc.v.

A larger design using one is here https://github.com/cliffordwolf/icestorm/blob/master/examples/up5k_rgb/rgb.v.
« Last Edit: April 02, 2018, 01:54:43 pm by daveshah »
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #2 on: April 02, 2018, 01:59:25 pm »
Actually the error message is clear about it:

Code: [Select]
@E: CS168 :"/home2/Develop/fpga/icecube/quad/quad.v":85:10:85:10|Port CLKHF_EN does not exist
But CLKHF_EN is mentioned in one of their hundreds docs about iCE (o;

Here is the whole design (where rgb out is stuck at 1 driven by internal oscillator):
The same design runs perfect on a MAX1000.

Code: [Select]
module quad
(
quadA,
quadB,
rgb,
push
);

input quadA, quadB, push;
output rgb;

reg [2:0] quadA_delayed, quadB_delayed;
reg [2:0] pushA_delayed, pushB_delayed;

always @(posedge hfclk)
if(push)
quadA_delayed <= {quadA_delayed[1:0], quadA};
else
pushA_delayed <= {pushA_delayed[1:0], quadA};

always @(posedge hfclk)
if(push)
quadB_delayed <= {quadB_delayed[1:0], quadB};
else
pushB_delayed <= {pushB_delayed[1:0], quadB};


wire count_enable = quadA_delayed[1] ^ quadA_delayed[2] ^ quadB_delayed[1] ^ quadB_delayed[2];
wire count_direction = quadA_delayed[1] ^ quadB_delayed[2];

wire volume_enable = pushA_delayed[1] ^ pushA_delayed[2] ^ pushB_delayed[1] ^ pushB_delayed[2];
wire volume_direction = pushA_delayed[1] ^ pushB_delayed[2];

reg [7:0] count;
reg [7:0] volume;

wire rgb;

always @(posedge hfclk)
begin
if(count_enable)
begin
if(count_direction)
begin
if (count < 165)
count<=count+1;
end
else
begin
if (count > 0)
count<=count-1;
end
end
end

always @(posedge hfclk)
begin
if(volume_enable)
begin
if(volume_direction)
begin
if (volume < 191)
volume<=volume+1;
end
else
begin
if (volume > 0)
volume<=volume-1;
end
end
end


ws2811 rgb_ring (
.wsclk(hfclk),
.reset(1'b0),
.DO(rgb),
.red_in(count),
.green_in(count),
.blue_in(count),
.volume(volume)
);

SB_HFOSC OSCInst0 (
.CLKHF_EN(1'b1),
.CLKHF_PU(1'b1),
.CLKHF(hfclk)
);

endmodule
 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #3 on: April 02, 2018, 02:33:17 pm »
You shouldn't have an underscore in CLKHF_EN or CLKHF_PU - it should just be CLKHFEN and CLKHFPU.

FYI, the official reference for these things is the Technology Library document - http://www.latticesemi.com/view_document?document_id=52206.
« Last Edit: April 02, 2018, 02:36:08 pm by daveshah »
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #4 on: April 03, 2018, 10:26:30 am »
Thanks for the pointer (o;

Though getting now with P&R:

Code: [Select]
I2100: Reading design library: //VMWARE-host/Shared Folders/Downloads/icecube/quad/quad/quad_Implmnt\sbt\netlist\oadb-quad/BFPGA_DESIGN_ep
The master file does not exist
oaInterface::OpenLib_Design OpenDesign failed //VMWARE-host/Shared Folders/Downloads/icecube/quad/quad/quad_Implmnt\sbt\netlist\oadb-quad BFPGA_DESIGN_ep quad INTERFACE

This stupid icecube2 software is killing me, sad this device isn't supported in ice storm yet...


Correction: Seems iCEcube doesn't like VMWare shares (o;


« Last Edit: April 03, 2018, 10:37:39 am by davorin »
 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #5 on: April 03, 2018, 10:45:45 am »
Mapping it as a network drive will probably solve that problem, it should then just appear as a normal drive with a letter. Icecube is certainly not the first program I've seen with UNC path issues.
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #6 on: April 03, 2018, 11:07:07 am »
Is there a difference in Verflog language interpretation between Quarts and iCEcube besides iCEcube is using Synplify?

For example this design https://github.com/dhrosa/ws2812-verilog/blob/master/ws2811.v works fine in Quarts...but does nothing in iCEcube besides using up space (o;

 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #7 on: April 03, 2018, 12:18:56 pm »
I don't think there is any difference that would be significant enough to stop that design from working. It's more likely another issue. Is that design passing timing on the iCE40?
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #8 on: April 03, 2018, 07:06:54 pm »
Stupid question...but does iCEcube2 really support several verilog files?

Have now both HF and LF clock running, and feeding them for example to a 10-bit counter and route the MSB to a pin, I can see the clock...
but seems everything clocking a submodule in a separate file doesn't gets feeded by the clock...

From regular FPGA software there is always an option to set the top design entry...which is missing here...

What does actually this mean during synthesis?

Code: [Select]
@W: MT420 |Found inferred clock quad|clk_inferred_clock with period 83.32ns. Please declare a user-defined clock on object "n:clk"
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #9 on: April 03, 2018, 08:30:31 pm »
I never liked Synplify in the past ;-)

Seems others like Quartus and Lattice Diamond are initializing a state machine by default, whereas Synplify just leaves it...so the ws2812 state machine stays always in an undefined state...

Is there some internal /reset signal that can be used on the ICE40 devices?

 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3146
  • Country: ca
Re: Lattice iCE40 Ultra internal oscillator
« Reply #10 on: April 04, 2018, 12:42:45 am »
Seems others like Quartus and Lattice Diamond are initializing a state machine by default, whereas Synplify just leaves it...so the ws2812 state machine stays always in an undefined state...

I don't know if this is of any interest to you, but PIC16 can drive WS8212 using just 2 logic cells:

http://ww1.microchip.com/downloads/en/AppNotes/00001606A.pdf

 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #11 on: April 04, 2018, 06:35:23 pm »
I never liked Synplify in the past ;-)

Seems others like Quartus and Lattice Diamond are initializing a state machine by default, whereas Synplify just leaves it...so the ws2812 state machine stays always in an undefined state...

Is there some internal /reset signal that can be used on the ICE40 devices?



All flip-flops in the iCE40 initialise to zero when the FPGA is configured. If you need a flip-flop to be initialised to 1, an inverter must be inserted before and after this (AIUI both Synplify and LSE will do this for you if you specify an initial value of 1). There is no internal global reset signal, the only way to force a reset of the chip is to reconfigure it using the external CRESET signal, or the internal WARMBOOT primitive - the latter will only work when configuring from SPI flash, the former will work for both SPI flash and NVCM. Normally if you need a global reset you would connect a reset signal to all flip-flops, and this would use one of the 8 general global routing nets (shared with clocks, clock enables and other high-fanout signals).
 
The following users thanked this post: edavid

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #12 on: April 04, 2018, 08:21:27 pm »
Well seems you have a deep knowledge about iCE40 devices. Just got my company to order another iCE40 eval board as I very like the small form factor and features you never find in CPLDs.

Now I have to figure out why the RAM initialisation with a custom RGB color map doesn't work as it does with Altera. I will say Intel FPGA when there will be an FPGA with Intel 4-core inside ;-)
 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #13 on: April 04, 2018, 09:18:03 pm »
The iCE40 devices really are great for a lot of applications - CPLD simplicity and pricing, but large enough to contain a RISC-V processor with custom logic. This works even better with the extra 128kB SPRAM in the UltraPlus.

In terms of the BRAM there are two issues to be aware of. Firstly there is a small delay (a couple of us IIRC) between configuration finishing and the block RAM actually being initialised - if you need initialised block RAM it is best to keep you logic in reset, and keep RCLKE and WCLKE deasserted for a few us after startup.

Secondly, and more likely the problem you are facing, the Lattice tools are a bit fussy about initialisation of BRAMs in initial blocks. Using an "initial $readmemh" initialisation should work though.
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #14 on: April 04, 2018, 10:07:42 pm »
Ah good to know...

Is there a good chance the other ICE40 devices will soon be supported in icestorm like the ICE5LP devices?

Sad all ICE40 eval boards from Lattice are expensive compared to the used chip costs...time to fire up kicad and do something similar like those nice and small MAX1000/CYC1000 boards from Trenz Electronics Germany ;-)
 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #15 on: April 05, 2018, 08:11:46 am »
I don't know if I will have time to work on adding more devices in the short term, although I know someone who might take this on. A lot of the UltraPlus work could be reused for the Ultra and UltraLite.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4784
  • Country: pm
  • It's important to try new things..
Re: Lattice iCE40 Ultra internal oscillator
« Reply #16 on: April 06, 2018, 09:47:09 pm »
.. large enough to contain a RISC-V processor with custom logic. This works even better with the extra 128kB SPRAM in the UltraPlus..
You cannot initialize the 128kB of SPRAM off the bitstream, however..
 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #17 on: April 07, 2018, 06:28:23 am »
No, but most applications with it will have an external SPI flash - these days a QSPI flash is sufficiently cheap that you can use it both for bitstream storage and code (most code can run directly off the flash, performance-critical code can be copied to RAM by software). Clifford has a QSPI memory mapped controller (supporting regular SPI and dual SPI too) as part of picosoc
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #18 on: April 07, 2018, 12:41:37 pm »
[quote
You cannot initialize the 128kB of SPRAM off the bitstream, however..
[/quote]

Ehm....you cannot initialise sysMEM contents?

Well..didn't work for me so far...but TN1250 states:

Code: [Select]
sysMEM memories can be initialized as needed. The initialization can be achieved through HDL (Verilog or VHDL) by specifying the initial values or through an initialization file (.mem file).
 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #19 on: April 07, 2018, 01:07:28 pm »
 imo was referring to initialising the extra 128kB of SPRAM in the iCE40 UltraPlus. It is definitely possible to initialise the normal block RAM from HDL. Can you post an example of the HDL file giving you trouble?
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #20 on: April 07, 2018, 02:05:56 pm »
The RAM initialization looks like this for a rgb led colormap:

Code: [Select]
SB_RAM256x16   rg_ram (
      .RDATA(rgbdata[23:8]),
      .RADDR(counter),
      .RCLK(clk),
      .RCLKE(1'b1),
      .RE(1'b1)
);
defparam rg_ram.INIT_0 = 256'h00000004001000150019001d0026002a002e0033003f0043004800540059005d;
defparam rg_ram.INIT_1 = 256'h0061006a006e00720077007f0087008c0098009d00a100a500ae00b200b600bb;
defparam rg_ram.INIT_2 = 256'h00c300c700d800dc00e100e500e900f200f600fa00ff00ff00ff00ff00ff00ff;
defparam rg_ram.INIT_3 = 256'h00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff;
defparam rg_ram.INIT_4 = 256'h00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff;
defparam rg_ram.INIT_5 = 256'h00ff00ff00ff00ff08ff0cff15ff19ff1dff2aff2eff33ff37ff3fff43ff48ff;
defparam rg_ram.INIT_6 = 256'h4cff59ff5dff61ff6eff72ff77ff7bff83ff87ff8cff90ff99ffa1ffa5ffb2ff;
defparam rg_ram.INIT_7 = 256'hb6ffbbffbfffc7ffcbffd0ffd4ffddffe1fff2fff6fffafffffffffafff2ffee;
defparam rg_ram.INIT_8 = 256'hffe9ffe5ffddffd8ffd4ffc7ffbfffbbffb2ffaeffaaffa5ffa1ff99ff94ff90;
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #21 on: April 07, 2018, 04:17:52 pm »
Ah this diamond standalone programmer is just a pita...maybe one out of 4 attempts work...

Would the "iceprog" tool also work for other Lattice ice40 (non-supported icestorm devices) breakout boards for programming the spi flash or are then any incompatibilities with the binary file?
At least reading out the ID seems to work nicely...

Code: [Select]
me@debian:~$ iceprog -d i:0x0403:0x6010 -v -t
init..
cdone: high
reset..
cdone: low
flash ID: 0x20 0xBA 0x16 0x10 0x00 0x00 0x23 0x54 0x93 0x93 0x13 0x00 0x16 0x00 0x35 0x19 0x01 0x16 0x7C 0x7B
cdone: high
Bye.
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #22 on: April 07, 2018, 04:38:30 pm »
Yepp..iceprog nicely programs the spi flash form the ICE5LP breakout board ;-)

Code: [Select]
me@debian:/home2/Develop/fpga/icecube/quad/quad/quad_Implmnt/sbt/outputs$ iceprog -d i:0x0403:0x6010 bitmap/quad_bitmap.bin
init..
cdone: high
reset..
cdone: low
flash ID: 0x20 0xBA 0x16 0x10 0x00 0x00 0x23 0x54 0x93 0x93 0x13 0x00 0x16 0x00 0x35 0x19 0x01 0x16 0x7C 0x7B
file size: 71338
erase 64kB sector at 0x000000..
erase 64kB sector at 0x010000..
programming..
reading..
VERIFY OK
cdone: high
Bye.
 

Offline daveshah

  • Supporter
  • ****
  • Posts: 356
  • Country: at
    • Projects
Re: Lattice iCE40 Ultra internal oscillator
« Reply #23 on: April 07, 2018, 05:53:11 pm »
Thanks for testing iceprog! Good to see that it works. I can't see anything obviously wrong with your HDL.

Do you have the latest (git) version of icestorm installed? If so, you should be able to unpack the bitstream to a text format using iceunpack (it supports bitstream unpack/pack for iCE40 Ultra, but nothing more) and see if the RAM initialisation data is present or not in the output. Otherwise you can send the bitstream to me and I'll take a look.
 

Offline davorinTopic starter

  • Supporter
  • ****
  • Posts: 922
  • Country: ch
Re: Lattice iCE40 Ultra internal oscillator
« Reply #24 on: April 08, 2018, 10:19:36 am »
The sysMEM initialisation works now....had a typo (o;

Now the colormap looks different on the WS2812 LEDs compared to the MAX10 design...

In the initialization statements in Verilog, how are the hex bytes mapped?

Code: [Select]
defparam rg_ram.INIT_0 = 256'h00000004001000150019001d0026002a002e0033003f0043004800540059005d;

Is the first hex byte 15:8 and the second one 7:0?

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf