Introduce Pi Register model to PI Framework

Change-Id: I7fae87d5b5ed5fff34b3addfc148cee6fc98137c
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/PiRegisterProgrammable.java b/core/api/src/main/java/org/onosproject/net/behaviour/PiRegisterProgrammable.java
new file mode 100644
index 0000000..9a8a6b0
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/PiRegisterProgrammable.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.behaviour;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.net.driver.HandlerBehaviour;
+import org.onosproject.net.pi.model.PiRegisterId;
+import org.onosproject.net.pi.runtime.PiRegisterCell;
+import org.onosproject.net.pi.runtime.PiRegisterCellId;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Protocol-independent register programmable device behaviour.
+ */
+@Beta
+public interface PiRegisterProgrammable extends HandlerBehaviour {
+
+    /**
+     * Write a register cell of this device.
+     *
+     * @param entry register entry
+     * @return Completable future with result of the operation
+     */
+    CompletableFuture<Boolean> writeRegisterCell(PiRegisterCell entry);
+
+    /**
+     * Gets the register cell given the register cell ID from the device.
+     *
+     * @param cellId the register cell Id
+     * @return completable future with the register cell
+     */
+    CompletableFuture<PiRegisterCell> readRegisterCell(PiRegisterCellId cellId);
+
+    /**
+     * Gets the register cells given the collection of cellIds from the device.
+     *
+     * @param cellIds the collection of register cell Id
+     * @return completable future with the collection of register cells
+     */
+    CompletableFuture<Collection<PiRegisterCell>> readRegisterCells(Set<PiRegisterCellId> cellIds);
+
+    /**
+     * Gets all of the register cells given register ID from the device.
+     * @param registerId the identifier of register
+     * @return completable future with the collection of register cells
+     */
+    CompletableFuture<Collection<PiRegisterCell>> readRegisterCells(PiRegisterId registerId);
+
+    /**
+     * Gets all of the register cells from the device.
+     *
+     * @return completable future with the collection of register cells
+     */
+    CompletableFuture<Collection<PiRegisterCell>> readAllRegisterCells();
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineModel.java
index c1840d9..bddbae8 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineModel.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiPipelineModel.java
@@ -43,7 +43,7 @@
     Collection<PiTableModel> tables();
 
     /**
-     * Returns the counter model associated with the given ID, id present.
+     * Returns the counter model associated with the given ID, if present.
      *
      * @param counterId counter ID
      * @return optional counter model
@@ -58,7 +58,7 @@
     Collection<PiCounterModel> counters();
 
     /**
-     * Returns the meter model associated with the given ID, id present.
+     * Returns the meter model associated with the given ID, if present.
      *
      * @param meterId meter ID
      * @return optional meter model
@@ -73,7 +73,22 @@
     Collection<PiMeterModel> meters();
 
     /**
-     * Returns the action profile model associated with the given ID, id present.
+     * Returns the register model associated with the given ID, if present.
+     *
+     * @param registerId register ID
+     * @return optional register model
+     */
+    Optional<PiRegisterModel> register(PiRegisterId registerId);
+
+    /**
+     * Returns all register models defined by this pipeline model.
+     *
+     * @return collection of register models
+     */
+    Collection<PiRegisterModel> registers();
+
+    /**
+     * Returns the action profile model associated with the given ID, if present.
      *
      * @param actionProfileId action profile ID
      * @return optional action profile model
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiRegisterId.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiRegisterId.java
new file mode 100644
index 0000000..ea8ca6f
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiRegisterId.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+import org.onlab.util.Identifier;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Identifier of a register in a protocol-independent pipeline, unique within the scope of a pipeline model.
+ */
+@Beta
+public final class PiRegisterId extends Identifier<String> {
+
+    private PiRegisterId(String name) {
+        super(name);
+    }
+
+    /**
+     * Returns an identifier for the given register name.
+     *
+     * @param name register name
+     * @return register ID
+     */
+    public static PiRegisterId of(String name) {
+        checkNotNull(name);
+        checkArgument(!name.isEmpty(), "Name can't be empty");
+        return new PiRegisterId(name);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/PiRegisterModel.java b/core/api/src/main/java/org/onosproject/net/pi/model/PiRegisterModel.java
new file mode 100644
index 0000000..0da02fc
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/PiRegisterModel.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.model;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Model of a register in a protocol-independent pipeline.
+ */
+@Beta
+public interface PiRegisterModel {
+
+    /**
+     * Returns the ID of this register.
+     *
+     * @return register ID
+     */
+    PiRegisterId id();
+
+    /**
+     * Returns the number of cells of this register.
+     *
+     * @return size
+     */
+    long size();
+}
+
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntityType.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntityType.java
index 5ef452b..a6c612b 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntityType.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiEntityType.java
@@ -41,5 +41,10 @@
     /**
      * Meter config.
      */
-    METER_CELL_CONFIG
+    METER_CELL_CONFIG,
+
+    /**
+     * Register entry.
+     */
+    REGISTER_CELL
 }
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRegisterCell.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRegisterCell.java
new file mode 100644
index 0000000..fd354ec
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRegisterCell.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.runtime;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import org.onosproject.net.pi.model.PiData;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * A register cell entry of a protocol-independent pipeline.
+ */
+@Beta
+public final class PiRegisterCell implements PiEntity {
+
+    private final PiRegisterCellId registerCellId;
+    private final PiData piData;
+
+    private PiRegisterCell(PiRegisterCellId registerCellId, PiData piData) {
+        this.registerCellId = registerCellId;
+        this.piData = piData;
+    }
+
+    /**
+     * Returns the cell identifier.
+     *
+     * @return cell identifier
+     */
+    public PiRegisterCellId cellId() {
+        return registerCellId;
+    }
+
+    /**
+     * Returns the data contained by this cell ID.
+     *
+     * @return PI data or null
+     */
+    public PiData data() {
+        return piData;
+    }
+
+    @Override
+    public PiEntityType piEntityType() {
+        return PiEntityType.REGISTER_CELL;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final PiRegisterCell other = (PiRegisterCell) obj;
+        return Objects.equal(this.registerCellId, other.registerCellId) &&
+                Objects.equal(this.piData, other.piData);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(registerCellId, piData);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("cellId", registerCellId)
+                .add("piData", piData)
+                .toString();
+    }
+
+    /**
+     * Returns a register cell entry builder.
+     *
+     * @return a new builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static final class Builder {
+        private PiRegisterCellId cellId;
+        private PiData piData;
+
+
+        private Builder() {
+            // Hides constructor.
+        }
+
+        /**
+         * Sets the register cell identifier for this register.
+         *
+         * @param registerCellId register cell identifier
+         * @return this
+         */
+        public PiRegisterCell.Builder withCellId(PiRegisterCellId registerCellId) {
+            this.cellId = registerCellId;
+            return this;
+        }
+
+
+        /**
+         * Sets the data of this register cell.
+         *
+         * @param data protocol-independent data
+         * @return this
+         */
+        public PiRegisterCell.Builder withData(PiData data) {
+            this.piData = data;
+            return this;
+        }
+
+        /**
+         * Builds the register cell entry.
+         *
+         * @return a new register cell entry
+         */
+        public PiRegisterCell build() {
+            checkNotNull(cellId);
+            return new PiRegisterCell(cellId, piData);
+        }
+    }
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRegisterCellId.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRegisterCellId.java
new file mode 100644
index 0000000..e56aa17
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiRegisterCellId.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.net.pi.runtime;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import org.onosproject.net.pi.model.PiRegisterId;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Identifier of a register cell in a protocol-independent pipeline.
+ */
+@Beta
+public final class PiRegisterCellId {
+
+    private final PiRegisterId registerId;
+    private final long index;
+
+    private PiRegisterCellId(PiRegisterId registerId, long index) {
+        this.registerId = registerId;
+        this.index = index;
+    }
+
+    /**
+     * Returns the identifier of the register instance where this cell is
+     * contained.
+     *
+     * @return register identifier
+     */
+    public PiRegisterId registerId() {
+        return registerId;
+    }
+
+    /**
+     * Returns the register index to which this cell ID is associated.
+     *
+     * @return register index
+     */
+    public long index() {
+        return index;
+    }
+
+    /**
+     * Return a register cell ID for the given register ID and index.
+     *
+     * @param registerId register ID
+     * @param index     index
+     * @return register cell ID
+     */
+    public static PiRegisterCellId of(PiRegisterId registerId, long index) {
+        checkNotNull(registerId);
+        checkArgument(index >= 0, "Index must be a positive number");
+        return new PiRegisterCellId(registerId, index);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final PiRegisterCellId other = (PiRegisterCellId) obj;
+        return Objects.equal(this.registerId, other.registerId)
+                && Objects.equal(this.index, other.index);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(registerId, index);
+    }
+
+    @Override
+    public String toString() {
+        return registerId.toString() + ':' + String.valueOf(index);
+    }
+}
\ No newline at end of file
diff --git a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4InfoParser.java b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4InfoParser.java
index dd365f6..f8d6082 100644
--- a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4InfoParser.java
+++ b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4InfoParser.java
@@ -42,9 +42,12 @@
 import org.onosproject.net.pi.model.PiPacketOperationModel;
 import org.onosproject.net.pi.model.PiPacketOperationType;
 import org.onosproject.net.pi.model.PiPipelineModel;
+import org.onosproject.net.pi.model.PiRegisterId;
+import org.onosproject.net.pi.model.PiRegisterModel;
 import org.onosproject.net.pi.model.PiTableId;
 import org.onosproject.net.pi.model.PiTableModel;
 import org.onosproject.net.pi.model.PiTableType;
+import p4.config.P4InfoOuterClass;
 import p4.config.P4InfoOuterClass.Action;
 import p4.config.P4InfoOuterClass.ActionProfile;
 import p4.config.P4InfoOuterClass.ActionRef;
@@ -142,6 +145,10 @@
         meterMap.putAll(parseMeters(p4info));
         meterMap.putAll(parseDirectMeters(p4info));
 
+        // Registers.
+        final Map<Integer, PiRegisterModel> registerMap = Maps.newHashMap();
+        registerMap.putAll(parseRegisters(p4info));
+
         // Action profiles.
         final Map<Integer, PiActionProfileModel> actProfileMap = parseActionProfiles(p4info);
 
@@ -219,6 +226,9 @@
         ImmutableMap<PiMeterId, PiMeterModel> meterImmMap = ImmutableMap.copyOf(
                 meterMap.values().stream()
                         .collect(Collectors.toMap(PiMeterModel::id, m -> m)));
+        ImmutableMap<PiRegisterId, PiRegisterModel> registerImmMap = ImmutableMap.copyOf(
+                registerMap.values().stream()
+                        .collect(Collectors.toMap(PiRegisterModel::id, r -> r)));
         ImmutableMap<PiActionProfileId, PiActionProfileModel> actProfileImmMap = ImmutableMap.copyOf(
                 actProfileMap.values().stream()
                         .collect(Collectors.toMap(PiActionProfileModel::id, a -> a)));
@@ -227,6 +237,7 @@
                 tableImmMapBuilder.build(),
                 counterImmMap,
                 meterImmMap,
+                registerImmMap,
                 actProfileImmMap,
                 ImmutableMap.copyOf(pktOpMap));
     }
@@ -296,6 +307,17 @@
         return meterMap;
     }
 
+    private static Map<Integer, PiRegisterModel> parseRegisters(P4Info p4info)
+            throws P4InfoParserException {
+        final Map<Integer, PiRegisterModel> registerMap = Maps.newHashMap();
+        for (P4InfoOuterClass.Register registerMsg : p4info.getRegistersList()) {
+            registerMap.put(registerMsg.getPreamble().getId(),
+                            new P4RegisterModel(PiRegisterId.of(registerMsg.getPreamble().getName()),
+                                                registerMsg.getSize()));
+        }
+        return registerMap;
+    }
+
     private static Map<Integer, PiActionProfileModel> parseActionProfiles(P4Info p4info)
             throws P4InfoParserException {
         final Map<Integer, PiActionProfileModel> actProfileMap = Maps.newHashMap();
diff --git a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PipelineModel.java b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PipelineModel.java
index 622cc23..ce9ec13 100644
--- a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PipelineModel.java
+++ b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4PipelineModel.java
@@ -26,6 +26,8 @@
 import org.onosproject.net.pi.model.PiPacketOperationModel;
 import org.onosproject.net.pi.model.PiPacketOperationType;
 import org.onosproject.net.pi.model.PiPipelineModel;
+import org.onosproject.net.pi.model.PiRegisterId;
+import org.onosproject.net.pi.model.PiRegisterModel;
 import org.onosproject.net.pi.model.PiTableId;
 import org.onosproject.net.pi.model.PiTableModel;
 
@@ -41,6 +43,7 @@
     private final ImmutableMap<PiTableId, PiTableModel> tables;
     private final ImmutableMap<PiCounterId, PiCounterModel> counters;
     private final ImmutableMap<PiMeterId, PiMeterModel> meters;
+    private final ImmutableMap<PiRegisterId, PiRegisterModel> registers;
     private final ImmutableMap<PiActionProfileId, PiActionProfileModel> actionProfiles;
     private final ImmutableMap<PiPacketOperationType, PiPacketOperationModel> packetOperations;
 
@@ -48,11 +51,13 @@
             ImmutableMap<PiTableId, PiTableModel> tables,
             ImmutableMap<PiCounterId, PiCounterModel> counters,
             ImmutableMap<PiMeterId, PiMeterModel> meters,
+            ImmutableMap<PiRegisterId, PiRegisterModel> registers,
             ImmutableMap<PiActionProfileId, PiActionProfileModel> actionProfiles,
             ImmutableMap<PiPacketOperationType, PiPacketOperationModel> packetOperations) {
         this.tables = tables;
         this.counters = counters;
         this.meters = meters;
+        this.registers = registers;
         this.actionProfiles = actionProfiles;
         this.packetOperations = packetOperations;
     }
@@ -88,6 +93,16 @@
     }
 
     @Override
+    public Optional<PiRegisterModel> register(PiRegisterId registerId) {
+        return Optional.ofNullable(registers.get(registerId));
+    }
+
+    @Override
+    public Collection<PiRegisterModel> registers() {
+        return registers.values();
+    }
+
+    @Override
     public Optional<PiActionProfileModel> actionProfiles(PiActionProfileId actionProfileId) {
         return Optional.ofNullable(actionProfiles.get(actionProfileId));
     }
diff --git a/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4RegisterModel.java b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4RegisterModel.java
new file mode 100644
index 0000000..7e4fcda
--- /dev/null
+++ b/protocols/p4runtime/model/src/main/java/org/onosproject/p4runtime/model/P4RegisterModel.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.p4runtime.model;
+
+import org.onosproject.net.pi.model.PiRegisterModel;
+import org.onosproject.net.pi.model.PiRegisterId;
+
+import java.util.Objects;
+
+/**
+ * Implementation of PiRegisterModel for P4Runtime.
+ */
+final class P4RegisterModel implements PiRegisterModel {
+
+    private final PiRegisterId id;
+    private final long size;
+
+    P4RegisterModel(PiRegisterId id, long size) {
+        this.id = id;
+        this.size = size;
+    }
+
+    @Override
+    public PiRegisterId id() {
+        return id;
+    }
+
+    @Override
+    public long size() {
+        return size;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id, size);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final P4RegisterModel other = (P4RegisterModel) obj;
+        return Objects.equals(this.id, other.id)
+                && Objects.equals(this.size, other.size);
+    }
+}
\ No newline at end of file
diff --git a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4PipelineModelTest.java b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4PipelineModelTest.java
index 918e6e8..84d3af8 100644
--- a/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4PipelineModelTest.java
+++ b/protocols/p4runtime/model/src/test/java/org/onosproject/p4runtime/model/P4PipelineModelTest.java
@@ -41,6 +41,8 @@
 import org.onosproject.net.pi.model.PiPacketOperationModel;
 import org.onosproject.net.pi.model.PiPacketOperationType;
 import org.onosproject.net.pi.model.PiPipelineModel;
+import org.onosproject.net.pi.model.PiRegisterId;
+import org.onosproject.net.pi.model.PiRegisterModel;
 import org.onosproject.net.pi.model.PiTableId;
 import org.onosproject.net.pi.model.PiTableModel;
 import org.onosproject.net.pi.model.PiTableType;
@@ -142,6 +144,25 @@
                     .put(PI_METER_ID_2, P4_METER_MODEL_2)
                     .build();
 
+    /* Registers */
+    private static final PiRegisterId PI_REGISTER_ID_1 = PiRegisterId.of("Register1");
+    private static final PiRegisterId PI_REGISTER_ID_2 = PiRegisterId.of("Register2");
+
+    private static final long REGISTER_SIZE_1 = 1000;
+    private static final long REGISTER_SIZE_2 = 2000;
+
+    private static final P4RegisterModel P4_REGISTER_MODEL_1 = new P4RegisterModel(PI_REGISTER_ID_1, REGISTER_SIZE_1);
+    private static final P4RegisterModel P4_REGISTER_MODEL_2 = new P4RegisterModel(PI_REGISTER_ID_2, REGISTER_SIZE_2);
+
+    private static final ImmutableMap<PiRegisterId, PiRegisterModel> REGISTERS_1 =
+            new ImmutableMap.Builder<PiRegisterId, PiRegisterModel>()
+                    .put(PI_REGISTER_ID_1, P4_REGISTER_MODEL_1)
+                    .build();
+    private static final ImmutableMap<PiRegisterId, PiRegisterModel> REGISTERS_2 =
+            new ImmutableMap.Builder<PiRegisterId, PiRegisterModel>()
+                    .put(PI_REGISTER_ID_2, P4_REGISTER_MODEL_2)
+                    .build();
+
     /* Match Fields */
     private static final PiMatchFieldId PI_MATCH_FIELD_ID_1 = PiMatchFieldId.of("MatchField1");
     private static final PiMatchFieldId PI_MATCH_FIELD_ID_2 = PiMatchFieldId.of("MatchField2");
@@ -315,11 +336,11 @@
                     .build();
 
     private static final PiPipelineModel P4_PIPELINE_MODEL_1 =
-            new P4PipelineModel(TABLES_1, COUNTERS_1, METERS_1, ACTION_PROFILES_1, PACKET_OPERATIONS_1);
+            new P4PipelineModel(TABLES_1, COUNTERS_1, METERS_1, REGISTERS_1, ACTION_PROFILES_1, PACKET_OPERATIONS_1);
     private static final PiPipelineModel SAME_AS_P4_PIPELINE_MODEL_1 =
-            new P4PipelineModel(TABLES_1, COUNTERS_1, METERS_1, ACTION_PROFILES_1, PACKET_OPERATIONS_1);
+            new P4PipelineModel(TABLES_1, COUNTERS_1, METERS_1, REGISTERS_1, ACTION_PROFILES_1, PACKET_OPERATIONS_1);
     private static final PiPipelineModel P4_PIPELINE_MODEL_2 =
-            new P4PipelineModel(TABLES_2, COUNTERS_2, METERS_2, ACTION_PROFILES_2, PACKET_OPERATIONS_2);
+            new P4PipelineModel(TABLES_2, COUNTERS_2, METERS_2, REGISTERS_1, ACTION_PROFILES_2, PACKET_OPERATIONS_2);
 
     /**
      * Checks that the P4PipelineModel class is immutable.