Use new port/param overload in pmg
authorEddie Hung <eddie@fpgeh.com>
Fri, 20 Sep 2019 21:21:22 +0000 (14:21 -0700)
committerEddie Hung <eddie@fpgeh.com>
Fri, 20 Sep 2019 21:21:22 +0000 (14:21 -0700)
passes/pmgen/ice40_dsp.pmg
passes/pmgen/xilinx_dsp.cc
passes/pmgen/xilinx_dsp.pmg
passes/pmgen/xilinx_srl.pmg

index 19ee9054b813f38a2d16454119eb8af73cb93d37..046aae9e25a0f8399f59c77038aae4fad8625ddf 100644 (file)
@@ -225,9 +225,9 @@ endcode
 code argD ffO ffOholdmux ffOrstmux ffOholdpol ffOrstpol sigO sigCD clock clock_pol cd_signed o_lo
        if (mul->type != \SB_MAC16 ||
                        // Ensure that register is not already used
-                       ((mul->parameters.at(\TOPOUTPUT_SELECT, 0).as_int() != 1 && mul->parameters.at(\BOTOUTPUT_SELECT, 0).as_int() != 1) &&
+                       ((param(mul, \TOPOUTPUT_SELECT, 0).as_int() != 1 && param(mul, \BOTOUTPUT_SELECT, 0).as_int() != 1) &&
                         // Ensure that OLOADTOP/OLOADBOT is unused or zero
-                        (mul->connections_.at(\OLOADTOP, State::S0).is_fully_zero() && mul->connections_.at(\OLOADBOT, State::S0).is_fully_zero()))) {
+                        (port(mul, \OLOADTOP, State::S0).is_fully_zero() && port(mul, \OLOADBOT, State::S0).is_fully_zero()))) {
 
                dff = nullptr;
 
index 1612b66ec174f6d031c9b822d602fe2cc4ad6b06..9d0a77e2b210042f47fa3e940c7bb28f0fe81fed 100644 (file)
@@ -290,7 +290,7 @@ void pack_xilinx_dsp(xilinx_dsp_pm &pm)
                st.sigD.extend_u0(25, D_SIGNED);
                cell->setPort(ID(A), st.sigA);
                cell->setPort(ID(D), st.sigD);
-               cell->connections_.at(ID(INMODE)) = Const::from_string("00100");
+               cell->setPort(ID(INMODE), Const::from_string("00100"));
 
                if (st.ffAD) {
                        if (st.ffADcemux) {
index 7d34c6a78a18f02687375768dddea57f2d685277..bb29bdd997beb0f941ca53249daebad9dcb8a046 100644 (file)
@@ -42,7 +42,7 @@ code sigA sigB sigC sigD sigM
        sigD = dsp->connections_.at(\D, SigSpec());
 
        SigSpec P = port(dsp, \P);
-       if (dsp->parameters.at(\USE_MULT, Const("MULTIPLY")).decode_string() == "MULTIPLY") {
+       if (param(dsp, \USE_MULT, Const("MULTIPLY")).decode_string() == "MULTIPLY") {
                // Only care about those bits that are used
                int i;
                for (i = 0; i < GetSize(P); i++) {
@@ -79,8 +79,8 @@ endcode
 match preAdd
        if sigD.empty() || sigD.is_fully_zero()
        // Ensure that preAdder not already used
-       if dsp->parameters.at(\USE_DPORT, Const("FALSE")).decode_string() == "FALSE"
-       if dsp->connections_.at(\INMODE, Const(0, 5)).is_fully_zero()
+       if param(dsp, \USE_DPORT, Const("FALSE")).decode_string() == "FALSE"
+       if port(dsp, \INMODE, Const(0, 5)).is_fully_zero()
 
        select preAdd->type.in($add)
        // Output has to be 25 bits or less
@@ -348,7 +348,7 @@ endcode
 
 match overflow
        if ffP
-       if dsp->parameters.at(\USE_PATTERN_DETECT, Const("NO_PATDET")).decode_string() == "NO_PATDET"
+       if param(dsp, \USE_PATTERN_DETECT, Const("NO_PATDET")).decode_string() == "NO_PATDET"
        select overflow->type.in($ge)
        select GetSize(port(overflow, \Y)) <= 48
        select port(overflow, \B).is_fully_const()
index b18119b872b191346af82b2c6d2161bd0e216f38..535b3dfdcca8830ab9ffdce5b27d4660ecbce468 100644 (file)
@@ -13,9 +13,9 @@ endcode
 match first
        select first->type.in($_DFF_N_, $_DFF_P_, $_DFFE_NN_, $_DFFE_NP_, $_DFFE_PN_, $_DFFE_PP_, \FDRE, \FDRE_1)
        select !first->has_keep_attr()
-       select !first->type.in(\FDRE) || !first->parameters.at(\IS_R_INVERTED, State::S0).as_bool()
-       select !first->type.in(\FDRE) || !first->parameters.at(\IS_D_INVERTED, State::S0).as_bool()
-       select !first->type.in(\FDRE, \FDRE_1) || first->connections_.at(\R, State::S0).is_fully_zero()
+       select !first->type.in(\FDRE) || !param(first, \IS_R_INVERTED, State::S0).as_bool()
+       select !first->type.in(\FDRE) || !param(first, \IS_D_INVERTED, State::S0).as_bool()
+       select !first->type.in(\FDRE, \FDRE_1) || port(first, \R, State::S0).is_fully_zero()
        filter !non_first_cells.count(first)
 generate
        SigSpec C = module->addWire(NEW_ID);
@@ -84,9 +84,9 @@ arg en_port
 match first
        select first->type.in($_DFF_N_, $_DFF_P_, $_DFFE_NN_, $_DFFE_NP_, $_DFFE_PN_, $_DFFE_PP_, \FDRE, \FDRE_1)
        select !first->has_keep_attr()
-       select !first->type.in(\FDRE) || !first->parameters.at(\IS_R_INVERTED, State::S0).as_bool()
-       select !first->type.in(\FDRE) || !first->parameters.at(\IS_D_INVERTED, State::S0).as_bool()
-       select !first->type.in(\FDRE, \FDRE_1) || first->connections_.at(\R, State::S0).is_fully_zero()
+       select !first->type.in(\FDRE) || !param(first, \IS_R_INVERTED, State::S0).as_bool()
+       select !first->type.in(\FDRE) || !param(first, \IS_D_INVERTED, State::S0).as_bool()
+       select !first->type.in(\FDRE, \FDRE_1) || port(first, \R, State::S0).is_fully_zero()
 endmatch
 
 code clk_port en_port
@@ -111,10 +111,10 @@ match next
        index <SigBit> port(next, \Q) === port(first, \D)
        filter port(next, clk_port) == port(first, clk_port)
        filter en_port == IdString() || port(next, en_port) == port(first, en_port)
-       filter !first->type.in(\FDRE) || next->parameters.at(\IS_C_INVERTED, State::S0).as_bool() == first->parameters.at(\IS_C_INVERTED, State::S0).as_bool()
-       filter !first->type.in(\FDRE) || next->parameters.at(\IS_D_INVERTED, State::S0).as_bool() == first->parameters.at(\IS_D_INVERTED, State::S0).as_bool()
-       filter !first->type.in(\FDRE) || next->parameters.at(\IS_R_INVERTED, State::S0).as_bool() == first->parameters.at(\IS_R_INVERTED, State::S0).as_bool()
-       filter !first->type.in(\FDRE, \FDRE_1) || next->connections_.at(\R, State::S0).is_fully_zero()
+       filter !first->type.in(\FDRE) || param(next, \IS_C_INVERTED, State::S0).as_bool() == param(first, \IS_C_INVERTED, State::S0).as_bool()
+       filter !first->type.in(\FDRE) || param(next, \IS_D_INVERTED, State::S0).as_bool() == param(first, \IS_D_INVERTED, State::S0).as_bool()
+       filter !first->type.in(\FDRE) || param(next, \IS_R_INVERTED, State::S0).as_bool() == param(first, \IS_R_INVERTED, State::S0).as_bool()
+       filter !first->type.in(\FDRE, \FDRE_1) || port(next, \R, State::S0).is_fully_zero()
 endmatch
 
 code
@@ -138,10 +138,10 @@ match next
        index <SigBit> port(next, \Q) === port(chain.back(), \D)
        filter port(next, clk_port) == port(first, clk_port)
        filter en_port == IdString() || port(next, en_port) == port(first, en_port)
-       filter !first->type.in(\FDRE) || next->parameters.at(\IS_C_INVERTED, State::S0).as_bool() == first->parameters.at(\IS_C_INVERTED, State::S0).as_bool()
-       filter !first->type.in(\FDRE) || next->parameters.at(\IS_D_INVERTED, State::S0).as_bool() == first->parameters.at(\IS_D_INVERTED, State::S0).as_bool()
-       filter !first->type.in(\FDRE) || next->parameters.at(\IS_R_INVERTED, State::S0).as_bool() == first->parameters.at(\IS_R_INVERTED, State::S0).as_bool()
-       filter !first->type.in(\FDRE, \FDRE_1) || next->connections_.at(\R, State::S0).is_fully_zero()
+       filter !first->type.in(\FDRE) || param(next, \IS_C_INVERTED, State::S0).as_bool() == param(first, \IS_C_INVERTED, State::S0).as_bool()
+       filter !first->type.in(\FDRE) || param(next, \IS_D_INVERTED, State::S0).as_bool() == param(first, \IS_D_INVERTED, State::S0).as_bool()
+       filter !first->type.in(\FDRE) || param(next, \IS_R_INVERTED, State::S0).as_bool() == param(first, \IS_R_INVERTED, State::S0).as_bool()
+       filter !first->type.in(\FDRE, \FDRE_1) || port(next, \R, State::S0).is_fully_zero()
 generate
        Cell *cell = module->addCell(NEW_ID, chain.back()->type);
        cell->setPort(\C, chain.back()->getPort(\C));
@@ -149,7 +149,7 @@ generate
        cell->setPort(\Q, chain.back()->getPort(\D));
        if (cell->type == \FDRE) {
                if (rng(2) == 0)
-                       cell->setPort(\R, chain.back()->connections_.at(\R, State::S0));
+                       cell->setPort(\R, port(chain.back(), \R, State::S0));
                cell->setPort(\CE, chain.back()->getPort(\CE));
        }
        else if (cell->type.begins_with("$_DFFE_"))