Shop OBEX P1 Docs P2 Docs Learn Events
Custom P1 Verilog code generator — Parallax Forums

Custom P1 Verilog code generator

ozpropdevozpropdev Posts: 2,792
edited 2015-08-27 11:00 in Propeller 1
Hi All

This is a tool for generating Verilog code for a P1V based on the configuration set by the user.
It uses Chip's "master" Verilog files as the base code and makes the necessary changes to it to accommodate the options needed.
All changes are marked in the cod e bu a "<=-" marker with a reason for the change.
The tool can load modified .binary images from Propeller Tool to allow modification of the rom contents.

Here's an example of the commands needed to build a custom P1 with 4 cogs, 3 counters per cog, PortB added, no video and 60K hub ram.
The target FPGA is a BeMicro CV in this example.
>new
>target cv
>video -
>portb +
>cogs 4
>ctr 3
>hub 60
>dest c:\p1_fpga\test
>rom myrom
>build

It's a little "rough" around the edges but served me well in getting the Max10 P1 up and running.
I'm putting some notes together on using Quartus II and it quirks (there's a few).
Feel free to quiz me on any aspect of the tool as documentation is not my strongest skill. :)

Cheers
Brian

Latest version 0.21 16th April 2015
See here
«1

Comments

  • TubularTubular Posts: 4,702
    edited 2015-03-06 03:48
    This looks so, so good Brian. A very nice bridge between the original verilog and something custom molded to suit individual needs.

    I think I just worked out what to do with my long weekend..
  • mindrobotsmindrobots Posts: 6,506
    edited 2015-03-06 05:33
    Thanks, Brian!!

    This looks like a lot of fun!

    To think I just got a BEMicro MAX10 to test it out on! I think I just figured out why my weekend got shorter.....
  • Kerry SKerry S Posts: 163
    edited 2015-03-06 05:53
    Great job Brian, Thanks for giving this to everyone.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-03-06 17:07
    Thanks Guys
    I just updated the docs to include the PLL multiplier/divider commands.
    A correction was also made to the MAKEROM command.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-03-06 20:28
    Excellent work Brian!
  • rjo__rjo__ Posts: 2,114
    edited 2015-03-10 17:01
    Brian,

    Really nice.

    Just got back from vacation and couldn't wait to try it out. The instructions are very clear. Everything installs and runs first time:)

    When using "portb +", the dig.inc file doesn't get generated.
    Also, in your instructions, I think you should mention setting the project to SystemVerilog.

    One of the most confusing aspects for a newcomer is pin assignments... For example getting the P1v onto Parallax's de2-115 adapter was a major pain. So... having this as command option would be sweet.

    I've also grown very fond of using .bsf files... so having the option to generate a symbolic version of the project would also whittle away the learning curve and let a newbie concentrate on more interesting issues first.

    Thank you!

    Rich
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-03-10 18:07
    Rich
    I forgot to mention the dig.inc file generation procedure in the docs.
    It can be done by Quartus by opening the dig.v file and then doing the following from the menu.
    File - Create/Update - Create AHDL include files for the current file.
    I am currently tweaking the code to enhance it a bit. 'll add the dig.inc file generation too.

    On the subject of pin assignment that's what I am currently working on at the moment.
    The idea is to avoid using Quarus's clunky schematic editor and speed things up a lot.
    Fore example a target associated file is loaded with all the "toys" of the target board.
    To add a LED to your project you would simply do one of the following variants
    >add led    'add first available led to first available port a pin
    >add led4    'add led4 to first available porta pin
    >add led a6   'add first available led to port a bit 6
    >add led7 a22   'add led7 to port a bit 22
    
    or to add a device a similar procedure
    
    >add ad5681    'add add5681 device to first available port a pins
    add ad5681 a16   'add device pins starting at port a bit 16
    
    Some other assorted associated commands for removing,moving,swapping and compacting pins are also in the mix.
    A new command generates a .qsf pin assignment file and another command generates a .spin CON block with all the definitions used in the project.
    I hope to have this all done by the end of the week.

    Cheers
    Brian
  • rjo__rjo__ Posts: 2,114
    edited 2015-03-10 19:26
    Brian...

    You make me smile from ear to ear. Have some coffee:)

    Rich
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-05 03:11
    Hi All
    I'm just finishing up some testing on the revised version of the Verilog code generator.
    I got caught up in trying to get more than 8 cogs. Temporarily skipped that for the moment
    and will come back to that later.

    So here's some of the additions.
    Support for larger hub memory models >64k.
    Pin assignment tools to rapidly generate qsf files for Quatus.
    Asymmetrical cog support. (Mixed features per cog i.e. Video, Counters, Ports, ALU)
    and lots of little tweaks to operation.

    Hope to have the associated documentation done in the next day or two.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-05 03:22
    Brian,
    What were your problems with trying more than 8 cog?
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-05 03:59
    Cluso99 wrote: »
    Brian,
    What were your problems with trying more than 8 cog?
    Basically I could never get Quartus to build a 16 cog P1V without huge compilation reports
    Status indicated that 8 cogs were built and the extra 8 were "synthesized away".
    The generate loop and all associated regs and buses in all associated .v files were expanded for the 16 cogs.
    It seems to be associated with missing clocks, but not 100% sure yet.
    Spent a huge amount of time on it with no results. I will come back to it though. :)
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-13 06:22
    Update: Version 0.2
    Here's the latest version of p1v_toolbox.

    What's new!
    Cogs can now be asymmetrical. Functions can be enabled/disabled per cog. i.e. video, counters, ports
    2 additional ports can be included now PortC and PortD for up to 128 I/O.
    Larger hub memory support (>64k) i.e. 128,256,512k depending on target.

    A quick pin assignment demo for a Nano board
    new demo1
    target 1
    toys
    add pb 1
    add led pa8 8
    savepins
    save
    build
    bye
    

    This will create a project in c:\p1_fpga\demo1.
    A single pushbutton attached to pa0
    Eight leds attached to pa8 to pa15
    Propplug is assigned by default.
    All relevant Verilog files (*.v, *.inc, *.tdf) ,pin assignment files (*.qsf) and a .spin file with clock and pin info.
    Create a new project in Quartus using the new toop.tdf file in the new folder.
    Import the pin assignments from the file demo1.qsf
    Use the device part number in the top.tdf file to set the device.
    Remember to select System Verilog in the settings.

    I think I've got the new commands covered in the docs. Apologies in advance if I'm unclear.
    Feel free to quiz me on any aspect of the tool.
    Have fun! :)

    Correction: Changed to 1 pushbutton from 2. Only 1 PB can be used on DE0-Nano
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-13 17:52
    WOW. You certainly have been busy Brian.
    I cannot wait to try it out, hopefully later today :)
  • TubularTubular Posts: 4,702
    edited 2015-04-13 18:34
    I had a quick play with this today.

    Very impressive, some really nice touches such as the MHZ selector that shows nearby ratios, and the MAP memory visualization command that shows the memory map clearly, and VIEW for the cog setup.

    Really well done... if you're able to run windows code this is well worth checking out
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-13 23:32
    One small issue to look out for when building p1v's with hub >64k.

    The standard P1 booter refers to address FFF9FFFF for the propeller version number.
                            rdbyte  bits,hFFF9FFFF          'get version byte at $FFFF
    
    The rom/ram decode usually "rolls over" so any access to addresses with the lower 16 bits
    set will normally return a 01 byte or the version number set by p1v_toolbox.
    The same applies to spin's "CHIPVER" function.

    With larger hub ram the decoding is modified to accommodate the larger address space.
    Because of this change then version number returned will always be 0.
    This is not a problem for Propeller Tool but causes issues with PropellerIDE.
    In PropellerIDE if the com port is set for "AUTO" the IDE does not detect a propeller.
    If using p1load.exe set the com port to your known com port and PropellerIDE will download to the propeller
    even though a "Identify Hardware" wont find the propeller.
    If using propellerloader.exe it doesn't seem to like a 0 version number at all.

    Here's a simple fix if it's a problem. In booter.spin make the following changes.
        ver_addr    long $ffff                    
        rdbyte  bits,ver_addr          'get version byte at $FFFF
    
    

    In Propeller Tool add a dummy PUB so it can compile the source and save as a .binary file.
    In p1v_toolbox use the loadbin command to load the rom image then use makerom or savehex to
    create a .hex file for use in your p1v.

    :)
  • nutsonnutson Posts: 242
    edited 2015-04-14 01:44
    Fantastic tool, ozpropdev, Thanks. I especially like the idea of "toys", makes the tool very open to expansion and practical experimentation

    What I don"t understand yet is the pin assignment thing. I made a P1Voz with ports B,C and D enabled, do see correct Verilog code, but no pin assignments. Do I have to add that manually in the Quartus pin editor, or in the toys???
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-14 03:16
    Thanks nutson
    In Quartus you need to import the pin assignments. From the menu >Assignments>Import Assignments..
    Make sure the device and device family are correct in the "Device" dialog.
    To verify the correct device is set use the >Assignments>Pin Planner functiom. You should see a top view of the device.
    After a "import" you will need to set the compiler for "Verilog HDL Input" to "System Verilog"
    In "Synthesis" settings make sure you also set "Block Design Naming" to" Quartus II".

    If you created a project called "p1voz" there should be a file called "p1voz.qsf".
    Check that this file contains the pin assignments you set. Let me know if it doesn't and I will check it further.

    Hope this helps :)
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-14 04:48
    I had a quick try and a look at the output Verilog files. Really nice job Brian.
    Had a couple of hiccups on install as I didn't put the files where you wanted originally. Done that now.
    Quick try with Quartus but no go. Didn't have time to see what didn't work. Maybe tomorrow.
    BTW I am on Windows 8.1 64bit. When downloading from the forum with IE it loses the download filename - get attachment.php but its all there when I rename it xxx.zip and xxx.txt. Bad windoze.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-14 06:10
    Cluso99 wrote: »
    Quick try with Quartus but no go. Didn't have time to see what didn't work. Maybe tomorrow.
    BTW I am on Windows 8.1 64bit. When downloading from the forum with IE it loses the download filename - get attachment.php but its all there when I rename it xxx.zip and xxx.txt. Bad windoze.
    Was your "no go" compiler errors or a nano fpga flat line? :(

    I get the same attachment.php issue with everything I download from the forum. Running Win 7 32 bit and IE11.
    I can't remember NOT having this download issue. A rename seems to work though.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-14 06:28
    Some peripherals ("toys") on the DE0-Nano board are connected to FPGA pins that are inputs only.
    These pins when assigned to P1V's bi-directional ports conflict and cause comile errors.
    So KEY1 and the DIPSW0..3 cannot be assigned for use with a P1V. :(
    I will check and see if we miss out on other toys on the DE2-115,DE0-CV,BeMicro CV & BeMicro Max10.
    Just delete these items from the nano.toys file.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-15 02:40
    Just been recompiling booter and runner.
    I realised you have a hub memory in the pc to represent the hub.
    So I have loaded up the hub rom section with what I want and have used dump to verify.
    When I went to save the resultant hex file it failed. After a few trials and errors I realised p1v_toolbox requires the file to pre-exist so it can overwrite the file.

    BTW this saves me a lot of work. Previously I have been using spin to save hex files from hub.
    Congratulations Brian.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-15 03:24
    Brian,
    If possible, I would love a simple command to store a byte into the hub ram/rom.
    It doesn't need to be complex as I don't intend to do much.
    It would be easier than editing a hex file and recalculate the checksum.

    BTW I am currently trying to reorganise hub rom $F004..FFFF to fit in my vector table.
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-15 07:06
    Ray
    I just added a byte entry command to the mix.
    >byte ff00 5a ff 2b bd 11
    
    FF00: 5A FF 2B BD 11
    Ok
    >
    
    It should do the trick! :)
    Cheers
    Brian
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-15 08:11
    Fantastic Thanks Brian.
    I will give it a go in the morning.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-15 18:27
    Brian, can I just copy the files or do I need to run setup again? and which files?
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-15 18:34
    Cluso99 wrote: »
    Brian, can I just copy the files or do I need to run setup again? and which files?
    Just extract the zip contents to c:\p1_fpga and run setup again.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-15 19:13
    I have tried all sorts of extracts, even renaming p1_fpga and then reinstalling into a new c:\p1_fpga
    Then run setup.exe from c:\p1_fpga
    BTW there is nothing displayed as/after it runs (after I give windoze the ok to run)
    It seems to always bring up v0.2 and not the new v021
    any ideas?
  • ozpropdevozpropdev Posts: 2,792
    edited 2015-04-15 19:34
    I just did a install on my Win 8.1 laptop.
    From the "Apps" screen I did a uninstall first of p1v_toolbox (Right click p1v_toolbox to select uninstall)
    This will take you to the "Programs and features" dialog. Scroll down to p1v_toolbox and right click on it to uninstall.
    I then double clicked the zip file and select "Extract" from the dialog box and then "Extract all".
    Using the "Browse" function to select the existing "c:\p1_fpga" folder.
    Then clicked "Extract" and agreed to replace files.
    Then ran setup from c:\p1_fpga and p1v_toolbox installs and starts.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-04-15 20:28
    I did all that except doing the uninstall, so will try that tomorrow.

    Btw dislike windoze 8.1. Even finding a new installed program is a chore.

    I have calculated if I break runner into 3 sections, I can fit my 254 long vector table
    Into $FBF8..FFF7. I have worked how to split runner :)
  • potatoheadpotatohead Posts: 10,261
    edited 2015-04-16 11:18
    Get one of the free shell utilities. http://www.classicshell.net/

    I set up a couple users with that one, and they are fine.
Sign In or Register to comment.