Shop OBEX P1 Docs P2 Docs Learn Events
An implementation of MUL / MULS — Parallax Forums

An implementation of MUL / MULS

Willy EkerslykeWilly Ekerslyke Posts: 29
edited 2014-09-29 10:58 in Propeller 1
I've implemented the MUL / MULS instruction. See attached zip for the modified cog.v and cog_alu.v files. I've marked the non-obvious changes with a // MUL comment. There's also a .spin test program that I used but it outputs to the 16x2 LCD on my Cyclone III board so you'll have to change it to suit your output device.

It's a full 32 x 32 bit multiplier so I've used the carry effect (wc) bit to select which 32 bits become the result: wc == 1 -> high 32 bits, wc == 0 -> low 32-bits. The zero flag is set (if enabled) according to the full 64-bit result. The carry flag always remains unaltered.

Uses 8 multiplier elements per COG. I've not done any speed assessments but as it's almost certainly the slowest part of the ALU it will undoubtedly limit the max COG clock.

Comments

  • nutsonnutson Posts: 242
    edited 2014-08-25 03:54
    Well done, and a very clear and comprehensive testprogram.
  • ozpropdevozpropdev Posts: 2,792
    edited 2014-08-25 03:54
    Nice work Willy! :)
  • pik33pik33 Posts: 2,366
    edited 2014-08-25 03:55
    Good work. Downloaded :)

    I will add this to my p1v and test.

    So far we have: unscrambled rom, portb and mul plus these less-than-8-cogs versions...
  • Cluso99Cluso99 Posts: 18,069
    edited 2014-08-25 04:44
    Fantastic work Willy!

    We also have >2KB per cog, VGA for a single cog (or other mix).
    Think there are a few other things done, including multiple P1s.
  • overclockedoverclocked Posts: 80
    edited 2014-08-25 05:20
    Just think of a simple GUI where one could via CheckBoxes/Dropdowns/Spinners could build a specific P1V using all efforts that been done here and all needed changes/defines is created for you.

    Some stuff is overlapping and would probably be non-trivial, but lots of stuff would just work I think.

    Some ideas:
    - Choose HubMem size
    - Choose number of COGs and customize every one of them of needed.
    - Choose which ROM-parts to include
  • markmark Posts: 252
    edited 2014-08-25 17:50
    Great stuff! Progress really is moving quickly.
  • boylansrboylansr Posts: 3
    edited 2014-09-27 09:57
    Sorry for coming late to the party, but in reading your code I think that the assign co statement should be changed to this:


    assign co = i[5:1] == 5'b00010 ? ci // mul: more selective -- pass through to ensure carry not altered
    : i[5:3] == 3'b000 ? bus_c
    : i[5:3] == 3'b001 ? rot_c
    : i[5:3] == 3'b011 ? log_c
    : add_c;

    If you test the i[5:3] before the i[5:1] in the case of your code co is always set to bus_c and not to ci or am I missing something?
  • Willy EkerslykeWilly Ekerslyke Posts: 29
    edited 2014-09-28 07:40
    boylansr wrote: »
    If you test the i[5:3] before the i[5:1] in the case of your code co is always set to bus_c and not to ci or am I missing something?

    I'm pretty sure my code is ok:
    assign co           = i[5:2] == 4'b0000     ? bus_c     // MUL: more selective
                        : i[5:1] == 5'b00010    ? ci        // MUL: pass through to ensure carry not altered
                        : i[5:3] == 3'b001      ? rot_c
                        : i[5:3] == 3'b011      ? log_c
                                                : add_c;
    

    bus_c is only selected if the four bits 5:2 are all zero otherwise ci is selected if the five bits 5:1 are 00010 etc.
  • boylansrboylansr Posts: 3
    edited 2014-09-28 10:47
    Ok, I must of made a typo when I enter your code to my file -- I[2] would make the difference.
  • pik33pik33 Posts: 2,366
    edited 2014-09-29 10:58
    Added to my p1v and tested - it works :)
Sign In or Register to comment.