Datapath threshold flag jump

Example of using datapath threshold flag to branch (asserted when the ALU detects a sign change). Stage_A input results in several sign changes as output goes from positive to negative and back

Download this project

Program Listing

    // [title] Datapath threshold flag jump
// [brief] Example of using datapath threshold flag to branch (asserted when the ALU detects a sign change). Stage_A input results in several sign changes as output goes from positive to negative and back
// [categories] Examples - jump conditions

init:
    // ----------------------------------------
    // Load the next Stage_A value and subtract
    // [SUBTRACTION_VAL_1] in DataRam_A from it
    // ----------------------------------------

    // Initialize
    // [acu]    Ensure we are positioned on [SUBTRACTION_VAL_1] at 0x00
    acu(clear, clear) dmux(sa, sa) alu(hold) mac(hold)
        
    // [dmux].a     Set up to read bus Stage_A to ALU
    // [dmux].b     Set up to read [SUBTRACTION_VAL_1] from DataRam_A to ALU
    // [alu]        Set up to subtract b from a with threshold detection
    acu(hold, hold) addr(1) dmux(ba, sra) alu(tsubb) mac(hold)

    // Pipeline delay
    // [alu]        Data values are loaded off the datapath
    acu(hold, hold) dmux(sa, sa) alu(hold) mac(hold)

     // Conditional jump: Is dpthresh asserted?
    //              [true]  Jump to [sign_changed]
    //              [false] Fall through to [sign_did_not_change]
    // [alu]        ALU output is put on the datapath
    acu(hold, hold) dmux(sa, sa) alu(hold) mac(hold) jmp(dpthresh, sign_changed)

sign_did_not_change:
    // --------------------------------------------------
    // This branch is entered when [alu].a - [alu].b >= 0
    // --------------------------------------------------

    // Unconditional jump: return to [init]
    acu(hold, hold) dmux(sa, sa) alu(hold) mac(hold) jmp(eob, init)

sign_changed:
    // --------------------------------------------------
    // This branch is entered when [alu].a - [alu].b < 0
    // --------------------------------------------------

    // Unconditional jump: return to [init]
    acu(hold, hold) dmux(sa, sa) alu(hold) mac(hold) jmp(eob, init)

area data_b
org 0
dw 0x000004    // [SUBTRACTION_VAL_1]

  

State Diagrams

Jump Diagram

Your browser does not support SVG
Call Diagram for this program from the DFB Assembler Mini IDE