-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
10,224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
% BitField Bit Field | ||
% F = BitField(WS,W,V) creates a bit field object F, with optional set of | ||
% expected bit widths WS, optional initial bit width W, and optional | ||
% initial value V. By default, WS is [], indicating no restriction on the | ||
% field width, and W is 1 bit or min(WS) if WS is not empty. The field | ||
% value defaults to 0 if not provided. | ||
% | ||
% BitField properties: | ||
% | ||
% Value - Integer field value (value can be assigned from a bit vector) | ||
% Width - Bit width of field | ||
% WidthValues - Set of expected, nominal bit widths for the field (Read-only) | ||
% | ||
% BitField methods: | ||
% | ||
% BitField - Class constructor | ||
% toBits - Map the field value to information bit vector | ||
% fromBits - Map the field value from information bit vector | ||
% info - Get information about the bit field | ||
% | ||
% Example: | ||
% % Create a BitField object where the field bit width is expected to be | ||
% % 0, 1, 5, or 10 bits. The initial width will be 0 (smallest of the set). | ||
% bf = BitField([0 1 5 10]); | ||
% | ||
% % Change width after construction to 5 bits. | ||
% bf.Width = 5; | ||
% | ||
% % Set the field value = 15, using a bit vector and then an integer. | ||
% bf.Value = [0 1 1 1 1]; | ||
% bf.Value = 15; | ||
% bf.Value = hex2dec('F'); | ||
% | ||
% % Map field value to bit vector. | ||
% bits = toBits(bf); | ||
% | ||
% See also MessageFormat. | ||
|
||
% Copyright 2021 The MathWorks, Inc. | ||
|
||
classdef BitField | ||
|
||
properties (Dependent) | ||
Value % Integer value of field | ||
Width % Bit width of field | ||
end | ||
|
||
properties (SetAccess = private) | ||
WidthValues = []; % Set of nominal widths defined for this field (Read-only) | ||
end | ||
|
||
methods | ||
|
||
% Constructor | ||
function obj = BitField(widthvalues,initwidth,initvalue) | ||
%BitField Construct an instance of BitField | ||
% F = BitField(WS,W,V) creates a bit field object F, with optional set of | ||
% expected bit widths WS, optional initial bit width W, and optional | ||
% initial value V. By default, WS is [], indicating no restriction on the | ||
% field width, and W is 1 bit or min(WS) if WS is not empty. The field | ||
% value defaults to 0 if not provided. | ||
if nargin > 0 | ||
obj.WidthValues = widthvalues; | ||
if nargin < 2 | ||
initwidth = min(widthvalues); % If initial width is not supplying then use smallest nominal width | ||
end | ||
obj.Width = initwidth; | ||
if nargin > 2 | ||
obj.Value = initvalue; | ||
end | ||
end | ||
end | ||
|
||
function ifo = info(obj,opts) | ||
% info Get information about the field (value, width, width set) | ||
if nargin > 1 && any(strcmpi(opts,{'width','fieldsizes'})) | ||
ifo = obj.Width; | ||
elseif nargin > 1 && any(strcmpi(opts,'widthvalues')) | ||
ifo = obj.WidthValues; | ||
else | ||
ifo = obj.Value; | ||
end | ||
end | ||
|
||
function bits = toBits(obj) | ||
% toBits Map field value into information bit vector (MSB maps to first bit in vector) | ||
|
||
% The most significant bit of each field is mapped to the lowest order information bit (i.e. first) of that field | ||
bits = int8(dec2bin(obj.Value,obj.Width) == '1')'; | ||
end | ||
|
||
function obj = fromBits(obj,B) | ||
% fromBits Turn information bit vector into field value (first bit in vector maps to MSB of value) | ||
wl = min(obj.Width,length(B)); | ||
obj.Value = sum(reshape(B(1:wl)~=0,1,[]).*2.^(wl-1:-1:0)); | ||
end | ||
|
||
% Set the field value from an integer or bit vector (modulo value by the field width) | ||
function obj = set.Value(obj,B) | ||
if length(B) > 1 | ||
wl = min(obj.Width,length(B)); | ||
B = sum(reshape(B(1:wl)~=0,1,[]).*2.^(wl-1:-1:0)); | ||
end | ||
|
||
if ~isempty(B) || obj.Width == 0 | ||
obj.IValue = mod(B,2^obj.Width); | ||
end | ||
end | ||
|
||
% Get the integer field value (empty if the bit width is 0) | ||
function v = get.Value(obj) | ||
v = obj.IValue; | ||
if obj.IWidth == 0 | ||
v = []; | ||
end | ||
end | ||
|
||
% Set the field width | ||
function obj = set.Width(obj,B) | ||
if isempty(B) || B < 0 | ||
error("The field bit width must be positive.") | ||
end | ||
if ~isempty(obj.WidthValues) && ~any(B == obj.WidthValues) | ||
warning("The field bit width (%d) is not one of the set specified (%s) for this field.", B, strjoin(string(obj.WidthValues),',')); | ||
end | ||
obj.IWidth = B; | ||
obj.Value = obj.Value; % Adjust stored value wrt the new bit width | ||
if isempty(obj.Value) && B > 0 | ||
obj.Value = 0; | ||
end | ||
end | ||
|
||
% Get the field width | ||
function w = get.Width(obj) | ||
w = obj.IWidth; | ||
end | ||
|
||
end | ||
|
||
properties (Access = private) | ||
IValue = 0; | ||
IWidth = 1; | ||
end | ||
|
||
end | ||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
%DCIFormat1_0_SIRNTI DCI format 1_0 with CRC scrambled by SI-RNTI | ||
% M = DCIFormat1_0_SIRNTI(NDLRB) creates a downlink control information | ||
% (DCI) format 1_0 message with CRC scrambled by the system information | ||
% radio network temporary identifier (SI-RNTI) for a CORESET 0 of size | ||
% NDLRB. The message contains the information described in TS 38.212 | ||
% Clause 7.3.1.2.1. The message enables the encoding and decoding of the | ||
% DCI message bits from and to message field values. All the fields map, | ||
% in order of the format definition, onto a set of information bits. The | ||
% mapping is such that the most significant bit of each field is mapped | ||
% to the lowest-order information bit for that field. The information | ||
% bits are encoded and carried on the physical downlink control channel | ||
% (PDCCH). | ||
% | ||
% M = DCIFormat1_0_SIRNTI(NDLRB,SHAREDSPECTRUM) enables to create a DCI | ||
% format 1_0 message with CRC scrambled by SI-RNTI with shared spectrum | ||
% enabled. A non-zero value of SHAREDSPECTRUM enables shared spectrum and | ||
% extends the number of reserved bits from 15 to 17. | ||
% | ||
% DCIFormat1_0_SIRNTI properties (configurable): | ||
% | ||
% FrequencyDomainResources - Frequency domain resource assignment | ||
% TimeDomainResources - Time domain resource assignment | ||
% VRBToPRBMapping - VRB-to-PRB mapping | ||
% ModulationCoding - Modulation and coding scheme | ||
% RedundancyVersion - Redundancy version | ||
% SystemInformationIndicator - System information indicator | ||
% ReservedBits - Reserved bits | ||
% | ||
% DCIFormat1_0_SIRNTI properties (read-only): | ||
% | ||
% Width - Bit width of message format | ||
% | ||
% Example: | ||
% % Create a DCIFormat1_0_SIRNTI message for a 48 RB CORESET 0 and map | ||
% % the field values to information bits. | ||
% | ||
% NDLRB = 48; | ||
% dci = DCIFormat1_0_SIRNTI(NDLRB); | ||
% dci.FrequencyDomainResources = 1; | ||
% dci.ModulationCoding = 2; | ||
% disp(toBits(dci)) | ||
% | ||
% See also MessageFormat, BitField. | ||
|
||
% Copyright 2021 The MathWorks, Inc. | ||
|
||
classdef DCIFormat1_0_SIRNTI < MessageFormat | ||
|
||
properties | ||
|
||
%FrequencyDomainResources Frequency domain resource assignment | ||
% The bit width depends on the size of CORESET 0 provided to the | ||
% constructor, as described in TS 38.212 Clause 7.3.1.2.1. | ||
FrequencyDomainResources = BitField(); | ||
|
||
%TimeDomainResources Time domain resource assignment | ||
% 4 bits as defined in TS 38.214 Subclause 5.1.2.1. | ||
TimeDomainResources = BitField(4); | ||
|
||
%VRBToPRBMapping VRB-to-PRB mapping | ||
% 1 bit according to TS 38.212 Table 7.3.1.2.2-5. | ||
VRBToPRBMapping = BitField(1); | ||
|
||
%ModulationCoding Modulation and coding scheme | ||
% 5 bits as defined in TS 38.214 Subclause 5.1.3. | ||
ModulationCoding = BitField(5); | ||
|
||
%RedundancyVersion Redundancy version | ||
% 2 bits as defined in TS 38.212 Table 7.3.1.1.1-2. | ||
RedundancyVersion = BitField(2); | ||
|
||
%SystemInformationIndicator System information indicator | ||
% 1 bit as defined in TS 38.212 Table 7.3.1.2.1-2. | ||
SystemInformationIndicator = BitField(1); | ||
|
||
%ReservedBits Reserved bits | ||
% 17 bits for operation in a cell with shared spectrum channel | ||
% access. Otherwise 15 bits. | ||
ReservedBits = BitField(15); | ||
|
||
end | ||
|
||
methods | ||
|
||
function obj = DCIFormat1_0_SIRNTI(nsizebwp,sharedspectrum) | ||
|
||
% NDLRB for CORESET 0 | ||
N = ceil(log2(nsizebwp*(nsizebwp+1)/2)); | ||
obj.FrequencyDomainResources = BitField(N); | ||
|
||
% If operation in a Release 16 cell with shared spectrum | ||
% channel access then adjust the field size | ||
if nargin>1 && sharedspectrum | ||
obj.ReservedBits = BitField(17); | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
%MIB MIB RRC message transmitted on BCH | ||
% M = MIB creates a master information block (MIB) radio resource control | ||
% (RRC) message that contains the MIB bit fields, as defined in TS | ||
% 38.331. The message enables the encoding and decoding of the MIB RRC | ||
% message bits from and to message field values. All the fields map, in | ||
% order of the format definition, onto a set of information bits. The | ||
% mapping is such that the most significant bit of each field is mapped | ||
% to the lowest-order information bit for that field. The number of bits | ||
% associated with each field is fixed. The information bits are encoded | ||
% by the broadcast channel (BCH) and carried on the physical broadcast | ||
% channel (PBCH). The BCH transport block is the RRC message | ||
% BCCH-BCH-Message, consisting of a leading 0 bit and 23 bits | ||
% corresponding to the MIB. The leading bit signals the message type | ||
% transmitted (MIB or empty sequence). | ||
% | ||
% MIB properties (configurable): | ||
% | ||
% systemFrameNumber - System frame number | ||
% subCarrierSpacingCommon - Subcarrier spacing for SIB1 in PDSCH | ||
% ssb_SubcarrierOffset - Subcarrier offset kSSB | ||
% dmrs_TypeA_Position - First DM-RS symbol position for SIB1 in PDSCH | ||
% pdcch_ConfigSIB1 - PDCCH-ConfigSIB1 information element for downlink control configuration | ||
% cellBarred - Cell barred | ||
% intraFreqReselection - Intra frequency reselection | ||
% spare - Spare bit | ||
% | ||
% MIB properties (read-only): | ||
% | ||
% Width - Bit width of message format | ||
% | ||
% Example: | ||
% % Create a MIB RRC message and map the field values to information bits. | ||
% | ||
% m = MIB; | ||
% m.systemFrameNumber = 1; | ||
% m.subCarrierSpacingCommon = 0; % SCS 15 for FR1 | ||
% m.ssb_SubcarrierOffset = 4; % kSSB = 4 for FR1 | ||
% m.dmrs_TypeA_Position = 0; % DM-RS position 2 | ||
% m.pdcch_ConfigSIB1.controlResourceSetZero = 0; | ||
% m.pdcch_ConfigSIB1.searchSpaceZero = 4; | ||
% m.cellBarred = 0; % Cell barred | ||
% m.intraFreqReselection = 0; % Reselection allowed | ||
% | ||
% disp(toBits(m)) | ||
% | ||
% See also PDCCH_ConfigSIB1, MessageFormat, BitField. | ||
|
||
% Copyright 2021 The MathWorks, Inc. | ||
|
||
classdef MIB < MessageFormat | ||
|
||
properties | ||
|
||
%systemFrameNumber System frame number | ||
% 6 most significant bits (MSB) of the 10-bit system frame number | ||
% (SFN). The 4 LSB of the SFN are conveyed in the BCH transport | ||
% block as part of channel coding (outside the MIB encoding). | ||
systemFrameNumber = BitField(6); | ||
|
||
%subCarrierSpacingCommon Subcarrier spacing for SIB1 in PDSCH | ||
% The value 0 (scs15or60) corresponds to 15 kHz and the value 1 | ||
% (scs30or120) corresponds to 30 kHz when the UE acquires this MIB | ||
% on an frequency range 1 (FR1) carrier frequency. The value 0 | ||
% (scs15or60) corresponds to 60 kHz and the value 1 (scs30or120) | ||
% corresponds to 120 kHz when the UE acquires this MIB on an FR2 | ||
% carrier frequency. | ||
subCarrierSpacingCommon = BitField(1); | ||
|
||
%ssb_SubcarrierOffset Subcarrier offset kSSB | ||
% Frequency domain offset between SSB and the overall resource | ||
% block grid in number of subcarriers. The value range of this | ||
% field may be extended by an additional most significant bit | ||
% encoded within PBCH as specified in TS 38.213. | ||
ssb_SubcarrierOffset = BitField(4); | ||
|
||
%dmrs_TypeA_Position First DM-RS symbol position for SIB1 in PDSCH | ||
% PDSCH DM-RS symbol position bit. The value 0 indicates DM-RS | ||
% symbol position 2 and the value 1 indicates position 3. | ||
dmrs_TypeA_Position = BitField(1); | ||
|
||
%pdcch_ConfigSIB1 PDCCH-ConfigSIB1 information element for downlink control configuration | ||
% RRC information element containing controlResourceSetZero and | ||
% searchSpaceZero configuration. | ||
pdcch_ConfigSIB1 = PDCCH_ConfigSIB1; | ||
|
||
%cellBarred Cell barred | ||
% cellBarred configures permission for UEs to camp in the cell. A | ||
% false value indicates that cell does not allow UEs to camp. | ||
cellBarred = BitField(1); | ||
|
||
%intraFreqReselection Intra frequency reselection | ||
% intraFreqReselection configures cell selection or reselection to | ||
% intra-frequency cells when the highest ranked cell is barred, or | ||
% treated as barred by the UE. A false value indicates frequency | ||
% reselection is allowed. | ||
intraFreqReselection = BitField(1); | ||
|
||
%spare Spare bit | ||
spare = BitField(1); | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.