├── .dvt └── default.build ├── .project ├── README ├── demo.sh ├── docs └── Physical_Coding_Library_UserGuide.docx ├── encoder_decoder ├── examples │ ├── common │ │ └── scripts │ │ │ ├── options_ius.f │ │ │ ├── options_vcs.f │ │ │ ├── options_vlog.f │ │ │ └── run.sh │ ├── endec_64b66b │ │ ├── scripts │ │ │ └── run.sh │ │ ├── tests │ │ │ ├── endec_64b66b_tests_base_test.svh │ │ │ ├── endec_64b66b_tests_legal_seq_test.svh │ │ │ ├── endec_64b66b_tests_pkg.sv │ │ │ └── endec_64b66b_tests_rand_seq_test.svh │ │ └── ve │ │ │ ├── endec_64b66b_top.svh │ │ │ ├── endec_64b66b_ve_agent.svh │ │ │ ├── endec_64b66b_ve_drv.svh │ │ │ ├── endec_64b66b_ve_env.svh │ │ │ ├── endec_64b66b_ve_pkg.sv │ │ │ ├── endec_64b66b_ve_scoreboard.svh │ │ │ ├── endec_64b66b_ve_seq_item.svh │ │ │ ├── endec_64b66b_ve_sequence_lib.svh │ │ │ └── endec_64b66b_ve_sequencer.svh │ └── endec_8b10b │ │ ├── scripts │ │ └── run.sh │ │ ├── tests │ │ ├── endec_8b10b_tests_all_k_test.svh │ │ ├── endec_8b10b_tests_base_test.svh │ │ ├── endec_8b10b_tests_encoder_decoder_test.svh │ │ └── endec_8b10b_tests_pkg.sv │ │ └── ve │ │ ├── endec_8b10b_top.svh │ │ ├── endec_8b10b_ve_decoder_agent.svh │ │ ├── endec_8b10b_ve_decoder_driver.svh │ │ ├── endec_8b10b_ve_decoder_seq_item.svh │ │ ├── endec_8b10b_ve_decoder_sequencer.svh │ │ ├── endec_8b10b_ve_encoder_agent.svh │ │ ├── endec_8b10b_ve_encoder_driver.svh │ │ ├── endec_8b10b_ve_encoder_seq_item.svh │ │ ├── endec_8b10b_ve_encoder_sequencer.svh │ │ ├── endec_8b10b_ve_env.svh │ │ ├── endec_8b10b_ve_pkg.sv │ │ ├── endec_8b10b_ve_scb.svh │ │ └── endec_8b10b_ve_seq_lib.svh └── sv │ ├── endec_64b66b │ ├── endec_64b66b_cov_items.svh │ ├── endec_64b66b_decoder.svh │ ├── endec_64b66b_decoder_cov.svh │ ├── endec_64b66b_defines.svh │ ├── endec_64b66b_encoder.svh │ ├── endec_64b66b_encoder_cov.svh │ ├── endec_64b66b_pkg.sv │ └── endec_64b66b_types.svh │ └── endec_8b10b │ ├── endec_8b10b_cov_item.svh │ ├── endec_8b10b_coverage.svh │ ├── endec_8b10b_decoder.svh │ ├── endec_8b10b_defines.svh │ ├── endec_8b10b_encoder.svh │ ├── endec_8b10b_mappings.svh │ ├── endec_8b10b_pkg.sv │ └── endec_8b10b_types.svh ├── examples └── coding_and_scrambling │ ├── scripts │ ├── options_ius.f │ ├── options_vcs.f │ ├── options_vlog.f │ └── run.sh │ ├── sv │ ├── coding_and_scrambling_top.sv │ └── endec_64b66b_driver_with_scrambler.svh │ └── tests │ └── endec_64b66b_with_scrambler_test.sv └── scrambler_descrambler ├── .project ├── examples ├── additive │ ├── scripts │ │ └── run.sh │ ├── sv │ │ └── scrambler_descrambler_additive_top.sv │ └── tests │ │ └── scrambler_descrambler_additive_test.sv ├── common │ └── scripts │ │ ├── options_ius.f │ │ ├── options_vcs.f │ │ ├── options_vlog.f │ │ └── run.sh └── multiplicative │ ├── scripts │ └── run.sh │ ├── sv │ └── scrambler_descrambler_multiplicative_top.sv │ └── tests │ └── scrambler_descrambler_multiplicative_test.sv └── sv ├── descrambler_multiplicative.svh ├── scrambler_descrambler_additive.svh ├── scrambler_descrambler_pkg.sv ├── scrambler_descrambler_types.svh └── scrambler_multiplicative.svh /.dvt/default.build: -------------------------------------------------------------------------------- 1 | // In a .build file you specify directives for the DVT builder. 2 | // Any line preceded by '//', '#' or '--' is considered a comment. 3 | // 4 | // examples/xbus_tb_top.sv // top file, path relative to project root 5 | // examples/xbus_tb_top.e // top file, path relative to project root 6 | // examples/xbus_tb_top.vhd // top file, path relative to project root 7 | // ${UVM_HOME}/src/uvm_pkg.sv // top file, absolute path with system variable 8 | // -f my_command_file.f // include another command file 9 | // +incdir+${UVM_HOME}/src/ // indicate search directory (for `include) 10 | // -incdir ${UVM_HOME}/src/ // indicate search directory (for `include) 11 | // +define+INCA // define preprocessing symbol 12 | // +define+CHIP_LEVEL_ID=0x10 // define preprocessing symbol with value 13 | // -v src/source_library_file.v // specify Verilog source library file 14 | // -y src/lib // specify Verilog source library directory 15 | 16 | -uvm 17 | 18 | +incdir+encoder_decoder/sv/endec_64b66b 19 | +incdir+encoder_decoder/examples/endec_64b66b/tests 20 | +incdir+encoder_decoder/examples/endec_64b66b/ve 21 | encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_top.svh 22 | encoder_decoder/sv/endec_64b66b/endec_64b66b_pkg.sv 23 | encoder_decoder/examples/endec_64b66b/tests/endec_64b66b_tests_pkg.sv 24 | encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_pkg.sv 25 | 26 | +incdir+encoder_decoder/sv/endec_8b10b 27 | +incdir+encoder_decoder/examples/endec_8b10b/tests 28 | +incdir+encoder_decoder/examples/endec_8b10b/ve 29 | encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_top.svh 30 | encoder_decoder/sv/endec_8b10b/endec_8b10b_pkg.sv 31 | encoder_decoder/examples/endec_8b10b/tests/endec_8b10b_tests_pkg.sv 32 | encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_pkg.sv 33 | 34 | +incdir+scrambler_descrambler/sv 35 | +incdir+scrambler_descrambler/examples/additive/sv 36 | +incdir+scrambler_descrambler/examples/additive/tests 37 | +incdir+scrambler_descrambler/examples/multiplicative/sv 38 | +incdir+scrambler_descrambler/examples/multiplicative/tests 39 | scrambler_descrambler/sv/scrambler_descrambler_pkg.sv 40 | scrambler_descrambler/examples/additive/sv/scrambler_descrambler_additive_top.sv 41 | scrambler_descrambler/examples/multiplicative/sv/scrambler_descrambler_multiplicative_top.sv 42 | 43 | +incdir+examples/coding_and_scrambling/sv 44 | +incdir+examples/coding_and_scrambling/tests 45 | examples/coding_and_scrambling/sv/coding_and_scrambling_top.sv 46 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | physical_coding_algorithms 4 | 5 | 6 | 7 | 8 | 9 | ro.amiq.dvt.MixedLangBuilder 10 | 11 | 12 | 13 | 14 | 15 | ro.amiq.vlogdt.VlogNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ========================== 2 | physical_coding_library 3 | ========================== 4 | 5 | Physical Coding Library 6 | 7 | AMIQ Blog related article: http://www.amiq.com/consulting/2016/02/25/physical-coding-library/ 8 | 9 | It contains implementations for 8b10b, 64b66b encoding/decoding algorithms and an implementation for scrambling/descrambling. 10 | 11 | Folder description 12 | /docs/Physical_Coding_Library_UserGuide.docx - documentation on how to use this library 13 | /encoder_decoder - source code for 8b10b and 64b66b encoding algorithms 14 | --/examples 15 | ----/common 16 | ------/scripts - scripts used to compile/run examples 17 | ----/endec_64b66b - usage examples of the 64b66b encoding/decoding implementation 18 | ----/endec_8b10b - usage examples of the 8b10b encoding/decoding implementation 19 | --/sv 20 | ----/endec_64b66b - source code of the 64b66b encoding/decoding implementation 21 | ----/endec_8b10b - source code of the 8b10b encoding/decoding implementation 22 | /examples 23 | --/coding_and_scrambling - examples that combine coding algorithms with scrambling algorithm 24 | ----/scripts - scripts used to compile/run examples 25 | ----/sv 26 | ----/tests 27 | /scrambler_descrambler - source code for scrambler_descrambler packages 28 | --/examples - usage examples of the scrambler/descrambler implementations 29 | --/sv - source code of the implementation 30 | demo.sh - script for demonstrating an usage example of the library 31 | 32 | 33 | How to demo: 34 | ./demo.sh 35 | 36 | For help, type: 37 | ./demo.sh -help 38 | -------------------------------------------------------------------------------- /demo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | 4 | #the default values of the user controlled options 5 | default_run_mode="batch" 6 | default_tool=questa 7 | default_seed=1; 8 | 9 | # not from here 10 | default_test="scrambler_descrambler_multiplicative_test" 11 | 12 | 13 | default_quit_cnt=0 14 | default_verbosity=UVM_MEDIUM 15 | default_script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 16 | default_script_path="$(cd ${default_script_path}/examples/coding_and_scrambling/scripts/ && pwd )" 17 | default_arch_bits=64 18 | 19 | echo ${default_script_path} 20 | 21 | 22 | # example to run; there are several examples: endec_8b10b, endec_64b66b, scrmb_descrmb_add, scrmb_descrmb_mult, scrmb_descrmb_endec 23 | default_ex_to_run="scrmb_descrmb_endec" 24 | 25 | 26 | ex_to_run=${default_ex_to_run} 27 | run_mode=${default_run_mode} 28 | tool=${default_tool} 29 | seed=${default_seed} 30 | test=${default_test} 31 | quit_cnt=${default_quit_cnt} 32 | verbosity=${default_verbosity} 33 | script_path=${default_script_path} 34 | ARCH_BITS=${default_arch_bits} 35 | 36 | 37 | 38 | help() { 39 | echo "" 40 | echo "Possible values for this script:" 41 | echo " -i --> run in interactive mode" 42 | echo " -ex_to_run --> specifiy what example to run; it can be: endec_8b10b, endec_64b66b, scrmb_descrmb_add, scrmb_descrmb_mult, scrmb_descrmb_endec" 43 | echo " -seed --> specify a particular seed for the simulation (default: ${default_seed})" 44 | echo " -test --> specify a particular test to run (default: ${default_test})" 45 | echo " -tool [ius|questa|vcs] --> specify what simulator to use (default: ${default_tool})" 46 | echo " -bit[32|64] --> specify what architecture to use: 32 or 64 bits (default: ${default_arch_bits} bits)" 47 | echo " -quit_cnt --> specify after how many errors should the test stop (default: ${default_quit_cnt})" 48 | echo " -verbosity {UVM_NONE|UVM_LOW|UVM_MEDIUM|UVM_HIGH|UVM_FULL|UVM_DEBUG }] --> specify the verbosity of a message (default: ${default_uvm_verbosity})" 49 | echo " -help --> print this message" 50 | echo "" 51 | 52 | } 53 | 54 | 55 | #use this to register options 56 | options="" 57 | 58 | while [ $# -gt 0 ]; do 59 | case `echo $1 | tr "[A-Z]" "[a-z]"` in 60 | -seed) 61 | seed=$2 62 | ;; 63 | -tool) 64 | tool=$2 65 | ;; 66 | -test) 67 | test=$2 68 | ;; 69 | -i) 70 | run_mode="-i" 71 | ;; 72 | -help) 73 | help 74 | exit 0 75 | ;; 76 | -verbosity) 77 | verbosity=$2 78 | ;; 79 | -quit_cnt) 80 | quit_cnt=$2 81 | ;; 82 | -bit32) 83 | ARCH_BITS=32 84 | ;; 85 | -bit64) 86 | ARCH_BITS=64 87 | ;; 88 | -ex_to_run) 89 | # call the appropriate script 90 | # reset the scrit path to proj directory 91 | script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 92 | case `echo $2 | tr "[A-Z]" "[a-z]"` in 93 | endec_8b10b) 94 | script_path="$( cd ${script_path}/encoder_decoder/examples/endec_8b10b/scripts/ && pwd )" 95 | echo "BEEN HERE !!!" 96 | echo ${script_path} 97 | ;; 98 | endec_64b66b) 99 | script_path="$( cd ${script_path}/encoder_decoder/examples/endec_64b66b/scripts/ && pwd )" 100 | ;; 101 | scrmb_descrmb_add) 102 | script_path="$( cd ${script_path}/scrambler_descrambler/examples/additive/scripts/ && pwd )" 103 | ;; 104 | scrmb_descrmb_mult) 105 | script_path="$( cd ${script_path}/scrambler_descrambler/examples/multiplicative/scripts/ && pwd )" 106 | ;; 107 | scrmb_descrmb_endec) 108 | script_path="$( cd ${script_path}/examples/coding_and_scrambling/scripts/ && pwd )" 109 | ;; 110 | *) 111 | echo "Invalid option given, exitting." 112 | exit 0 113 | ;; 114 | esac 115 | ;; 116 | -*) 117 | echo "Invalid option given, exitting." 118 | exit 0 119 | ;; 120 | esac 121 | shift 122 | done 123 | 124 | test_cmd="-test $test" 125 | if [ $test == $default_test ]; then 126 | test_cmd="" 127 | fi 128 | 129 | options="-seed $seed -tool $tool $test_cmd $run_mode -verbosity $verbosity -quit_cnt $quit_cnt -bits ${ARCH_BITS}" 130 | echo "Running script ${script_path}/run.sh with options: ${options}" 131 | 132 | ${script_path}/run.sh ${options} 133 | 134 | #${script_path}/run.sh -ex_to_run ${ex_to_run} -tool ${tool} -test ${test} -quit_cnt ${quit_cnt} -verbosity ${verbosity} -------------------------------------------------------------------------------- /docs/Physical_Coding_Library_UserGuide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amiq-consulting/physical_coding_library/741f798adab6d6e42a521f2db36dbad63bd17381/docs/Physical_Coding_Library_UserGuide.docx -------------------------------------------------------------------------------- /encoder_decoder/examples/common/scripts/options_ius.f: -------------------------------------------------------------------------------- 1 | +incdir+${PROJECT_DIR}/sv/${ENDEC_TYPE} 2 | 3 | +incdir+${EXAMPLE_DIR}/ 4 | +incdir+${EXAMPLE_DIR}/ve 5 | +incdir+${EXAMPLE_DIR}/tests 6 | 7 | 8 | -${ARCH_BITS}bit 9 | -linedebug 10 | -uvmlinedebug 11 | +uvm_set_action="*,_ALL_,UVM_ERROR,UVM_DISPLAY|UVM_STOP" 12 | -uvm 13 | -access rw 14 | -sv 15 | -covoverwrite 16 | -coverage all 17 | +UVM_NO_RELNOTES 18 | -DSC_INCLUDE_DYNAMIC_PROCESSES 19 | +define+UVM_OBJECT_MUST_HAVE_CONSTRUCTOR 20 | -timescale 1ns/1ps 21 | ${PROJECT_DIR}/sv/${ENDEC_TYPE}/${ENDEC_TYPE}_pkg.sv 22 | ${EXAMPLE_DIR}/ve/${ENDEC_TYPE}_ve_pkg.sv 23 | ${EXAMPLE_DIR}/tests/${ENDEC_TYPE}_tests_pkg.sv 24 | ${TOP_FILE_PATH} 25 | -------------------------------------------------------------------------------- /encoder_decoder/examples/common/scripts/options_vcs.f: -------------------------------------------------------------------------------- 1 | -sverilog 2 | 3 | +incdir+${PROJECT_DIR}/sv/${ENDEC_TYPE} 4 | 5 | +incdir+${EXAMPLE_DIR}/ 6 | +incdir+${EXAMPLE_DIR}/ve 7 | +incdir+${EXAMPLE_DIR}/tests 8 | 9 | ${PROJECT_DIR}/sv/${ENDEC_TYPE}/${ENDEC_TYPE}_pkg.sv 10 | ${EXAMPLE_DIR}/ve/${ENDEC_TYPE}_ve_pkg.sv 11 | ${EXAMPLE_DIR}/tests/${ENDEC_TYPE}_tests_pkg.sv 12 | ${TOP_FILE_PATH} 13 | -top ${TOP_MODULE_NAME} 14 | -timescale=1ns/1ps -------------------------------------------------------------------------------- /encoder_decoder/examples/common/scripts/options_vlog.f: -------------------------------------------------------------------------------- 1 | +incdir+${PROJECT_DIR}/sv/${ENDEC_TYPE} 2 | 3 | +incdir+${EXAMPLE_DIR}/ 4 | +incdir+${EXAMPLE_DIR}/ve 5 | +incdir+${EXAMPLE_DIR}/tests 6 | 7 | -${ARCH_BITS} 8 | -sv 9 | ${PROJECT_DIR}/sv/${ENDEC_TYPE}/${ENDEC_TYPE}_pkg.sv 10 | ${EXAMPLE_DIR}/ve/${ENDEC_TYPE}_ve_pkg.sv 11 | ${EXAMPLE_DIR}/tests/${ENDEC_TYPE}_tests_pkg.sv 12 | ${TOP_FILE_PATH} 13 | -------------------------------------------------------------------------------- /encoder_decoder/examples/common/scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | #the default values of the user controlled options 4 | default_run_mode="batch" 5 | default_tool=ius 6 | default_seed=1; 7 | default_test="NONE" 8 | default_quit_cnt=0 9 | default_verbosity=UVM_MEDIUM 10 | default_arch_bits=64 11 | 12 | while [ $# -gt 0 ]; do 13 | case `echo $1 | tr "[A-Z]" "[a-z]"` in 14 | -default_test) 15 | default_test=$2 16 | break; 17 | ;; 18 | esac 19 | done 20 | 21 | run_mode=${default_run_mode} 22 | tool=${default_tool} 23 | seed=${default_seed} 24 | test=${default_test} 25 | ARCH_BITS=${default_arch_bits} 26 | verbosity=${default_verbosity} 27 | quit_cnt=${default_quit_cnt} 28 | 29 | export TOP_MODULE_NAME=${DUT_MODULE_NAME}_top 30 | export TOP_FILE_NAME=${TOP_MODULE_NAME}.svh 31 | export TOP_FILE_PATH=${EXAMPLE_DIR}/ve/${TOP_FILE_NAME} 32 | 33 | help() { 34 | echo "" 35 | echo "Possible options for this script:" 36 | echo " -i --> run in interactive mode" 37 | echo " -seed --> specify a particular seed for the simulation (default: ${default_seed})" 38 | echo " -test --> specify a particular test to run (default: ${default_test})" 39 | echo " -tool [ius|questa|vcs] --> specify what simulator to use (default: ${default_tool})" 40 | echo " -bit[32|64] --> specify what architecture to use: 32 or 64 bits (default: ${default_arch_bits} bits)" 41 | echo " -quit_cnt --> specify after how many errors should the test stop (default: ${default_quit_cnt})" 42 | echo " -verbosity {UVM_NONE|UVM_LOW|UVM_MEDIUM|UVM_HIGH|UVM_FULL|UVM_DEBUG }] --> specify the verbosity of a message (default: ${default_verbosity})" 43 | echo " -help --> print this message" 44 | echo "" 45 | } 46 | 47 | run_with_ius_test() { 48 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 49 | 50 | if [ "$run_mode" = "interactive" ]; then 51 | rm -rf ncsim_cmds.tcl 52 | touch ncsim_cmds.tcl 53 | 54 | echo "database -open waves -into waves.shm -default" >> ncsim_cmds.tcl 55 | echo "probe -create ${TOP_MODULE_NAME} -depth all -tasks -functions -uvm -packed 4k -unpacked 16k -all" >> ncsim_cmds.tcl 56 | 57 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -gui -input ncsim_cmds.tcl " 58 | else 59 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -exit " 60 | fi 61 | 62 | irun -f ${PROJECT_DIR}/examples/common/scripts/options_ius.f -svseed ${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} ${EXTRA_OPTIONS} 63 | } 64 | 65 | run_with_vcs_test() { 66 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 67 | 68 | if [ "$run_mode" = "interactive" ]; then 69 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -gui " 70 | fi 71 | 72 | vcs -ntb_opts uvm -f ${PROJECT_DIR}/examples/common/scripts/options_vcs.f +ntb_random_seed=${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} -R ${EXTRA_OPTIONS} 73 | 74 | } 75 | 76 | run_with_questa_test() { 77 | vlib work 78 | vlog -f ${PROJECT_DIR}/examples/common/scripts/options_vlog.f 79 | 80 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 81 | 82 | if [ "$run_mode" != "interactive" ]; then 83 | rm -rf vsim_cmds.do 84 | touch vsim_cmds.do 85 | 86 | echo "run -all; exit" >> vsim_cmds.do 87 | 88 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -do vsim_cmds.do -c " 89 | fi 90 | 91 | vsim -${ARCH_BITS} -novopt ${TOP_MODULE_NAME} -sv_seed ${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} ${EXTRA_OPTIONS} 92 | } 93 | 94 | while [ $# -gt 0 ]; do 95 | case `echo $1 | tr "[A-Z]" "[a-z]"` in 96 | -seed) 97 | seed=$2 98 | ;; 99 | -tool) 100 | tool=$2 101 | ;; 102 | -test) 103 | test=$2 104 | ;; 105 | -i) 106 | run_mode=interactive 107 | ;; 108 | -verbosity) 109 | verbosity=$2 110 | ;; 111 | -help) 112 | help 113 | exit 0 114 | ;; 115 | esac 116 | shift 117 | done 118 | 119 | export ARCH_BITS=${ARCH_BITS} 120 | 121 | case $tool in 122 | ius) 123 | echo "Selected tool: IUS..." 124 | ;; 125 | vcs) 126 | echo "Selected tool: VCS..." 127 | ;; 128 | questa) 129 | echo "Selected tool: Questa..." 130 | ;; 131 | *) 132 | echo "Illegal option for tool: $tool" 133 | exit 1; 134 | ;; 135 | esac 136 | 137 | sim_dir=`pwd`/sim_${test} 138 | echo "Start running ${test} test in ${sim_dir}"; 139 | rm -rf ${sim_dir}; 140 | mkdir ${sim_dir}; 141 | cd ${sim_dir}; 142 | run_with_${tool}_test 143 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | export PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../../ && pwd )" 4 | export EXAMPLE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../ && pwd )" 5 | 6 | #the default values of the user controlled options 7 | default_test="endec_64b66b_tests_legal_seq_test" 8 | 9 | export ENDEC_TYPE=endec_64b66b 10 | export DUT_MODULE_NAME=endec_64b66b 11 | 12 | ${PROJECT_DIR}/examples/common/scripts/run.sh -default_test ${default_test} $@ -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/tests/endec_64b66b_tests_base_test.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_tests_base_test.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains the base test of the endec_64b66b package 21 | *******************************************************************************/ 22 | 23 | 24 | `ifndef ENDEC_64b66b_TESTS_BASE_TEST_SVH 25 | `define ENDEC_64b66b_TESTS_BASE_TEST_SVH 26 | 27 | 28 | /* Base test class 29 | */ 30 | class endec_64b66b_tests_base_test extends uvm_test; 31 | `uvm_component_utils(endec_64b66b_tests_base_test) 32 | 33 | //environment 34 | endec_64b66b_ve_env m_env; 35 | 36 | 37 | /* Constructor 38 | * @param name : name for this component instance 39 | * @param parent : parent for this component 40 | */ 41 | function new(string name, uvm_component parent); 42 | super.new(name, parent); 43 | endfunction 44 | 45 | 46 | /* UVM build phase 47 | * @param phase - current phase 48 | */ 49 | virtual function void build_phase(uvm_phase phase); 50 | super.build_phase(phase); 51 | 52 | m_env = endec_64b66b_ve_env::type_id::create("m_env", this); 53 | endfunction 54 | 55 | endclass 56 | 57 | `endif//ENDEC_64b66b_TESTS_BASE_TEST_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/tests/endec_64b66b_tests_legal_seq_test.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_tests_legal_seq_test.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains test of the endec_64b66b package 21 | *******************************************************************************/ 22 | 23 | 24 | `ifndef ENDEC_64b66b_TESTS_LEGAL_SEQ_TEST_SVH 25 | `define ENDEC_64b66b_TESTS_LEGAL_SEQ_TEST_SVH 26 | 27 | 28 | /* Test class for legal sequence 29 | */ 30 | class endec_64b66b_tests_legal_seq_test extends endec_64b66b_tests_base_test; 31 | `uvm_component_utils(endec_64b66b_tests_legal_seq_test) 32 | 33 | 34 | /* Constructor 35 | * @param name : name for this component instance 36 | * @param parent : parent for this component 37 | */ 38 | function new(string name, uvm_component parent); 39 | super.new(name, parent); 40 | endfunction 41 | 42 | 43 | /* UVM build phase 44 | * @param phase - current phase 45 | */ 46 | virtual function void build_phase(uvm_phase phase); 47 | super.build_phase(phase); 48 | endfunction 49 | 50 | 51 | /* UVM run phase 52 | * @param phase - current phase 53 | */ 54 | virtual task run_phase(uvm_phase phase); 55 | endec_64b66b_ve_all_legal_seq seq = endec_64b66b_ve_all_legal_seq::type_id::create( 56 | "seq_64b66b_all_legal", m_env.m_agent_64b66b.m_sequencer_64b66b 57 | ); 58 | 59 | phase.raise_objection(this); 60 | assert(seq.randomize() with {m_num_of_items inside {500};}); 61 | seq.start(m_env.m_agent_64b66b.m_sequencer_64b66b); 62 | phase.drop_objection(this); 63 | endtask 64 | endclass 65 | 66 | `endif//ENDEC_64b66b_TESTS_LEGAL_SEQ_TEST_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/tests/endec_64b66b_tests_pkg.sv: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * (C) Copyright 2015 AMIQ Consulting 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | * MODULE: endec_64b66b_tests_pkg.sv 18 | * PROJECT: endec_64b66b 19 | * 20 | * 21 | * Description: Package containing the tests library 22 | *******************************************************************************/ 23 | 24 | `ifndef ENDEC_64b66b_TESTS_PKG_SV 25 | `define ENDEC_64b66b_TESTS_PKG_SV 26 | 27 | package endec_64b66b_tests_pkg; 28 | import uvm_pkg::*; 29 | `include "uvm_macros.svh" 30 | 31 | import endec_64b66b_ve_pkg::*; 32 | 33 | `include "endec_64b66b_tests_base_test.svh" 34 | `include "endec_64b66b_tests_legal_seq_test.svh" 35 | `include "endec_64b66b_tests_rand_seq_test.svh" 36 | 37 | endpackage 38 | 39 | `endif -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/tests/endec_64b66b_tests_rand_seq_test.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_tests_rand_seq_test.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains test of the endec_64b66b package 21 | *******************************************************************************/ 22 | 23 | 24 | `ifndef ENDEC_64b66b_TESTS_RAND_SEQ_TEST_SVH 25 | `define ENDEC_64b66b_TESTS_RAND_SEQ_TEST_SVH 26 | 27 | 28 | /* Test class for legal sequence 29 | */ 30 | class endec_64b66b_tests_rand_seq_test extends endec_64b66b_tests_base_test; 31 | `uvm_component_utils(endec_64b66b_tests_rand_seq_test) 32 | 33 | 34 | /* Constructor 35 | * @param name : name for this component instance 36 | * @param parent : parent for this component 37 | */ 38 | function new(string name, uvm_component parent); 39 | super.new(name, parent); 40 | endfunction 41 | 42 | 43 | /* UVM build phase 44 | * @param phase - current phase 45 | */ 46 | virtual function void build_phase(uvm_phase phase); 47 | super.build_phase(phase); 48 | endfunction 49 | 50 | 51 | /* UVM run phase 52 | * @param phase - current phase 53 | */ 54 | virtual task run_phase(uvm_phase phase); 55 | endec_64b66b_ve_seq seq = endec_64b66b_ve_seq::type_id::create( 56 | "seq_64b66b", m_env.m_agent_64b66b.m_sequencer_64b66b 57 | ); 58 | 59 | phase.raise_objection(this); 60 | assert(seq.randomize() with {m_num_of_items inside {500};}); 61 | seq.start(m_env.m_agent_64b66b.m_sequencer_64b66b); 62 | 63 | phase.drop_objection(this); 64 | endtask 65 | endclass 66 | 67 | `endif//ENDEC_64b66b_TESTS_RAND_SEQ_TEST_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_top.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_top.sv 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains the top module used for starting the test 21 | *******************************************************************************/ 22 | 23 | `ifndef ENDEC_64b66b_TOP_SVH 24 | `define ENDEC_64b66b_TOP_SVH 25 | 26 | import uvm_pkg::*; 27 | import endec_64b66b_tests_pkg::*; 28 | 29 | module endec_64b66b_top; 30 | 31 | initial begin 32 | run_test(""); 33 | end 34 | 35 | endmodule 36 | 37 | `endif//ENDEC_64b66b_TOP_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_agent.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_ve_agent.sv 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains the agent component of the endec_64b66b pkt 21 | *******************************************************************************/ 22 | 23 | `ifndef ENDEC_64b66b_VE_AGENT_SVH 24 | `define ENDEC_64b66b_VE_AGENT_SVH 25 | 26 | /* Agent class 27 | * 28 | */ 29 | class endec_64b66b_ve_agent extends uvm_agent; 30 | `uvm_component_utils(endec_64b66b_ve_agent) 31 | 32 | //driver 33 | endec_64b66b_ve_drv m_driver_64b66b; 34 | //sequencer 35 | endec_64b66b_ve_sequencer m_sequencer_64b66b; 36 | 37 | 38 | /* Constructor 39 | * @param name : name for this component instance 40 | * @param parent : parent for this component 41 | */ 42 | function new(string name, uvm_component parent); 43 | super.new(name, parent); 44 | endfunction 45 | 46 | 47 | /* UVM build phase 48 | * @param phase - current phase 49 | */ 50 | virtual function void build_phase(uvm_phase phase); 51 | super.build_phase(phase); 52 | 53 | m_driver_64b66b = endec_64b66b_ve_drv::type_id::create("m_driver_64b66b", this); 54 | m_sequencer_64b66b = endec_64b66b_ve_sequencer::type_id::create("m_sequencer_64b66b", this); 55 | endfunction 56 | 57 | 58 | /* UVM connect phase 59 | * @param phase - current phase 60 | */ 61 | virtual function void connect_phase(uvm_phase phase); 62 | m_driver_64b66b.seq_item_port.connect(m_sequencer_64b66b.seq_item_export); 63 | endfunction 64 | 65 | endclass 66 | 67 | `endif//ENDEC_64b66b_VE_AGENT_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_drv.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_ve_drv.sv 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains the driver used for sending symbols 21 | * to the encoder 22 | *******************************************************************************/ 23 | 24 | `ifndef ENDEC_64b66b_VE_DRV_SVH 25 | `define ENDEC_64b66b_VE_DRV_SVH 26 | 27 | 28 | /* Driver class 29 | * 30 | */ 31 | class endec_64b66b_ve_drv extends uvm_driver#(endec_64b66b_ve_seq_item); 32 | `uvm_component_utils(endec_64b66b_ve_drv) 33 | 34 | 35 | // analysis port that broadcasts all items outputted by the decoding function 36 | uvm_analysis_port#(endec_64b66b_ve_seq_item) m_post_decode_item_ap; 37 | 38 | 39 | // encoder handler 40 | endec_64b66b_encoder m_encoder_64b66b; 41 | // decoder handler 42 | endec_64b66b_decoder m_decoder_64b66b; 43 | 44 | 45 | /* Constructor 46 | * @param name : name for this component instance 47 | * @param parent : parent for this component 48 | */ 49 | function new(string name, uvm_component parent); 50 | super.new(name, parent); 51 | endfunction 52 | 53 | 54 | /* UVM build phase 55 | * @param phase - current phase 56 | */ 57 | virtual function void build_phase(uvm_phase phase); 58 | super.build_phase(phase); 59 | //encoder instance 60 | m_encoder_64b66b = endec_64b66b_encoder::type_id::create("m_encoder_64b66b", this); 61 | //decoder instance 62 | m_decoder_64b66b = endec_64b66b_decoder::type_id::create("m_decoder_64b66b", this); 63 | 64 | // analysis port 65 | m_post_decode_item_ap = new("m_post_decode_item_ap", this); 66 | endfunction 67 | 68 | 69 | /* UVM connect_phase 70 | * @param phase - current phase 71 | */ 72 | virtual function void connect_phase(uvm_phase phase); 73 | super.connect_phase(phase); 74 | endfunction 75 | 76 | 77 | /* UVM run_phase 78 | * @param phase - current phase 79 | */ 80 | virtual task run_phase(uvm_phase phase); 81 | endec_64b66b_ve_seq_item encoder_item; 82 | 83 | 84 | forever begin 85 | // get item from the sequencer 86 | seq_item_port.get_next_item(encoder_item); 87 | 88 | // print item 89 | `uvm_info("DRIVER_64b66b", encoder_item.convert2string(), UVM_HIGH) 90 | 91 | // encode 92 | encoder_item.m_code_block_66b = m_encoder_64b66b.encode({encoder_item.m_control1,encoder_item.m_data1, 93 | encoder_item.m_control0, encoder_item.m_data0}); 94 | // update block type of the packet after encoding process has been performed 95 | encoder_item.m_tx_block_type = m_encoder_64b66b.get_tx_block_format(); 96 | `uvm_info("DRIVER_64b66b", $sformatf("\nEncoder output = %x " , encoder_item.m_code_block_66b), UVM_MEDIUM) 97 | 98 | // decode 99 | encoder_item.m_decoded_xgmii_data = m_decoder_64b66b.decode(encoder_item.m_code_block_66b); 100 | `uvm_info("DECODER_64b66b", 101 | $sformatf("\Decoder output \ncontrol0 = %x \ndata0 = %x \ncontrol1 = %x \ndata1 = %x \n", 102 | encoder_item.m_decoded_xgmii_data[71:68], encoder_item.m_decoded_xgmii_data[67:36], 103 | encoder_item.m_decoded_xgmii_data[35:32], encoder_item.m_decoded_xgmii_data[31:0]), UVM_HIGH) 104 | 105 | 106 | // send item to scoreboard 107 | m_post_decode_item_ap.write(encoder_item); 108 | 109 | seq_item_port.item_done(); 110 | end 111 | endtask 112 | 113 | endclass 114 | 115 | `endif//ENDEC_64b66b_VE_DRV_SVH 116 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_env.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_ve_env.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains the environment component 21 | *******************************************************************************/ 22 | 23 | `ifndef ENDEC_64b66b_VE_ENV_SVH 24 | `define ENDEC_64b66b_VE_ENV_SVH 25 | 26 | 27 | /* Environment class 28 | */ 29 | class endec_64b66b_ve_env extends uvm_env; 30 | `uvm_component_utils(endec_64b66b_ve_env) 31 | 32 | // agent 33 | endec_64b66b_ve_agent m_agent_64b66b; 34 | 35 | // scoreboard 36 | endec_64b66b_ve_scoreboard m_sb_64b66b; 37 | 38 | /* Constructor 39 | * @param name : name for this component instance 40 | * @param parent : parent for this component 41 | */ 42 | function new(string name, uvm_component parent); 43 | super.new(name, parent); 44 | endfunction 45 | 46 | /* UVM build phase 47 | * @param phase - current phase 48 | */ 49 | virtual function void build_phase(uvm_phase phase); 50 | super.build_phase(phase); 51 | 52 | // instantiate the agent 53 | m_agent_64b66b = endec_64b66b_ve_agent::type_id::create("m_agent_64b66b", this); 54 | 55 | // instantiate the scoreboard 56 | m_sb_64b66b = endec_64b66b_ve_scoreboard::type_id::create("m_sb_64b66b", this); 57 | endfunction 58 | 59 | /* UVM connect phase 60 | * @param phase - current phase 61 | */ 62 | virtual function void connect_phase(uvm_phase phase); 63 | super.connect_phase(phase); 64 | 65 | // connect driver uvm_analysis_port to the scoreboard anlysis_port_imp 66 | m_agent_64b66b.m_driver_64b66b.m_post_decode_item_ap.connect(m_sb_64b66b.m_decoded_item_ap); 67 | endfunction 68 | 69 | endclass 70 | 71 | `endif//ENDEC_64b66b_VE_ENV_SVH 72 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_pkg.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_ve_pkg.sv 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: Package containing the implementation of verification environment 21 | *******************************************************************************/ 22 | 23 | `ifndef ENDEC_64b66b_VE_PKG_SV 24 | `define ENDEC_64b66b_VE_PKG_SV 25 | 26 | `include "uvm_macros.svh" 27 | `include "endec_64b66b_pkg.sv" 28 | 29 | package endec_64b66b_ve_pkg; 30 | 31 | import uvm_pkg::*; 32 | import endec_64b66b_pkg::*; 33 | 34 | `include "endec_64b66b_ve_seq_item.svh" 35 | `include "endec_64b66b_ve_sequencer.svh" 36 | `include "endec_64b66b_ve_drv.svh" 37 | `include "endec_64b66b_ve_agent.svh" 38 | `include "endec_64b66b_ve_scoreboard.svh" 39 | `include "endec_64b66b_ve_sequence_lib.svh" 40 | `include "endec_64b66b_ve_env.svh" 41 | 42 | endpackage 43 | 44 | `endif 45 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_scoreboard.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_ve_scoreboard.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains the scoreboard component 21 | *******************************************************************************/ 22 | `ifndef ENDEC_64b66b_VE_SCOREBOARD_SVH 23 | `define ENDEC_64b66b_VE_SCOREBOARD_SVH 24 | /* Scoreboard class 25 | * 26 | */ 27 | class endec_64b66b_ve_scoreboard extends uvm_component; 28 | `uvm_component_utils(endec_64b66b_ve_scoreboard) 29 | 30 | 31 | // analysis ports that report items from drivers to the checked 32 | // uvm_analysis_imp_before_encoder_drv#(endec_64b66b_seq_item, endec_64b66b_scoreboard) item_before_encoder_drv; 33 | uvm_analysis_imp #(endec_64b66b_ve_seq_item, endec_64b66b_ve_scoreboard) m_decoded_item_ap; 34 | 35 | 36 | /* Constructor 37 | * @param name : name for this component instance 38 | * @param parent : parent for this component 39 | */ 40 | function new(string name, uvm_component parent); 41 | super.new(name, parent); 42 | endfunction 43 | 44 | 45 | /* UVM build phase 46 | * @param phase - current phase 47 | */ 48 | virtual function void build_phase(uvm_phase phase); 49 | super.build_phase(phase); 50 | 51 | // allocate the analysis port 52 | m_decoded_item_ap = new("m_decoded_item_ap", this); 53 | endfunction 54 | 55 | 56 | /* Analysis port write() implementation 57 | * @param a_decoded_item : input item from the driver received after decoding process 58 | */ 59 | virtual function void write(endec_64b66b_ve_seq_item a_decoded_item); 60 | string error_msg; 61 | // handle to the decoder used to retrieve the decoding state 62 | endec_64b66b_decoder decoder_handle; 63 | // variable where state of decoder is updated 64 | endec_64b66b_receive_sm_states_e decoder_state; 65 | 66 | uvm_component parent = this.get_parent(); 67 | 68 | // get handle to the decoder 69 | assert ($cast(decoder_handle, parent.lookup("m_agent_64b66b.m_driver_64b66b.m_decoder_64b66b"))) else 70 | `uvm_error("SB_64b66b", "Cast has failed.") 71 | decoder_state = decoder_handle.get_current_tx_state(); 72 | 73 | if ((a_decoded_item.m_tx_block_type != E_BLOCK) & (decoder_state != RX_E)) begin 74 | 75 | if (a_decoded_item.m_control0 != a_decoded_item.m_decoded_xgmii_data[71:68]) begin 76 | error_msg = $sformatf("%s\nDifference between control0 input %x and decoded output %x", 77 | error_msg, a_decoded_item.m_control0, a_decoded_item.m_decoded_xgmii_data[71:68]); 78 | end 79 | if (a_decoded_item.m_data0 != a_decoded_item.m_decoded_xgmii_data[67:36]) begin 80 | error_msg = $sformatf("%s\nDifference between data0 input %x and decoded output %x", 81 | error_msg, a_decoded_item.m_data0, a_decoded_item.m_decoded_xgmii_data[67:36]); 82 | end 83 | if (a_decoded_item.m_control1 != a_decoded_item.m_decoded_xgmii_data[35:32]) begin 84 | error_msg = $sformatf("%s\nDifference between control1 input %x and decoded output %x", 85 | error_msg, a_decoded_item.m_control1, a_decoded_item.m_decoded_xgmii_data[35:32]); 86 | end 87 | if (a_decoded_item.m_data1 != a_decoded_item.m_decoded_xgmii_data[31:0]) begin 88 | error_msg = $sformatf("%s\nDifference between data1 input %x and decoded output %x", 89 | error_msg, a_decoded_item.m_data1, a_decoded_item.m_decoded_xgmii_data[31:0]); 90 | end 91 | end else begin 92 | if (a_decoded_item.m_decoded_xgmii_data[71:68] != 4'hf) begin 93 | error_msg = 94 | $sformatf("%s\nDifference between control0 expected value for error block %x and decoded output %x", 95 | error_msg, 4'hf, a_decoded_item.m_decoded_xgmii_data[71:68]); 96 | end 97 | if (a_decoded_item.m_decoded_xgmii_data[67:36] != {4{E_CONTROL}}) begin 98 | error_msg = 99 | $sformatf("%s\nDifference between data0 expected value for error block %x and decoded output %x", 100 | error_msg, {4{E_CONTROL}}, a_decoded_item.m_decoded_xgmii_data[67:36]); 101 | end 102 | if (a_decoded_item.m_decoded_xgmii_data[35:32] != 4'hf) begin 103 | error_msg = 104 | $sformatf("%s\nDifference between control1 expected value for error block %x and decoded output %x", 105 | error_msg, a_decoded_item.m_control1, a_decoded_item.m_decoded_xgmii_data[35:32]); 106 | end 107 | if (a_decoded_item.m_decoded_xgmii_data[31:0] != {4{E_CONTROL}}) begin 108 | error_msg = 109 | $sformatf("%s\nDifference between data1 expected value for error block %x and decoded output %x", 110 | error_msg, {4{E_CONTROL}}, a_decoded_item.m_decoded_xgmii_data[31:0]); 111 | end 112 | 113 | end 114 | 115 | // output error if error string is not empty 116 | if (error_msg != "") begin 117 | `uvm_error("SB_64b66b", error_msg) 118 | end else begin 119 | `uvm_info("SB_64b66b", "Scoreboarding passed", UVM_MEDIUM) 120 | end 121 | 122 | 123 | endfunction 124 | 125 | endclass 126 | 127 | `endif//ENDEC_64b66b_VE_SCOREBOARD_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_sequence_lib.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_ve_sequence_lib.sv 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This file contains the sequence library. 21 | *******************************************************************************/ 22 | `ifndef ENDEC_64b66b_VE_SEQUENCE_LIB_SVH 23 | `define ENDEC_64b66b_VE_SEQUENCE_LIB_SVH 24 | 25 | 26 | 27 | /* Basic sequence with random items 28 | */ 29 | class endec_64b66b_ve_seq extends uvm_sequence #(endec_64b66b_ve_seq_item); 30 | `uvm_object_utils(endec_64b66b_ve_seq) 31 | 32 | // sequence item numbers 33 | rand int m_num_of_items; 34 | //64b66b sequence item 35 | endec_64b66b_ve_seq_item m_seq_item; 36 | 37 | 38 | /* Default constructor 39 | * @param name : instance name 40 | */ 41 | function new(string name = ""); 42 | super.new(name); 43 | endfunction 44 | 45 | 46 | /* Sequence body task implementation 47 | */ 48 | virtual task body(); 49 | int unsigned index; 50 | 51 | repeat(m_num_of_items) begin 52 | bit [1:0] dice_on_item; 53 | void'(std::randomize(dice_on_item)); 54 | 55 | 56 | case (dice_on_item) 57 | 0: m_seq_item = endec_64b66b_ve_s_blk_idle_and_err_seq_item::type_id::create("s_seq_item"); 58 | 1: m_seq_item = endec_64b66b_ve_d_block_seq_item::type_id::create("d_seq_item"); 59 | 2: m_seq_item = endec_64b66b_ve_t_blk_idle_and_err_seq_item::type_id::create("t_seq_item"); 60 | 3: m_seq_item = endec_64b66b_ve_c_blk_idle_and_err_seq_item::type_id::create("c_seq_item"); 61 | //4,5,6,7 : seq_item = endec_64b66b_seq_item::type_id::create("seq_item"); 62 | endcase 63 | 64 | 65 | start_item(m_seq_item); 66 | if (!m_seq_item.randomize())begin 67 | `uvm_fatal("ENDEC_64b66b_SEQ_LIB", "Randomization failed.") 68 | end 69 | finish_item(m_seq_item); 70 | 71 | index += 1; 72 | end 73 | endtask 74 | 75 | endclass 76 | 77 | 78 | /* Sequence generating legal input 79 | * 80 | */ 81 | class endec_64b66b_ve_all_legal_seq extends uvm_sequence#(endec_64b66b_ve_seq_item); 82 | `uvm_object_utils(endec_64b66b_ve_all_legal_seq) 83 | 84 | //sequence items number 85 | rand int m_num_of_items; 86 | //64b66b sequence item 87 | endec_64b66b_ve_seq_item m_seq_item; 88 | 89 | 90 | /* Default constructor 91 | * @param name : instance name 92 | */ 93 | function new(string name = ""); 94 | super.new(name); 95 | endfunction 96 | 97 | 98 | /* Sequence body task implementation 99 | */ 100 | virtual task body(); 101 | string prev_seq_type = ""; 102 | 103 | 104 | repeat(m_num_of_items) begin 105 | // initial item 106 | if (prev_seq_type == "") begin 107 | m_seq_item = endec_64b66b_ve_c_blk_idle_and_err_seq_item::type_id::create("c_seq_item"); 108 | prev_seq_type = m_seq_item.my_type(); 109 | end 110 | else if( 111 | prev_seq_type inside {"endec_64b66b_c_block_seq_item", "endec_64b66b_c_block_idle_and_error_seq_item"} 112 | )begin 113 | // generate only C type or S type 114 | bit dice_on_seq; 115 | void'(std::randomize(dice_on_seq)); 116 | 117 | if (dice_on_seq == 1) begin 118 | m_seq_item = endec_64b66b_ve_s_blk_idle_and_err_seq_item::type_id::create("s_seq_item"); 119 | prev_seq_type = m_seq_item.my_type(); 120 | end 121 | else begin 122 | m_seq_item = endec_64b66b_ve_c_blk_idle_and_err_seq_item::type_id::create("c_seq_item"); 123 | prev_seq_type = m_seq_item.my_type(); 124 | end 125 | 126 | prev_seq_type = m_seq_item.my_type(); 127 | end 128 | else if( 129 | prev_seq_type inside {"endec_64b66b_s_block_seq_item", "endec_64b66b_s_block_idle_and_error_seq_item"} 130 | )begin 131 | // generate only D type or T type 132 | bit dice_on_seq; 133 | void'(std::randomize(dice_on_seq)); 134 | 135 | if (dice_on_seq == 1) begin 136 | m_seq_item = endec_64b66b_ve_t_blk_idle_and_err_seq_item::type_id::create("t_seq_item"); 137 | prev_seq_type = m_seq_item.my_type(); 138 | end 139 | else begin 140 | m_seq_item = endec_64b66b_ve_d_block_seq_item::type_id::create("d_seq_item"); 141 | prev_seq_type = m_seq_item.my_type(); 142 | end 143 | 144 | end 145 | else if( 146 | prev_seq_type inside {"endec_64b66b_t_block_seq_item", "endec_64b66b_t_block_idle_and_error_seq_item"} 147 | )begin 148 | // generate only C type or S type 149 | bit dice_on_seq; 150 | void'(std::randomize(dice_on_seq)); 151 | 152 | if (dice_on_seq == 1) begin 153 | m_seq_item = endec_64b66b_ve_s_blk_idle_and_err_seq_item::type_id::create("s_seq_item"); 154 | prev_seq_type = m_seq_item.my_type(); 155 | end 156 | else begin 157 | m_seq_item = endec_64b66b_ve_c_blk_idle_and_err_seq_item::type_id::create("c_seq_item"); 158 | prev_seq_type = m_seq_item.my_type(); 159 | end 160 | end 161 | else if (prev_seq_type == "endec_64b66b_d_block_seq_item") begin 162 | // generate only D type or T type 163 | bit dice_on_seq; 164 | void'(std::randomize(dice_on_seq)); 165 | 166 | if (dice_on_seq == 1) begin 167 | m_seq_item = endec_64b66b_ve_d_block_seq_item::type_id::create("d_seq_item"); 168 | prev_seq_type = m_seq_item.my_type(); 169 | end 170 | else begin 171 | m_seq_item = endec_64b66b_ve_t_blk_idle_and_err_seq_item::type_id::create("t_seq_item"); 172 | prev_seq_type = m_seq_item.my_type(); 173 | end 174 | end 175 | 176 | 177 | start_item(m_seq_item); 178 | if (!m_seq_item.randomize())begin 179 | `uvm_fatal("ENDEC_64b66b_SEQ_LIB", "Randomization failed.") 180 | end 181 | finish_item(m_seq_item); 182 | end 183 | 184 | endtask 185 | 186 | endclass 187 | 188 | `endif//ENDEC_64b66b_VE_SEQUENCE_LIB_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_sequencer.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_ve_sequencer.sv 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This is the implementation file of endec_64b66b sequencer 21 | *******************************************************************************/ 22 | 23 | `ifndef ENDEC_64b66b_VE_SEQUENCER_SVH 24 | `define ENDEC_64b66b_VE_SEQUENCER_SVH 25 | 26 | /* Sequencer class 27 | * 28 | */ 29 | class endec_64b66b_ve_sequencer extends uvm_sequencer #(endec_64b66b_ve_seq_item); 30 | `uvm_component_utils(endec_64b66b_ve_sequencer) 31 | 32 | //constructor 33 | //@param name - name of the component instance 34 | //@param parent - parent of the component instance 35 | function new (string name, uvm_component parent); 36 | super.new(name, parent); 37 | endfunction 38 | 39 | endclass 40 | 41 | `endif//ENDEC_64b66b_VE_SEQUENCER_SVH 42 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | export PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../../ && pwd )" 4 | export EXAMPLE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../ && pwd )" 5 | 6 | #the default values of the user controlled options 7 | default_test="endec_8b10b_tests_all_k_test" 8 | 9 | export ENDEC_TYPE=endec_8b10b 10 | export DUT_MODULE_NAME=endec_8b10b 11 | 12 | ${PROJECT_DIR}/examples/common/scripts/run.sh -default_test ${default_test} $@ -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/tests/endec_8b10b_tests_all_k_test.svh: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * (C) Copyright 2015 AMIQ Consulting 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | * MODULE: endec_8b10b_tests_all_k_test.svh 18 | * PROJECT: endec_8b10b 19 | * 20 | * 21 | * Description: This file contains the test running only control symbols 22 | *****************************************************************************/ 23 | 24 | `ifndef ENDEC_8b10b_TESTS_ALL_K_TEST_SVH 25 | `define ENDEC_8b10b_TESTS_ALL_K_TEST_SVH 26 | 27 | /* Test class 28 | */ 29 | class endec_8b10b_tests_all_k_test extends endec_8b10b_tests_base_test; 30 | `uvm_component_utils(endec_8b10b_tests_all_k_test) 31 | 32 | /* Constructor 33 | * @param name : name for this component instance 34 | * @param parent : parent for this component 35 | */ 36 | function new(input string name, input uvm_component parent); 37 | super.new(name, parent); 38 | endfunction 39 | 40 | /* UVM build phase 41 | * @param phase - current phase 42 | */ 43 | virtual function void build_phase(uvm_phase phase); 44 | super.build_phase(phase); 45 | endfunction 46 | 47 | /* UVM run phase 48 | * @param phase - current phase 49 | */ 50 | virtual task run_phase(uvm_phase phase); 51 | //send only control symbols 52 | endec_8b10b_ve_encoder_all_k_seq en_seq = endec_8b10b_ve_encoder_all_k_seq::type_id::create( 53 | "seq", m_env.m_enc_agent.m_sequencer_h 54 | ); 55 | endec_8b10b_ve_decoder_response_seq de_seq = endec_8b10b_ve_decoder_response_seq::type_id::create( 56 | "de_seq", m_env.m_dec_agent.m_sequencer_h 57 | ); 58 | 59 | phase.raise_objection(this); 60 | 61 | assert(en_seq.randomize() with {m_nof_items inside {[100:200]};}); 62 | 63 | fork:start_sequencers 64 | begin 65 | en_seq.start(m_env.m_enc_agent.m_sequencer_h); 66 | end 67 | begin 68 | de_seq.start(m_env.m_dec_agent.m_sequencer_h); 69 | end 70 | join_any:start_sequencers 71 | 72 | 73 | phase.drop_objection(this); 74 | endtask 75 | 76 | endclass 77 | 78 | `endif//ENDEC_8b10b_TESTS_ALL_K_TEST_SVH 79 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/tests/endec_8b10b_tests_base_test.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_tests_base_test.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the base test 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_TESTS_BASE_TEST_SVH 24 | `define ENDEC_8b10b_TESTS_BASE_TEST_SVH 25 | 26 | /* Base test class 27 | */ 28 | class endec_8b10b_tests_base_test extends uvm_test; 29 | `uvm_component_utils(endec_8b10b_tests_base_test) 30 | 31 | 32 | // Verification environment 33 | endec_8b10b_ve_env m_env; 34 | 35 | /* Constructor 36 | * @param name : name for this component instance 37 | * @param parent : parent for this component 38 | */ 39 | function new(input string name, input uvm_component parent); 40 | super.new(name, parent); 41 | endfunction 42 | 43 | /* UVM build phase 44 | * @param phase - current phase 45 | */ 46 | virtual function void build_phase(uvm_phase phase); 47 | super.build_phase(phase); 48 | 49 | m_env = endec_8b10b_ve_env::type_id::create("m_env", this); 50 | endfunction 51 | 52 | endclass 53 | 54 | `endif//ENDEC_8b10b_TESTS_BASE_TEST_SVH 55 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/tests/endec_8b10b_tests_encoder_decoder_test.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_tests_encoder_decoder_test.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the test with random symbols 21 | ***************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_TESTS_ENCODER_DECODER_TEST_SVH 24 | `define ENDEC_8b10b_TESTS_ENCODER_DECODER_TEST_SVH 25 | 26 | /* Test class 27 | */ 28 | class endec_8b10b_tests_encoder_decoder_test extends endec_8b10b_tests_base_test; 29 | `uvm_component_utils(endec_8b10b_tests_encoder_decoder_test) 30 | 31 | /* Constructor 32 | * @param name : name for this component instance 33 | * @param parent : parent for this component 34 | */ 35 | function new(input string name, input uvm_component parent); 36 | super.new(name, parent); 37 | endfunction 38 | 39 | /* UVM build phase 40 | * @param phase - current phase 41 | */ 42 | virtual function void build_phase(uvm_phase phase); 43 | super.build_phase(phase); 44 | endfunction 45 | 46 | /* UVM run phase 47 | * @param phase - current phase 48 | */ 49 | virtual task run_phase(uvm_phase phase); 50 | 51 | endec_8b10b_ve_encoder_seq en_seq = endec_8b10b_ve_encoder_seq::type_id::create( 52 | "en_seq", m_env.m_enc_agent.m_sequencer_h 53 | ); 54 | endec_8b10b_ve_decoder_response_seq de_seq = endec_8b10b_ve_decoder_response_seq::type_id::create( 55 | "de_seq", m_env.m_dec_agent.m_sequencer_h 56 | ); 57 | 58 | phase.raise_objection(this); 59 | 60 | assert(en_seq.randomize() with {m_nof_items == 1500;}); 61 | 62 | fork:start_sequencers 63 | begin 64 | en_seq.start(m_env.m_enc_agent.m_sequencer_h); 65 | end 66 | begin 67 | de_seq.start(m_env.m_dec_agent.m_sequencer_h); 68 | end 69 | join_any:start_sequencers 70 | 71 | phase.drop_objection(this); 72 | 73 | endtask 74 | 75 | endclass 76 | 77 | `endif//ENDEC_8b10b_TESTS_ENCODER_DECODER_TEST_SVH 78 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/tests/endec_8b10b_tests_pkg.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_tests_pkg.sv 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: Package containing the tests library 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_TESTS_PKG_SV 24 | `define ENDEC_8b10b_TESTS_PKG_SV 25 | 26 | package endec_8b10b_tests_pkg; 27 | import uvm_pkg::*; 28 | import endec_8b10b_pkg::*; 29 | import endec_8b10b_ve_pkg::*; 30 | `include "uvm_macros.svh" 31 | `include "endec_8b10b_tests_base_test.svh" 32 | `include "endec_8b10b_tests_all_k_test.svh" 33 | `include "endec_8b10b_tests_encoder_decoder_test.svh" 34 | endpackage 35 | 36 | `endif//ENDEC_8b10b_TESTS_PKG_SV 37 | 38 | 39 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_top.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_top.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the top module used for starting the test 21 | *******************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_TOP_SVH 24 | `define ENDEC_8b10b_TOP_SVH 25 | 26 | `timescale 1ns/1ps 27 | 28 | import uvm_pkg::*; 29 | import endec_8b10b_tests_pkg::*; 30 | 31 | module endec_8b10b_top; 32 | 33 | initial begin 34 | run_test(""); 35 | end 36 | 37 | endmodule 38 | 39 | `endif//ENDEC_8b10b_TOP_SVH 40 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_decoder_agent.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_decoder_agent.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the decoding agent 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_VE_DECODER_AGENT_SVH 24 | `define ENDEC_8b10b_VE_DECODER_AGENT_SVH 25 | 26 | /* Decoder agent 27 | */ 28 | class endec_8b10b_ve_decoder_agent extends uvm_agent; 29 | `uvm_component_utils(endec_8b10b_ve_decoder_agent) 30 | 31 | //driver 32 | endec_8b10b_ve_decoder_driver m_driver_h; 33 | 34 | //sequencer 35 | endec_8b10b_ve_decoder_sequencer m_sequencer_h; 36 | 37 | /* Constructor 38 | * @param name : name for this component instance 39 | * @param parent : parent for this component 40 | */ 41 | function new(input string name, input uvm_component parent); 42 | super.new(name, parent); 43 | endfunction 44 | 45 | /* UVM build phase 46 | * @param phase - current phase 47 | */ 48 | virtual function void build_phase(uvm_phase phase); 49 | 50 | super.build_phase(phase); 51 | 52 | m_driver_h = endec_8b10b_ve_decoder_driver::type_id::create("m_driver_h", this); 53 | m_sequencer_h = endec_8b10b_ve_decoder_sequencer::type_id::create("m_sequencer_h", this); 54 | 55 | endfunction 56 | 57 | /* UVM connect phase 58 | * @param phase - current phase 59 | */ 60 | virtual function void connect_phase(uvm_phase phase); 61 | super.connect_phase(phase); 62 | m_driver_h.seq_item_port.connect(m_sequencer_h.seq_item_export); 63 | endfunction 64 | 65 | endclass 66 | 67 | `endif//ENDEC_8b10b_VE_DECODER_AGENT_SVH 68 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_decoder_driver.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_decoder_driver.sv 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the driver used for sending symbols 21 | * to the decoder 22 | *****************************************************************************/ 23 | 24 | `ifndef ENDEC_8b10b_VE_DECODER_DRIVER_SVH 25 | `define ENDEC_8b10b_VE_DECODER_DRIVER_SVH 26 | 27 | /* Decoder driver 28 | */ 29 | class endec_8b10b_ve_decoder_driver extends uvm_driver#(endec_8b10b_ve_decoder_seq_item); 30 | `uvm_component_utils(endec_8b10b_ve_decoder_driver) 31 | 32 | // Decoder 33 | endec_8b10b_decoder m_decoder_h; 34 | 35 | // Analysis ports to report items to other components 36 | uvm_analysis_port #(endec_8b10b_ve_encoder_seq_item) m_symb_8b_analysis_port; 37 | 38 | // Analysis ports to report items to other components 39 | uvm_analysis_port #(endec_8b10b_ve_decoder_seq_item) m_symb_10b_analysis_port; 40 | 41 | /* Constructor 42 | * @param name : name for this component instance 43 | * @param parent : parent for this component 44 | */ 45 | function new(input string name, input uvm_component parent); 46 | super.new(name, parent); 47 | m_symb_8b_analysis_port = new("m_symb_8b_analysis_port", this); 48 | m_symb_10b_analysis_port = new("m_symb_10b_analysis_port", this); 49 | endfunction 50 | 51 | /* UVM build phase 52 | * @param phase - current phase 53 | */ 54 | virtual function void build_phase(uvm_phase phase); 55 | super.build_phase(phase); 56 | m_decoder_h = endec_8b10b_decoder::type_id::create("m_decoder_h", this); 57 | endfunction 58 | 59 | /* UVM run phase 60 | * @param phase - current phase 61 | */ 62 | virtual task run_phase(uvm_phase phase); 63 | //sequence item 64 | endec_8b10b_ve_decoder_seq_item tx; 65 | //struct holding the output from the decoder 66 | endec_8b10b_enc_in_dec_out_s decoder_out_s; 67 | 68 | forever begin 69 | endec_8b10b_ve_encoder_seq_item decoded_tx = endec_8b10b_ve_encoder_seq_item::type_id::create("decoded_tx_dec_drv"); 70 | seq_item_port.get_next_item(tx); 71 | m_symb_10b_analysis_port.write(tx); 72 | 73 | decoder_out_s = m_decoder_h.decode(tx.m_encoded_symbol); 74 | //if errors signal error 75 | ENDEC_8b10b_DECODE_ERROR: assert (decoder_out_s.decode_err == 0) else 76 | `uvm_error("ENDEC_8b10b_DECODE_ERROR", "Item received from decoder contains errors.") 77 | 78 | decoded_tx.m_data = decoder_out_s.enc_dec_8b_val; 79 | decoded_tx.m_is_k_symbol = decoder_out_s.is_k_symbol; 80 | 81 | m_symb_8b_analysis_port.write(decoded_tx); 82 | seq_item_port.item_done(); 83 | end 84 | endtask 85 | 86 | endclass 87 | 88 | `endif//ENDEC_8b10b_VE_DECODER_DRIVER_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_decoder_seq_item.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_decoder_seq_item.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the item that will be decoded 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_VE_DECODER_SEQ_ITEM_SVH 24 | `define ENDEC_8b10b_VE_DECODER_SEQ_ITEM_SVH 25 | 26 | /* Decoder sequence item 27 | */ 28 | class endec_8b10b_ve_decoder_seq_item extends uvm_sequence_item; 29 | 30 | `uvm_object_utils(endec_8b10b_ve_decoder_seq_item) 31 | // 8b10b encoded symbol 32 | rand bit [9:0] m_encoded_symbol; 33 | 34 | /* Default constructor 35 | * @param name : instance name 36 | */ 37 | function new (input string name="8b10b_encoded_data_trans"); 38 | super.new(name); 39 | endfunction 40 | 41 | endclass 42 | 43 | `endif//ENDEC_8b10b_VE_DECODER_SEQ_ITEM_SVH 44 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_decoder_sequencer.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_decoder_sequencer.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This is the implementation file of 8b10b_decoder sequencer 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_VE_DECODER_SEQUENCER_SVH 24 | `define ENDEC_8b10b_VE_DECODER_SEQUENCER_SVH 25 | 26 | /* Decoder sequencer 27 | */ 28 | class endec_8b10b_ve_decoder_sequencer extends uvm_sequencer #(endec_8b10b_ve_decoder_seq_item); 29 | `uvm_component_utils(endec_8b10b_ve_decoder_sequencer) 30 | 31 | // Events used for synchronization 32 | event start_dec_resp_seq; 33 | 34 | // Events used for synchronization 35 | event dec_resp_seq_done; 36 | 37 | // Blocking put import 38 | uvm_blocking_put_imp#(endec_8b10b_ve_decoder_seq_item, endec_8b10b_ve_decoder_sequencer) m_port; 39 | 40 | // Sequence item used to be sent 41 | endec_8b10b_ve_decoder_seq_item m_it; 42 | 43 | /* Constructor 44 | * @param name : instance name 45 | * @param parent : parent component 46 | */ 47 | function new (input string name, input uvm_component parent); 48 | super.new(name, parent); 49 | m_port = new("m_port", this); 50 | endfunction 51 | 52 | /* Put task implementation 53 | * @param t : sequence item to be sent 54 | */ 55 | virtual task put(input endec_8b10b_ve_decoder_seq_item t); 56 | m_it = t; 57 | -> start_dec_resp_seq; 58 | @(dec_resp_seq_done); 59 | endtask 60 | 61 | endclass 62 | 63 | `endif//ENDEC_8b10b_VE_DECODER_SEQUENCER_SVH 64 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_encoder_agent.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_encoder_agent.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains encoding agent 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_VE_ENCODER_AGENT_SVH 24 | `define ENDEC_8b10b_VE_ENCODER_AGENT_SVH 25 | 26 | /* Encoder agent 27 | */ 28 | class endec_8b10b_ve_encoder_agent extends uvm_agent; 29 | `uvm_component_utils(endec_8b10b_ve_encoder_agent) 30 | 31 | // driver 32 | endec_8b10b_ve_encoder_driver m_driver_h; 33 | 34 | // sequencer 35 | endec_8b10b_ve_encoder_sequencer m_sequencer_h; 36 | 37 | /* Constructor 38 | * @param name : name for this component instance 39 | * @param parent : parent for this component 40 | */ 41 | function new(input string name, input uvm_component parent); 42 | super.new(name, parent); 43 | endfunction 44 | 45 | /* UVM build phase 46 | * @param phase - current phase 47 | */ 48 | virtual function void build_phase(uvm_phase phase); 49 | super.build_phase(phase); 50 | 51 | m_sequencer_h = endec_8b10b_ve_encoder_sequencer::type_id::create("m_sequencer_h", this); 52 | m_driver_h = endec_8b10b_ve_encoder_driver::type_id::create("m_driver_h", this); 53 | endfunction 54 | 55 | /* UVM connect phase 56 | * @param phase - current phase 57 | */ 58 | virtual function void connect_phase(uvm_phase phase); 59 | super.connect_phase(phase); 60 | m_driver_h.seq_item_port.connect(m_sequencer_h.seq_item_export); 61 | endfunction 62 | 63 | endclass 64 | 65 | `endif//ENDEC_8b10b_VE_ENCODER_AGENT_SVH 66 | 67 | 68 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_encoder_driver.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_encoder_driver.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the driver used for sending symbols 21 | * to the encoder 22 | *****************************************************************************/ 23 | 24 | `ifndef ENDEC_8b10b_VE_ENCODER_DRIVER_SVH 25 | `define ENDEC_8b10b_VE_ENCODER_DRIVER_SVH 26 | 27 | 28 | /* Encoder driver 29 | */ 30 | class endec_8b10b_ve_encoder_driver extends uvm_driver#(endec_8b10b_ve_encoder_seq_item); 31 | `uvm_component_utils(endec_8b10b_ve_encoder_driver) 32 | 33 | 34 | // Encoder 35 | endec_8b10b_encoder m_encoder_h; 36 | 37 | // Analysis ports to report items to other components 38 | uvm_analysis_port #(endec_8b10b_ve_encoder_seq_item) m_symb_8b_analysis_port; 39 | 40 | // Analysis ports to report items to other components 41 | uvm_analysis_port #(endec_8b10b_ve_decoder_seq_item) m_symb_10b_analysis_port; 42 | 43 | // Put port to sent items to the decoder sequencer 44 | uvm_blocking_put_port#(endec_8b10b_ve_decoder_seq_item) m_dec_seqr_put_port; 45 | 46 | 47 | /* Constructor 48 | * @param name : name for this component instance 49 | * @param parent : parent for this component 50 | */ 51 | function new(input string name, input uvm_component parent); 52 | super.new(name, parent); 53 | m_symb_8b_analysis_port = new("m_symb_8b_analysis_port", this); 54 | m_symb_10b_analysis_port = new("m_symb_10b_analysis_port", this); 55 | endfunction 56 | 57 | /* UVM build phase 58 | * @param phase - current phase 59 | */ 60 | virtual function void build_phase(uvm_phase phase); 61 | super.build_phase(phase); 62 | m_encoder_h = endec_8b10b_encoder::type_id::create("m_encoder_h", this); 63 | 64 | m_dec_seqr_put_port = new("m_dec_seqr_put_port", this); 65 | endfunction 66 | 67 | 68 | /* UVM run phase 69 | * @param phase - current phase 70 | */ 71 | virtual task run_phase(uvm_phase phase); 72 | 73 | endec_8b10b_ve_encoder_seq_item tx; 74 | // struct used as input for the encoder encode() function 75 | endec_8b10b_enc_in_dec_out_s encoder_in_s; 76 | 77 | 78 | forever begin 79 | 80 | endec_8b10b_ve_decoder_seq_item encoded_tx = endec_8b10b_ve_decoder_seq_item::type_id::create("encoded_tx_enc_drv"); 81 | int current_disp = m_encoder_h.m_running_disp; 82 | 83 | seq_item_port.get_next_item(tx); 84 | m_symb_8b_analysis_port.write(tx); 85 | 86 | //populate encoder input struct 87 | encoder_in_s.enc_dec_8b_val = tx.m_data; 88 | encoder_in_s.is_k_symbol = tx.m_is_k_symbol; 89 | 90 | 91 | //populate the sequence item with the output struct contents 92 | encoded_tx.m_encoded_symbol = m_encoder_h.encode(encoder_in_s); 93 | 94 | m_symb_10b_analysis_port.write(encoded_tx); 95 | 96 | m_dec_seqr_put_port.put(encoded_tx); 97 | 98 | seq_item_port.item_done(); 99 | end 100 | 101 | endtask 102 | 103 | endclass 104 | 105 | `endif//ENDEC_8b10b_VE_ENCODER_DRIVER_SVH -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_encoder_seq_item.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_encoder_seq_item.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the item that will be encoded 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_VE_ENCODER_SEQ_ITEM_SVH 24 | `define ENDEC_8b10b_VE_ENCODER_SEQ_ITEM_SVH 25 | 26 | /* Decoder sequence item 27 | */ 28 | class endec_8b10b_ve_encoder_seq_item extends uvm_sequence_item; 29 | `uvm_object_utils(endec_8b10b_ve_encoder_seq_item) 30 | 31 | //if set means the byte to be encoded is 32 | //a control symbol 33 | rand bit m_is_k_symbol; 34 | //un-encoded/decoded data byte 35 | rand bit[7:0] m_data; 36 | 37 | //constrain to generate valid control symbols when flag is set 38 | constraint k_symb { 39 | if (m_is_k_symbol == 1) { 40 | m_data inside {K_28_0_8B, K_28_1_8B, K_28_2_8B, K_28_3_8B, K_28_4_8B, 41 | K_28_5_8B, K_28_6_8B, K_28_7_8B, K_23_7_8B, K_27_7_8B, K_29_7_8B, K_30_7_8B}; 42 | } 43 | } 44 | 45 | /* Default constructor 46 | * @param name : instance name 47 | */ 48 | function new (input string name="8b10b_data_to_encode_trans"); 49 | super.new(name); 50 | endfunction 51 | 52 | endclass 53 | 54 | `endif//ENDEC_8b10b_VE_ENCODER_SEQ_ITEM_SVH 55 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_encoder_sequencer.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_encoder_sequencer.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This is the implementation file of endec_8b10b pkg 21 | * encoder sequencer 22 | *****************************************************************************/ 23 | 24 | `ifndef ENDEC_8b10b_VE_ENCODER_SEQUENCER_SVH 25 | `define ENDEC_8b10b_VE_ENCODER_SEQUENCER_SVH 26 | 27 | /* Encoder sequencer 28 | */ 29 | class endec_8b10b_ve_encoder_sequencer extends uvm_sequencer #(endec_8b10b_ve_encoder_seq_item); 30 | `uvm_component_utils(endec_8b10b_ve_encoder_sequencer) 31 | 32 | /* Constructor 33 | * @param name : name for this component instance 34 | * @param parent : parent for this component 35 | */ 36 | function new (input string name, input uvm_component parent); 37 | super.new(name, parent); 38 | endfunction 39 | 40 | endclass 41 | 42 | `endif//ENDEC_8b10b_VE_ENCODER_SEQUENCER_SVH 43 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_env.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_env.svgh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the environment component 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_VE_ENV_SVH 24 | `define ENDEC_8b10b_VE_ENV_SVH 25 | 26 | /* Environment class 27 | */ 28 | class endec_8b10b_ve_env extends uvm_env; 29 | `uvm_component_utils(endec_8b10b_ve_env) 30 | 31 | // decoder agent 32 | endec_8b10b_ve_decoder_agent m_dec_agent; 33 | 34 | // encoder agent 35 | endec_8b10b_ve_encoder_agent m_enc_agent; 36 | 37 | // scoreboard 38 | endec_8b10b_ve_scb m_scb_8b10b; 39 | 40 | 41 | /* Constructor 42 | * @param name : name for this component instance 43 | * @param parent : parent for this component 44 | */ 45 | function new(input string name, input uvm_component parent); 46 | super.new(name, parent); 47 | endfunction 48 | 49 | /* UVM build phase 50 | * @param phase - current phase 51 | */ 52 | virtual function void build_phase(uvm_phase phase); 53 | super.build_phase(phase); 54 | 55 | m_dec_agent = endec_8b10b_ve_decoder_agent::type_id::create("m_dec_agent", this); 56 | 57 | m_enc_agent = endec_8b10b_ve_encoder_agent::type_id::create("m_enc_agent", this); 58 | 59 | //instantiate the scoreboard 60 | m_scb_8b10b = endec_8b10b_ve_scb::type_id::create("m_scb_8b10b", this); 61 | endfunction 62 | 63 | 64 | /* UVM connect phase 65 | * @param phase - current phase 66 | */ 67 | virtual function void connect_phase(uvm_phase phase); 68 | super.connect_phase(phase); 69 | 70 | m_enc_agent.m_driver_h.m_dec_seqr_put_port.connect(m_dec_agent.m_sequencer_h.m_port); 71 | 72 | //connect encoder and decoder driver with scoreboard 73 | m_enc_agent.m_driver_h.m_symb_8b_analysis_port.connect(m_scb_8b10b.m_encoder_drv_ap); 74 | m_dec_agent.m_driver_h.m_symb_8b_analysis_port.connect(m_scb_8b10b.m_decoder_drv_ap); 75 | 76 | endfunction 77 | 78 | endclass 79 | 80 | `endif//ENDEC_8b10b_VE_ENV_SVH 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_pkg.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_pkg.sv 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: Package containing the verification environment 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_VE_PKG_SV 24 | `define ENDEC_8b10b_VE_PKG_SV 25 | 26 | package endec_8b10b_ve_pkg; 27 | import uvm_pkg::*; 28 | `include "uvm_macros.svh" 29 | import endec_8b10b_pkg::*; 30 | 31 | `include "endec_8b10b_ve_encoder_seq_item.svh" 32 | `include "endec_8b10b_ve_decoder_seq_item.svh" 33 | 34 | `include "endec_8b10b_ve_encoder_sequencer.svh" 35 | `include "endec_8b10b_ve_encoder_driver.svh" 36 | `include "endec_8b10b_ve_decoder_sequencer.svh" 37 | `include "endec_8b10b_ve_decoder_driver.svh" 38 | 39 | `include "endec_8b10b_ve_seq_lib.svh" 40 | `include "endec_8b10b_ve_encoder_agent.svh" 41 | `include "endec_8b10b_ve_decoder_agent.svh" 42 | 43 | `include "endec_8b10b_ve_scb.svh" 44 | `include "endec_8b10b_ve_env.svh" 45 | endpackage 46 | 47 | `endif//ENDEC_8b10b_VE_PKG_SV 48 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_scb.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_scb.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the scoreboard implementation 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_VE_SCB_SVH 24 | `define ENDEC_8b10b_VE_SCB_SVH 25 | 26 | `uvm_analysis_imp_decl(_from_encoder_drv) 27 | `uvm_analysis_imp_decl(_from_decoder_drv) 28 | 29 | /* Scoreboard class 30 | */ 31 | class endec_8b10b_ve_scb extends uvm_scoreboard; 32 | 33 | // analysis ports that report items from encoder driver to the checked 34 | uvm_analysis_imp_from_encoder_drv#(endec_8b10b_ve_encoder_seq_item, endec_8b10b_ve_scb) m_encoder_drv_ap; 35 | 36 | // analysis ports that report items from decoder driver to the checked 37 | uvm_analysis_imp_from_decoder_drv#(endec_8b10b_ve_encoder_seq_item, endec_8b10b_ve_scb) m_decoder_drv_ap; 38 | 39 | // Provide implementations of virtual methods such as get_type_name and create 40 | `uvm_component_utils(endec_8b10b_ve_scb) 41 | 42 | 43 | // list of items received from encoder driver 44 | endec_8b10b_ve_encoder_seq_item m_items_enc_drv[$]; 45 | 46 | /* Constructor 47 | * @param name : name for this component instance 48 | * @param parent : parent for this component 49 | */ 50 | function new (input string name, input uvm_component parent); 51 | super.new(name, parent); 52 | 53 | m_encoder_drv_ap = new("m_encoder_drv_ap", this); 54 | m_decoder_drv_ap = new("m_decoder_drv_ap", this); 55 | endfunction : new 56 | 57 | /* Function that saves the item received from the encoder 58 | * @param a_enc_drv_item - item received from the encoder agent driver 59 | */ 60 | virtual function void write_from_encoder_drv (endec_8b10b_ve_encoder_seq_item a_enc_drv_item); 61 | m_items_enc_drv.push_back(a_enc_drv_item); 62 | `uvm_info("SCB_8b10b", $sformatf("Received item from encoder with value = %x and is_k_symbol = %x", 63 | a_enc_drv_item.m_data, a_enc_drv_item.m_is_k_symbol), UVM_HIGH) 64 | endfunction 65 | 66 | /* Function performs scoreboarding each time it received a decoded item 67 | * @param a_dec_drv_item - item received from the decoder driver 68 | */ 69 | virtual function void write_from_decoder_drv (endec_8b10b_ve_encoder_seq_item a_dec_drv_item); 70 | `uvm_info("SCB_8b10b", $sformatf("Received item from decoder with value = %x and is_k_symbol = %x", 71 | a_dec_drv_item.m_data, a_dec_drv_item.m_is_k_symbol), UVM_HIGH) 72 | if (m_items_enc_drv.size() == 0) begin 73 | `uvm_error("SCB_8b10b", $sformatf("Decoder reported an item while list of items from the driver is empty")) 74 | end 75 | 76 | begin 77 | endec_8b10b_ve_encoder_seq_item expected_item = m_items_enc_drv.pop_front(); 78 | 79 | if (expected_item.m_data != a_dec_drv_item.m_data) begin 80 | `uvm_error("SCB_8b10b", $sformatf("Difference between decoded symbol value %x and encoded item %x", 81 | a_dec_drv_item.m_data, expected_item.m_data)) 82 | end 83 | else if (expected_item.m_is_k_symbol != a_dec_drv_item.m_is_k_symbol) begin 84 | `uvm_error("SCB_8b10b", $sformatf("Difference between decoded symbol type %x and encoded item type %x", 85 | a_dec_drv_item.m_is_k_symbol, expected_item.m_is_k_symbol)) 86 | end 87 | else `uvm_info("SCB_8b10b", $sformatf("Scoreboarding passed for decoded value = %x with is_k_symbol = %x", 88 | a_dec_drv_item.m_data, a_dec_drv_item.m_is_k_symbol), UVM_HIGH) 89 | end 90 | endfunction 91 | 92 | endclass 93 | 94 | `endif//ENDEC_8b10b_VE_SCB_SVH 95 | -------------------------------------------------------------------------------- /encoder_decoder/examples/endec_8b10b/ve/endec_8b10b_ve_seq_lib.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_ve_seq_lib.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains the sequence library. 21 | *****************************************************************************/ 22 | `ifndef ENDEC_8b10b_VE_SEQ_LIB_SVH 23 | `define ENDEC_8b10b_VE_SEQ_LIB_SVH 24 | 25 | /* Decoder response sequence 26 | */ 27 | class endec_8b10b_ve_decoder_response_seq extends uvm_sequence #(endec_8b10b_ve_decoder_seq_item); 28 | `uvm_object_utils(endec_8b10b_ve_decoder_response_seq) 29 | `uvm_declare_p_sequencer(endec_8b10b_ve_decoder_sequencer) 30 | 31 | // Sequence item 32 | endec_8b10b_ve_decoder_seq_item m_seq_item; 33 | 34 | /* Default constructor 35 | * @param name : instance name 36 | */ 37 | function new(input string name = ""); 38 | super.new(name); 39 | endfunction 40 | 41 | /* body() task implementation 42 | */ 43 | virtual task body(); 44 | forever begin 45 | @(p_sequencer.start_dec_resp_seq); 46 | 47 | m_seq_item = endec_8b10b_ve_decoder_seq_item::type_id::create("m_seq_item",,get_full_name()); 48 | start_item(m_seq_item); 49 | m_seq_item.m_encoded_symbol = p_sequencer.m_it.m_encoded_symbol; 50 | finish_item(m_seq_item); 51 | -> p_sequencer.dec_resp_seq_done; 52 | end 53 | endtask 54 | endclass 55 | 56 | /* Basic encoder sequence 57 | */ 58 | class endec_8b10b_ve_encoder_seq extends uvm_sequence #(endec_8b10b_ve_encoder_seq_item); 59 | `uvm_object_utils(endec_8b10b_ve_encoder_seq) 60 | 61 | // Number of items in sequence 62 | rand int m_nof_items; 63 | 64 | // Sequence item 65 | endec_8b10b_ve_encoder_seq_item m_seq_item; 66 | 67 | /* Default constructor 68 | * @param name : instance name 69 | */ 70 | function new(input string name = ""); 71 | super.new(name); 72 | endfunction 73 | 74 | /* body() task implementation 75 | */ 76 | virtual task body(); 77 | repeat(m_nof_items) begin 78 | m_seq_item = endec_8b10b_ve_encoder_seq_item::type_id::create("m_seq_item",,get_full_name()); 79 | start_item(m_seq_item); 80 | if (!m_seq_item.randomize()) begin 81 | `uvm_fatal(get_type_name(), "Randomization failed.") 82 | end 83 | finish_item(m_seq_item); 84 | end 85 | endtask 86 | endclass 87 | 88 | 89 | /* Sequence for control symbols only 90 | */ 91 | class endec_8b10b_ve_encoder_all_k_seq extends endec_8b10b_ve_encoder_seq; 92 | `uvm_object_utils(endec_8b10b_ve_encoder_all_k_seq) 93 | 94 | /* Default constructor 95 | * @param name : instance name 96 | */ 97 | function new(input string name = ""); 98 | super.new(name); 99 | endfunction 100 | 101 | /* body() task implementation 102 | */ 103 | virtual task body(); 104 | repeat(m_nof_items) begin 105 | m_seq_item = endec_8b10b_ve_encoder_seq_item::type_id::create("m_seq_item",,get_full_name()); 106 | start_item(m_seq_item); 107 | if (!(m_seq_item.randomize() with {m_is_k_symbol == 1;})) begin 108 | `uvm_fatal(get_type_name(), "Randomization failed.") 109 | end 110 | finish_item(m_seq_item); 111 | end 112 | endtask 113 | endclass 114 | 115 | /* Sequence for data symbols only 116 | */ 117 | class endec_8b10b_ve_encoder_all_d_seq extends endec_8b10b_ve_encoder_seq; 118 | `uvm_object_utils(endec_8b10b_ve_encoder_all_d_seq) 119 | 120 | /* Default constructor 121 | * @param name : instance name 122 | */ 123 | function new(input string name = ""); 124 | super.new(name); 125 | endfunction 126 | 127 | /* body() task implementation 128 | */ 129 | virtual task body(); 130 | repeat(m_nof_items) begin 131 | m_seq_item = endec_8b10b_ve_encoder_seq_item::type_id::create("m_seq_item",,get_full_name()); 132 | start_item(m_seq_item); 133 | if (!(m_seq_item.randomize() with {m_is_k_symbol == 0;})) begin 134 | `uvm_fatal(get_type_name(), "Randomization failed.") 135 | end 136 | finish_item(m_seq_item); 137 | end 138 | endtask 139 | endclass 140 | 141 | `endif//ENDEC_8b10b_VE_SEQ_LIB_SVH -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_64b66b/endec_64b66b_cov_items.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_cov_items.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: Classes holding the coverage information 21 | *******************************************************************************/ 22 | 23 | `ifndef ENDEC_64b66b_COV_ITEMS_SVH 24 | `define ENDEC_64b66b_COV_ITEMS_SVH 25 | 26 | /* Class holding the coverage points to be send 27 | * to the decoder coverage class 28 | */ 29 | class endec_64b66b_encoder_cov_c extends uvm_object; 30 | `uvm_object_utils(endec_64b66b_encoder_cov_c) 31 | 32 | // holds state of the transmit state machine 33 | endec_64b66b_transmit_sm_states_e m_transmit_state; 34 | 35 | // this bit will tell if the block formats should 36 | // be used for coverage for a struct instance 37 | bit m_tx_blk_formats_sampled; 38 | // this bit is used for the cross coverage to avoid 39 | // cross coverage on input when the previous input does not exist 40 | bit m_first_sample_done; 41 | // holds current format 42 | endec_64b66b_block_formats_e m_tx_blk_format; 43 | // holds previous format 44 | endec_64b66b_block_formats_e m_prev_tx_blk_format; 45 | 46 | /* Constructor 47 | * @param name : name for this instance 48 | */ 49 | function new(input string name= "endec_64b66b_encoder_cov_c"); 50 | super.new(name); 51 | endfunction 52 | 53 | endclass 54 | 55 | 56 | /* Class holding the coverage points to be send 57 | * to the decoder coverage class 58 | */ 59 | class endec_64b66b_decoder_cov_c extends uvm_object; 60 | `uvm_object_utils(endec_64b66b_decoder_cov_c) 61 | 62 | // holds current state of the state machine 63 | endec_64b66b_receive_sm_states_e m_receive_state; 64 | 65 | // this bit will tell if the block formats should 66 | // be used for coverage for a class instance 67 | bit m_rx_blk_formats_sampled; 68 | // this bit is used for the cross coverage to avoid 69 | // cross coverage on input when the previous input does not exist 70 | bit m_first_sample_done; 71 | // holds current format 72 | endec_64b66b_block_formats_e m_rx_blk_format; 73 | // holds previous format 74 | endec_64b66b_block_formats_e m_prev_rx_blk_format; 75 | 76 | /* Constructor 77 | * @param name : name for this instance 78 | */ 79 | function new(input string name= "endec_64b66b_decoder_cov_c"); 80 | super.new(name); 81 | endfunction 82 | 83 | endclass 84 | 85 | `endif //ENDEC_64b66b_COV_ITEMS_SVH -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_64b66b/endec_64b66b_decoder_cov.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_decoder_cov.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This is the implementation file of the 64b/66b decoder coverage 21 | * class that's part of endec_64b66b package 22 | *******************************************************************************/ 23 | 24 | `ifndef ENDEC_64b66b_DECODER_COV_SVH 25 | `define ENDEC_64b66b_DECODER_COV_SVH 26 | 27 | 28 | /* Decoder coverage class 29 | * Receives the coverage data from the decoder component 30 | */ 31 | class endec_64b66b_decoder_cov extends uvm_component; 32 | `uvm_component_utils(endec_64b66b_decoder_cov) 33 | 34 | 35 | // receives to structure containing data from the decoder to be covered 36 | uvm_analysis_imp #(endec_64b66b_decoder_cov_c, endec_64b66b_decoder_cov) m_get_data_to_cov_ai; 37 | 38 | // cover the receive state machine transitions 39 | covergroup cg_receive_state with function sample(endec_64b66b_receive_sm_states_e receive_state); 40 | STATE: coverpoint receive_state 41 | { 42 | bins receive_state [] = (RX_C, RX_D, RX_T, RX_E => RX_C, RX_D, RX_T, RX_E); 43 | illegal_bins illegal = (RX_C => RX_T), (RX_D => RX_C), (RX_T => RX_T); 44 | type_option.comment = "Transition of state machine states."; 45 | } 46 | endgroup 47 | 48 | // cover the format of the blocks 49 | covergroup cg_receive_blk_format with function sample(endec_64b66b_block_formats_e rx_block_format); 50 | BLOCK_FORMAT: coverpoint rx_block_format 51 | { 52 | type_option.comment = "Coverage of the type of the received block formats."; 53 | } 54 | endgroup 55 | 56 | // cross between two consecutive block formats 57 | covergroup cg_receive_blk_format_cross with function sample( 58 | endec_64b66b_block_formats_e m_prev_rx_blk_format, endec_64b66b_block_formats_e m_rx_blk_format 59 | ); 60 | BLK_FORMAT_TRANS: cross m_prev_rx_blk_format, m_rx_blk_format 61 | { 62 | ignore_bins ignore = 63 | // illegal case if we go from C_block to D_block or T_block 64 | ( 65 | binsof (m_prev_rx_blk_format) intersect { 66 | ALL_CONTROL_FORMAT, CONTROL_ORDSET_FORMAT, ORDSET_ORDSET_FORMAT, ORDSET_CONTROL_FORMAT 67 | } 68 | && 69 | binsof (m_rx_blk_format) intersect { 70 | ALL_DATA_FORMAT, TERMINATE7_FORMAT, TERMINATE6_FORMAT, TERMINATE5_FORMAT, TERMINATE4_FORMAT, 71 | TERMINATE3_FORMAT, TERMINATE2_FORMAT, TERMINATE1_FORMAT, TERMINATE0_FORMAT 72 | } 73 | ) 74 | || 75 | // illegal case if we go from S_block to C_block or S_block 76 | ( 77 | binsof (m_prev_rx_blk_format) intersect {CONTROL_START_FORMAT, ORDSET_START_FORMAT, START_DATA_FORMAT} 78 | && 79 | binsof (m_rx_blk_format) intersect { 80 | ALL_CONTROL_FORMAT, CONTROL_ORDSET_FORMAT, ORDSET_ORDSET_FORMAT, ORDSET_CONTROL_FORMAT, 81 | CONTROL_START_FORMAT, ORDSET_START_FORMAT, START_DATA_FORMAT 82 | } 83 | ) 84 | || 85 | // illegal case if we go from D_block to C_block or S_block 86 | ( 87 | binsof (m_prev_rx_blk_format) intersect {ALL_DATA_FORMAT} 88 | && 89 | binsof (m_rx_blk_format) intersect { 90 | ALL_CONTROL_FORMAT, CONTROL_ORDSET_FORMAT, ORDSET_ORDSET_FORMAT, ORDSET_CONTROL_FORMAT, 91 | CONTROL_START_FORMAT, ORDSET_START_FORMAT, START_DATA_FORMAT 92 | } 93 | ) 94 | || 95 | // illegal case if we go from T_block to D_block or T_block 96 | ( 97 | binsof (m_prev_rx_blk_format) intersect { 98 | TERMINATE7_FORMAT, TERMINATE6_FORMAT, TERMINATE5_FORMAT, TERMINATE4_FORMAT, TERMINATE3_FORMAT, 99 | TERMINATE2_FORMAT, TERMINATE1_FORMAT, TERMINATE0_FORMAT 100 | } 101 | && 102 | binsof (m_rx_blk_format) intersect { 103 | ALL_DATA_FORMAT, TERMINATE7_FORMAT, TERMINATE6_FORMAT, TERMINATE5_FORMAT, TERMINATE4_FORMAT, 104 | TERMINATE3_FORMAT, TERMINATE2_FORMAT, TERMINATE1_FORMAT, TERMINATE0_FORMAT 105 | } 106 | ); 107 | type_option.comment = "Cross between previously and currently received block formats."; 108 | } 109 | endgroup 110 | 111 | 112 | /* Constructor 113 | * @param name : name for this component instance 114 | * @param parent : parent for this component 115 | */ 116 | function new(string name, uvm_component parent); 117 | super.new(name, parent); 118 | 119 | cg_receive_state = new(); 120 | cg_receive_blk_format = new(); 121 | cg_receive_blk_format_cross = new(); 122 | endfunction 123 | 124 | 125 | /* UVM build phase 126 | * @param phase - current phase 127 | */ 128 | virtual function void build_phase(uvm_phase phase); 129 | super.build_phase(phase); 130 | 131 | // allocate the analysis implementation 132 | m_get_data_to_cov_ai = new("m_get_data_to_cov_ai", this); 133 | endfunction 134 | 135 | 136 | /* write() function implementation 137 | * @param a_cov_data : input item from the driver received after decoding process 138 | */ 139 | virtual function void write(endec_64b66b_decoder_cov_c a_cov_data); 140 | `uvm_info("DECODER_64b66b_COVERAGE", $sformatf("%b", a_cov_data.m_first_sample_done), UVM_MEDIUM) 141 | `uvm_info("DECODER_64b66b_COVERAGE", $sformatf("%s", a_cov_data.m_receive_state), UVM_MEDIUM) 142 | 143 | 144 | cg_receive_state.sample(a_cov_data.m_receive_state); 145 | if (a_cov_data.m_rx_blk_formats_sampled == 1) begin 146 | cg_receive_blk_format.sample(a_cov_data.m_rx_blk_format); 147 | if (a_cov_data.m_first_sample_done == 1) begin 148 | cg_receive_blk_format_cross.sample(a_cov_data.m_prev_rx_blk_format ,a_cov_data.m_rx_blk_format); 149 | end 150 | end 151 | endfunction 152 | 153 | endclass 154 | 155 | `endif//ENDEC_64b66b_DECODER_COV_SVH 156 | -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_64b66b/endec_64b66b_defines.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_defines.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: Defines file for the endec_64b66b package 21 | *******************************************************************************/ 22 | 23 | 24 | `ifndef ENDEC_64b66b_DEFINES_SVH 25 | `define ENDEC_64b66b_DEFINES_SVH 26 | 27 | // default error block output 28 | `define T_EBLOCK_T {2'b10,8'hfe,{8{7'h1e}}} 29 | 30 | // used as output from decoding logic in case of error 31 | `define R_EBLOCK_T {4'hf, {4{8'hfe}}, 4'hf, {4{8'hfe}}} 32 | 33 | `endif//ENDEC_64b66b_DEFINES_SVH 34 | 35 | 36 | -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_64b66b/endec_64b66b_encoder_cov.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_encoder_cov.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This is the implementation file of the 64b/66b encoder coverage 21 | * class that's part of endec_64b66b package 22 | *******************************************************************************/ 23 | 24 | `ifndef ENDEC_64b66b_ENCODER_COV_SVH 25 | `define ENDEC_64b66b_ENCODER_COV_SVH 26 | 27 | 28 | /* Encoder coverage class 29 | * Receives the coverage data from the encoder component 30 | */ 31 | class endec_64b66b_encoder_cov extends uvm_component; 32 | `uvm_component_utils(endec_64b66b_encoder_cov) 33 | 34 | 35 | // receives the structure containing data from the encoder to be covered 36 | uvm_analysis_imp #(endec_64b66b_encoder_cov_c, endec_64b66b_encoder_cov) m_get_data_to_cov_ai; 37 | 38 | 39 | // cover the evolution of the transmit state machine 40 | covergroup cg_transmit_state with function sample(endec_64b66b_transmit_sm_states_e transmit_state); 41 | STATE: coverpoint transmit_state 42 | { 43 | bins transmit_state [] = (TX_C, TX_D, TX_T, TX_E => TX_C, TX_D, TX_T, TX_E); 44 | illegal_bins illegal = (TX_C => TX_T), (TX_D => TX_C), (TX_T => TX_T); 45 | type_option.comment = "Transition of state machine states."; 46 | } 47 | endgroup 48 | 49 | // cover the format of the blocks 50 | covergroup cg_transmit_blk_format with function sample(endec_64b66b_block_formats_e tx_block_format); 51 | BLK_FORMAT: coverpoint tx_block_format 52 | { 53 | type_option.comment = "Coverage of the type of the transmitted block formats."; 54 | } 55 | endgroup 56 | 57 | // cross between two consecutive block formats 58 | covergroup cg_transmit_blk_format_cross with function sample( 59 | endec_64b66b_block_formats_e m_prev_tx_blk_format, endec_64b66b_block_formats_e m_tx_blk_format 60 | ); 61 | BLK_FORMAT_TRANS: cross m_prev_tx_blk_format, m_tx_blk_format 62 | { 63 | ignore_bins ignore = 64 | // illegal case if we go from C_block to D_block or T_block 65 | ( 66 | binsof (m_prev_tx_blk_format) intersect { 67 | ALL_CONTROL_FORMAT, CONTROL_ORDSET_FORMAT, ORDSET_ORDSET_FORMAT, ORDSET_CONTROL_FORMAT 68 | } 69 | && 70 | binsof (m_tx_blk_format) intersect { 71 | ALL_DATA_FORMAT, TERMINATE7_FORMAT, TERMINATE6_FORMAT, TERMINATE5_FORMAT, TERMINATE4_FORMAT, 72 | TERMINATE3_FORMAT, TERMINATE2_FORMAT, TERMINATE1_FORMAT, TERMINATE0_FORMAT 73 | } 74 | ) 75 | || 76 | // illegal case if we go from S_block to C_block or S_block 77 | ( 78 | binsof (m_prev_tx_blk_format) intersect { 79 | CONTROL_START_FORMAT, ORDSET_START_FORMAT, START_DATA_FORMAT 80 | } 81 | && 82 | binsof (m_tx_blk_format) intersect { 83 | ALL_CONTROL_FORMAT, CONTROL_ORDSET_FORMAT, ORDSET_ORDSET_FORMAT, ORDSET_CONTROL_FORMAT, 84 | CONTROL_START_FORMAT, ORDSET_START_FORMAT, START_DATA_FORMAT 85 | } 86 | ) 87 | || 88 | // illegal case if we go from D_block to C_block or S_block 89 | ( 90 | binsof (m_prev_tx_blk_format) intersect {ALL_DATA_FORMAT} 91 | && 92 | binsof (m_tx_blk_format) intersect { 93 | ALL_CONTROL_FORMAT, CONTROL_ORDSET_FORMAT, ORDSET_ORDSET_FORMAT, ORDSET_CONTROL_FORMAT, 94 | CONTROL_START_FORMAT, ORDSET_START_FORMAT, START_DATA_FORMAT 95 | } 96 | ) 97 | || 98 | // illegal case if we go from T_block to D_block or T_block 99 | ( 100 | binsof (m_prev_tx_blk_format) intersect { 101 | TERMINATE7_FORMAT, TERMINATE6_FORMAT, TERMINATE5_FORMAT, TERMINATE4_FORMAT, TERMINATE3_FORMAT, 102 | TERMINATE2_FORMAT, TERMINATE1_FORMAT, TERMINATE0_FORMAT 103 | } 104 | && 105 | binsof (m_tx_blk_format) intersect { 106 | ALL_DATA_FORMAT, TERMINATE7_FORMAT, TERMINATE6_FORMAT, TERMINATE5_FORMAT, TERMINATE4_FORMAT, 107 | TERMINATE3_FORMAT, TERMINATE2_FORMAT, TERMINATE1_FORMAT, TERMINATE0_FORMAT 108 | } 109 | ); 110 | type_option.comment = "Cross between previously and currently transmitted block formats."; 111 | } 112 | endgroup 113 | 114 | 115 | /* Constructor 116 | * @param name : name for this component instance 117 | * @param parent : parent for this component 118 | */ 119 | function new(string name, uvm_component parent); 120 | super.new(name, parent); 121 | 122 | cg_transmit_state = new(); 123 | cg_transmit_blk_format = new(); 124 | cg_transmit_blk_format_cross = new(); 125 | endfunction 126 | 127 | 128 | /* UVM build phase 129 | * @param phase - current phase 130 | */ 131 | virtual function void build_phase(uvm_phase phase); 132 | super.build_phase(phase); 133 | 134 | // allocate the analysis implementation 135 | m_get_data_to_cov_ai = new("m_get_data_to_cov_ai", this); 136 | endfunction 137 | 138 | 139 | /* write() function implementation 140 | * @param a_cov_data : input item from the driver received after decoding process 141 | */ 142 | virtual function void write(endec_64b66b_encoder_cov_c a_cov_data); 143 | `uvm_info("ENCODER_64b66b_COVERAGE", $sformatf("%b", a_cov_data.m_first_sample_done), UVM_MEDIUM) 144 | `uvm_info("ENCODER_64b66b_COVERAGE", $sformatf("%s", a_cov_data.m_transmit_state), UVM_MEDIUM) 145 | 146 | 147 | cg_transmit_state.sample(a_cov_data.m_transmit_state); 148 | if (a_cov_data.m_tx_blk_formats_sampled == 1) begin 149 | cg_transmit_blk_format.sample(a_cov_data.m_tx_blk_format); 150 | if (a_cov_data.m_first_sample_done == 1) begin 151 | cg_transmit_blk_format_cross.sample(a_cov_data.m_prev_tx_blk_format ,a_cov_data.m_tx_blk_format); 152 | end 153 | end 154 | endfunction 155 | 156 | endclass 157 | 158 | `endif//ENDEC_64b66b_ENCODER_COV_SVH -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_64b66b/endec_64b66b_pkg.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_pkg.sv 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: This is the package file 21 | *******************************************************************************/ 22 | 23 | 24 | `ifndef ENDEC_64b66b_PKG_SV 25 | `define ENDEC_64b66b_PKG_SV 26 | 27 | `include "uvm_macros.svh" 28 | 29 | package endec_64b66b_pkg; 30 | import uvm_pkg::*; 31 | 32 | 33 | `include "endec_64b66b_defines.svh" 34 | `include "endec_64b66b_types.svh" 35 | `include "endec_64b66b_cov_items.svh" 36 | `include "endec_64b66b_encoder_cov.svh" 37 | `include "endec_64b66b_encoder.svh" 38 | `include "endec_64b66b_decoder_cov.svh" 39 | `include "endec_64b66b_decoder.svh" 40 | 41 | endpackage 42 | 43 | `endif -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_64b66b/endec_64b66b_types.svh: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_types.svh 17 | * PROJECT: endec_64b66b 18 | * 19 | * 20 | * Description: File containing types used by the endec_64b66b package 21 | ****************************************************************************/ 22 | 23 | `ifndef ENDEC_64b66b_TYPES_SVH 24 | `define ENDEC_64b66b_TYPES_SVH 25 | 26 | // enum holding the 5 possible block types 27 | typedef enum { 28 | C_BLOCK=0, S_BLOCK=1, T_BLOCK=2, D_BLOCK=3, E_BLOCK=4 29 | } endec_64b66b_rx_tx_block_type_e; 30 | 31 | 32 | // enum holding the defined control characters on xgmii interface 33 | typedef enum byte unsigned { 34 | I_CONTROL= 8'h07, S_CONTROL=8'hfb, T_CONTROL=8'hfd, E_CONTROL=8'hfe, Q_CONTROL=8'h9c, NON_CONTROL=8'h00 35 | } endec_64b66b_xgmii_control_code_e; 36 | 37 | 38 | // enum for valid block formats 39 | typedef enum { 40 | // DDDD/DDDD 41 | ALL_DATA_FORMAT=0, 42 | // CCCC/CCCC 43 | ALL_CONTROL_FORMAT=1, 44 | // CCCC/ODDD 45 | CONTROL_ORDSET_FORMAT=2, 46 | // CCCC/SDDD 47 | CONTROL_START_FORMAT=3, 48 | // ODDD/SDDD 49 | ORDSET_START_FORMAT=4, 50 | // ODDD/ODDD 51 | ORDSET_ORDSET_FORMAT=5, 52 | // SDDD/DDDD 53 | START_DATA_FORMAT=6, 54 | // ODDD/CCCC 55 | ORDSET_CONTROL_FORMAT=7, 56 | // TCCC/CCCC 57 | TERMINATE7_FORMAT=8, 58 | // DTCC/CCCC 59 | TERMINATE6_FORMAT=9, 60 | // DDTC/CCCC 61 | TERMINATE5_FORMAT=10, 62 | // DDDT/CCCC 63 | TERMINATE4_FORMAT=11, 64 | // DDDD/TCCC 65 | TERMINATE3_FORMAT=12, 66 | // DDDD/DTCC 67 | TERMINATE2_FORMAT=13, 68 | // DDDD/DDTC 69 | TERMINATE1_FORMAT=14, 70 | // DDDD/DDDT 71 | TERMINATE0_FORMAT=15 72 | } endec_64b66b_block_formats_e; 73 | 74 | 75 | // enum for block type fields 76 | typedef enum byte unsigned { 77 | BLK_TYPE_0 = 8'h1e, 78 | BLK_TYPE_1 = 8'h2d, 79 | BLK_TYPE_2 = 8'h33, 80 | BLK_TYPE_3 = 8'h66, 81 | BLK_TYPE_4 = 8'h55, 82 | BLK_TYPE_5 = 8'h78, 83 | BLK_TYPE_6 = 8'h4b, 84 | BLK_TYPE_7 = 8'h87, 85 | BLK_TYPE_8 = 8'h99, 86 | BLK_TYPE_9 = 8'haa, 87 | BLK_TYPE_10= 8'hb4, 88 | BLK_TYPE_11= 8'hcc, 89 | BLK_TYPE_12= 8'hd2, 90 | BLK_TYPE_13= 8'he1, 91 | BLK_TYPE_14= 8'hff 92 | } endec_64b66b_block_type_field_e; 93 | 94 | 95 | // by default it's int 96 | // type used to name the states of the transmitting state machine 97 | typedef enum { 98 | TX_INIT=0, TX_C=1, TX_D=2, TX_T=3, TX_E=4 99 | } endec_64b66b_transmit_sm_states_e; 100 | 101 | 102 | // unpacked 7bit array 103 | // used as return type of function 104 | typedef bit[6:0] bits7_unpacked_arr []; 105 | 106 | 107 | // type used to name the states of the receiving state machine 108 | typedef enum { 109 | RX_INIT=0, RX_C=1, RX_D=2, RX_T=3, RX_E=4 110 | } endec_64b66b_receive_sm_states_e; 111 | 112 | 113 | `endif -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_8b10b/endec_8b10b_cov_item.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_cov_item.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains classes holding the coverage information 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_COV_ITEM_SVH 24 | `define ENDEC_8b10b_COV_ITEM_SVH 25 | 26 | 27 | /* Class holding coverage information related to the 28 | * uncoded data 29 | */ 30 | class endec_8b10b_cov_data extends uvm_object; 31 | `uvm_object_utils(endec_8b10b_cov_data) 32 | 33 | //if set means the byte to be encoded 34 | //or the one that's been decoded is 35 | //a control symbol 36 | bit m_is_k_symbol; 37 | 38 | //un-encoded/decoded data byte 39 | bit[7:0] m_data; 40 | 41 | //encoded symbol, output of the encoder 42 | //or input of the decoder 43 | bit[9:0] m_encoded_symb; 44 | 45 | //field holding disparity before 46 | //processing (for encoding and decoding) 47 | int m_pre_disp; 48 | //field holding disparity after 49 | //processing (for encoding and decoding) 50 | int m_post_disp; 51 | 52 | /* Constructor 53 | * @param name : name for this instance 54 | */ 55 | function new(input string name="endec_8b10b_cov_data"); 56 | //class constructor 57 | super.new(name); 58 | endfunction 59 | endclass 60 | 61 | `endif//ENDEC_8b10b_COV_ITEM_SVH 62 | -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_8b10b/endec_8b10b_coverage.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_coverage.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains agent coverage collector 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_COVERAGE_SVH 24 | `define ENDEC_8b10b_COVERAGE_SVH 25 | 26 | 27 | /* Coverage component 28 | */ 29 | class endec_8b10b_coverage extends uvm_component; 30 | `uvm_component_utils(endec_8b10b_coverage) 31 | 32 | 33 | //analysis import delivering the coverage item 34 | uvm_analysis_imp#(endec_8b10b_cov_data, endec_8b10b_coverage) m_cov_data_ap; 35 | 36 | 37 | //if set means the byte to be encoded is a control symbol 38 | bit m_is_k_symbol; 39 | 40 | //received 8b10b encoded symbol 41 | bit[9:0] m_symbol_10b; 42 | 43 | //received un-encoded/decoded data byte 44 | bit[7:0] m_symbol_8b; 45 | 46 | //holds the disparity throughout the encoding process, initial value is -1 47 | int m_running_disp; 48 | 49 | //previous symbol received 50 | bit[3:0] m_prev_symbol_4b; 51 | 52 | // Cover group for the 8bit symbol 53 | covergroup symbol_8b_cov; 54 | 55 | option.per_instance = 1; 56 | 57 | // Cover type of symbol : data or control 58 | k_d_symbols : coverpoint m_is_k_symbol { 59 | bins k_symbol = {1}; 60 | bins d_symbol = {0}; 61 | } 62 | 63 | // Cover transitions between types of symbol 64 | k_d_symb_trans : coverpoint m_is_k_symbol { 65 | bins transitions[] = (0,1=>0,1); 66 | } 67 | 68 | // Cover the running disparity 69 | disparity : coverpoint m_running_disp { 70 | bins negative = {-1}; 71 | bins positive = {1}; 72 | } 73 | 74 | // Cover the disparity transitions 75 | disp_trans : coverpoint m_running_disp { 76 | bins transitions[] = (-1,1=>-1,1); 77 | } 78 | 79 | // Cover the 8bit data symbol 80 | symbol_8b : coverpoint m_symbol_8b { 81 | bins values[] = {[8'h0:8'hFF]}; 82 | } 83 | 84 | // Cover the 8bit input symbol crossed with type of the symbol 85 | crs_k_d_value : cross symbol_8b, k_d_symbols { 86 | ignore_bins ignore = !binsof(symbol_8b) intersect { 87 | K_28_0_8B, 88 | K_28_1_8B, 89 | K_28_2_8B, 90 | K_28_3_8B, 91 | K_28_4_8B, 92 | K_28_5_8B, 93 | K_28_6_8B, 94 | K_28_7_8B, 95 | K_23_7_8B, 96 | K_27_7_8B, 97 | K_29_7_8B, 98 | K_30_7_8B} && binsof(k_d_symbols) intersect {1}; 99 | } 100 | 101 | // Cover the 8bit symbol crossed with type of symbol and disparity 102 | crs_k_d_val_disp :cross symbol_8b, k_d_symbols, disparity { 103 | ignore_bins ignore = !binsof(symbol_8b) intersect { 104 | K_28_0_8B, 105 | K_28_1_8B, 106 | K_28_2_8B, 107 | K_28_3_8B, 108 | K_28_4_8B, 109 | K_28_5_8B, 110 | K_28_6_8B, 111 | K_28_7_8B, 112 | K_23_7_8B, 113 | K_27_7_8B, 114 | K_29_7_8B, 115 | K_30_7_8B} && binsof(k_d_symbols) intersect {1} && binsof(disparity) intersect {-1, 1}; 116 | } 117 | 118 | endgroup 119 | 120 | // Cover group for the 10bit symbol 121 | covergroup symbol_10b_cov; 122 | 123 | option.per_instance = 1; 124 | 125 | // Cover the 6bit code group 126 | symbol_6b : coverpoint m_symbol_10b[9:4] { 127 | bins symbol_6b[] = { 128 | D_00_6B_N, 129 | D_00_6B_P, 130 | D_01_6B_N, 131 | D_01_6B_P, 132 | D_02_6B_N, 133 | D_02_6B_P, 134 | D_03_6B, 135 | D_04_6B_N, 136 | D_04_6B_P, 137 | D_05_6B, 138 | D_06_6B, 139 | D_07_6B_N, 140 | D_07_6B_P, 141 | D_08_6B_N, 142 | D_08_6B_P, 143 | D_09_6B, 144 | D_10_6B, 145 | D_11_6B, 146 | D_12_6B, 147 | D_13_6B, 148 | D_14_6B, 149 | D_15_6B_N, 150 | D_15_6B_P, 151 | D_16_6B_N, 152 | D_16_6B_P, 153 | D_17_6B, 154 | D_18_6B, 155 | D_19_6B, 156 | D_20_6B, 157 | D_21_6B, 158 | D_22_6B, 159 | D_23_6B_N, 160 | D_23_6B_P, 161 | D_24_6B_N, 162 | D_24_6B_P, 163 | D_25_6B, 164 | D_26_6B, 165 | D_27_6B_N, 166 | D_27_6B_P, 167 | D_28_6B, 168 | D_29_6B_N, 169 | D_29_6B_P, 170 | D_30_6B_N, 171 | D_30_6B_P, 172 | D_31_6B_N, 173 | D_31_6B_P, 174 | K_28_6B_N, 175 | K_28_6B_P}; 176 | illegal_bins all_other = default; 177 | } 178 | 179 | // Cover the 4bit code group 180 | symbol_4b : coverpoint m_symbol_10b[3:0] { 181 | bins symbol_4b[] = { 182 | D_X_0_4B_N, 183 | D_X_0_4B_P, 184 | D_X_1_4B, 185 | D_X_2_4B, 186 | D_X_3_4B_N, 187 | D_X_3_4B_P, 188 | D_X_4_4B_N, 189 | D_X_4_4B_P, 190 | D_X_5_4B, 191 | D_X_6_4B, 192 | D_X_P7_4B_N, 193 | D_X_P7_4B_P, 194 | D_X_A7_4B_N, 195 | D_X_A7_4B_P}; 196 | illegal_bins all_other = default; 197 | } 198 | 199 | // Cover the 6bit code group crossed with the 4bit code group 200 | crs_6b_x_4b : cross symbol_6b, symbol_4b { 201 | ignore_bins all_other = (binsof (symbol_6b) intersect { 202 | D_07_6B_N, 203 | D_00_6B_P, 204 | D_01_6B_P, 205 | D_02_6B_P, 206 | D_04_6B_P, 207 | D_08_6B_P, 208 | D_15_6B_P, 209 | D_16_6B_P, 210 | D_23_6B_P, 211 | D_24_6B_P, 212 | D_27_6B_P, 213 | D_29_6B_P, 214 | D_30_6B_P, 215 | D_31_6B_P, 216 | K_28_6B_P 217 | } && !binsof (symbol_4b) intersect { 218 | D_X_0_4B_N, 219 | D_X_1_4B, 220 | D_X_2_4B, 221 | D_X_3_4B_N, 222 | D_X_4_4B_N, 223 | D_X_5_4B, 224 | D_X_6_4B, 225 | D_X_P7_4B_N, 226 | D_X_A7_4B_N}) || 227 | (binsof (symbol_6b) intersect { 228 | D_07_6B_P, 229 | D_00_6B_N, 230 | D_01_6B_N, 231 | D_02_6B_N, 232 | D_04_6B_N, 233 | D_08_6B_N, 234 | D_15_6B_N, 235 | D_16_6B_N, 236 | D_23_6B_N, 237 | D_24_6B_N, 238 | D_27_6B_N, 239 | D_29_6B_N, 240 | D_30_6B_N, 241 | D_31_6B_N, 242 | K_28_6B_N 243 | } && 244 | !binsof (symbol_4b) intersect { 245 | D_X_0_4B_P, 246 | D_X_1_4B, 247 | D_X_2_4B, 248 | D_X_3_4B_P, 249 | D_X_4_4B_P, 250 | D_X_5_4B, 251 | D_X_6_4B, 252 | D_X_P7_4B_P, 253 | D_X_A7_4B_P 254 | }) || 255 | (binsof (symbol_6b) intersect {D_17_6B, D_18_6B, D_20_6B} && 256 | binsof (symbol_4b) intersect {D_X_A7_4B_P, D_X_P7_4B_N, D_X_P7_4B_P}) || 257 | (binsof (symbol_6b) intersect {D_11_6B, D_13_6B, D_14_6B} && 258 | binsof (symbol_4b) intersect {D_X_A7_4B_N, D_X_P7_4B_N, D_X_P7_4B_P}) || 259 | (!binsof (symbol_6b) intersect {D_17_6B, D_18_6B, D_20_6B} && 260 | binsof (symbol_4b) intersect {D_X_A7_4B_N}) || 261 | (!binsof (symbol_6b) intersect {D_11_6B, D_13_6B, D_14_6B} && 262 | binsof (symbol_4b) intersect {D_X_A7_4B_P}) || 263 | (binsof (symbol_6b) intersect { 264 | K_28_6B_N, 265 | K_28_6B_P, 266 | K_23_6B_N, 267 | K_23_6B_P, 268 | K_27_6B_N, 269 | K_27_6B_P, 270 | K_29_6B_N, 271 | K_29_6B_P, 272 | K_30_6B_N, 273 | K_30_6B_P} && 274 | !binsof (symbol_4b) intersect { 275 | K_X_0_4B_N, 276 | K_X_1_4B_N, 277 | K_X_2_4B_N, 278 | K_X_3_4B_N, 279 | K_X_4_4B_N, 280 | K_X_5_4B_N, 281 | K_X_6_4B_N, 282 | K_X_7_4B_N, 283 | K_X_0_4B_P, 284 | K_X_1_4B_P, 285 | K_X_2_4B_P, 286 | K_X_3_4B_P, 287 | K_X_4_4B_P, 288 | K_X_5_4B_P, 289 | K_X_6_4B_P, 290 | K_X_7_4B_P}); 291 | } 292 | 293 | prev_symbol_4b : coverpoint m_prev_symbol_4b { 294 | option.weight = 0; 295 | ignore_bins ignore_initial_value = {0}; 296 | ignore_bins ignore_F_value = {15}; 297 | } 298 | 299 | // Cover previous 4bit code group crossed with new 6bit code group 300 | crs_prev_4b_x_6b : cross prev_symbol_4b, symbol_6b { 301 | ignore_bins all_other = (binsof (prev_symbol_4b) intersect { 302 | D_X_0_4B_P, 303 | D_X_3_4B_N, 304 | D_X_4_4B_P, 305 | D_X_P7_4B_P, 306 | D_X_A7_4B_P 307 | } && !binsof (symbol_6b) intersect { 308 | D_03_6B, 309 | D_05_6B, 310 | D_06_6B, 311 | D_09_6B, 312 | D_10_6B, 313 | D_11_6B, 314 | D_12_6B, 315 | D_13_6B, 316 | D_14_6B, 317 | D_17_6B, 318 | D_18_6B, 319 | D_19_6B, 320 | D_20_6B, 321 | D_21_6B, 322 | D_22_6B, 323 | D_25_6B, 324 | D_26_6B, 325 | D_28_6B, 326 | D_07_6B_N, 327 | D_00_6B_N, 328 | D_01_6B_N, 329 | D_02_6B_N, 330 | D_04_6B_N, 331 | D_08_6B_N, 332 | D_15_6B_N, 333 | D_16_6B_N, 334 | D_23_6B_N, 335 | D_24_6B_N, 336 | D_27_6B_N, 337 | D_29_6B_N, 338 | D_30_6B_N, 339 | D_31_6B_N, 340 | K_28_6B_N 341 | }) || 342 | (binsof (prev_symbol_4b) intersect { 343 | D_X_0_4B_N, 344 | D_X_3_4B_P, 345 | D_X_4_4B_N, 346 | D_X_P7_4B_N, 347 | D_X_A7_4B_N 348 | } && !binsof (symbol_6b) intersect { 349 | D_03_6B, 350 | D_05_6B, 351 | D_06_6B, 352 | D_09_6B, 353 | D_10_6B, 354 | D_11_6B, 355 | D_12_6B, 356 | D_13_6B, 357 | D_14_6B, 358 | D_17_6B, 359 | D_18_6B, 360 | D_19_6B, 361 | D_20_6B, 362 | D_21_6B, 363 | D_22_6B, 364 | D_25_6B, 365 | D_26_6B, 366 | D_28_6B, 367 | D_07_6B_P, 368 | D_00_6B_P, 369 | D_01_6B_P, 370 | D_02_6B_P, 371 | D_04_6B_P, 372 | D_08_6B_P, 373 | D_15_6B_P, 374 | D_16_6B_P, 375 | D_23_6B_P, 376 | D_24_6B_P, 377 | D_27_6B_P, 378 | D_29_6B_P, 379 | D_30_6B_P, 380 | D_31_6B_P, 381 | K_28_6B_P 382 | }); 383 | } 384 | endgroup 385 | 386 | /* Constructor 387 | * @param name : name for this component instance 388 | * @param parent : parent for this component 389 | */ 390 | function new(input string name, input uvm_component parent); 391 | super.new(name, parent); 392 | 393 | m_cov_data_ap = new("m_cov_data_ap", this); 394 | 395 | symbol_8b_cov = new(); 396 | symbol_10b_cov = new(); 397 | // set initial values 398 | m_running_disp = -1; 399 | m_prev_symbol_4b = 4'b0; 400 | 401 | endfunction 402 | 403 | 404 | /* Overwrite function to collect the coverage for 8 bit item 405 | * @param a_cov_data : coverage item sent for coverage collection 406 | */ 407 | virtual function void write(input endec_8b10b_cov_data a_cov_data); 408 | m_symbol_10b = a_cov_data.m_encoded_symb; 409 | m_symbol_8b = a_cov_data.m_data; 410 | m_is_k_symbol = a_cov_data.m_is_k_symbol; 411 | 412 | 413 | m_running_disp = a_cov_data.m_post_disp; 414 | 415 | // call sample() functions 416 | symbol_8b_cov.sample(); 417 | symbol_10b_cov.sample(); 418 | 419 | m_prev_symbol_4b = m_symbol_10b[3:0]; 420 | endfunction 421 | //-------------- 422 | 423 | endclass 424 | 425 | `endif//ENDEC_8b10b_COVERAGE_SVH -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_8b10b/endec_8b10b_defines.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_defines.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains defines used by endec_8b10b package 21 | *****************************************************************************/ 22 | 23 | `ifndef ENDEC_8b10b_DEFINES_SVH 24 | `define ENDEC_8b10b_DEFINES_SVH 25 | 26 | //add defines if any are needed 27 | 28 | //Defines beneath are not to be changed 29 | 30 | //each bit holds information for 5b6b encoded values from 0 to 31 31 | //if bit is 1 means the corresponding value has two 32 | //encodings, one for each running disparity 33 | //zero means single, neutral encoding 34 | `define ENDEC_5B6B_SYMBOL_HAS_DOUBLE_ENCODING 32'b11101001100000011000000110010111 35 | 36 | //each bit holds information for 3b4b encoded values from 0 to 7, the additional bit is for 37 | //value 7 which has two different encodings(primary and alternative) 38 | //if bit is 1 means the corresponding value has two 39 | //encodings, one for each running disparity 40 | //zero means single, neutral encoding 41 | `define ENDEC_3B4B_SYMBOL_HAS_DOUBLE_ENCODING 9'b110011001 42 | 43 | 44 | `endif//ENDEC_8b10b_DEFINES_SVH 45 | -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_8b10b/endec_8b10b_mappings.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_mappings.sv 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: File containing the class implementing the mappings between 21 | * uncoded symbols and disparity and their coded equivalents 22 | *****************************************************************************/ 23 | 24 | 25 | `ifndef ENDEC_8b10b_MAPPINGS_SVH 26 | `define ENDEC_8b10b_MAPPINGS_SVH 27 | 28 | /* Decoder driver 29 | */ 30 | class endec_8b10b_mappings extends uvm_object; 31 | `uvm_object_utils(endec_8b10b_mappings) 32 | 33 | // 34 | // maps 5b6b symbols to the corresponding uncoded data bits and disparity of the symbol 35 | // the 2 MSBs hold the disparity and the 5 LSBs hold the uncoded bits 36 | // disparity(of coded word) is represented like this: -2->0, 0->1, 2->2 37 | bit[6:0] m_map_from_5b6b [endec_8b10b_d_6b_e]; 38 | // maps uncoded data bits and disparity of the symbol to the corresponding 5b6b symbol 39 | // the 2 MSBs hold the running disparity and the 5 LSBs hold the uncoded bits 40 | // running disparity is represented like this: -1->0, 1->1 41 | endec_8b10b_d_6b_e m_map_to_5b6b [bit[6:0]]; 42 | 43 | /* Function that builds a mapping between a 5b6b encoded word and 44 | * it's un-coded counterpart together with it's disparity 45 | */ 46 | virtual function void build_from_5b6b_map (); 47 | endec_8b10b_d_6b_e code_word_6b = code_word_6b.first(); 48 | bit[6:0] map_entry; 49 | int symb_vector_5b6b = `ENDEC_5B6B_SYMBOL_HAS_DOUBLE_ENCODING; 50 | //disparity possible values are: -2, 0, 2 51 | for (int iter = 0; iter < 32; iter++) begin 52 | if (symb_vector_5b6b[iter] == 1) begin 53 | //for disparity '2' use value '2' 54 | map_entry = (2<<5) + iter; 55 | m_map_from_5b6b[code_word_6b] = map_entry; 56 | code_word_6b = code_word_6b.next(); 57 | //for '-2' disparity use value '0' 58 | map_entry = iter; 59 | m_map_from_5b6b[code_word_6b] = map_entry; 60 | end else begin 61 | //for disparity '0' use value '1' 62 | map_entry = (1<<5) + iter; 63 | m_map_from_5b6b[code_word_6b] = map_entry; 64 | end 65 | code_word_6b = code_word_6b.next(); 66 | end 67 | endfunction 68 | 69 | /* Function that builds the mapping in the direction opposite to 70 | * the one above 71 | */ 72 | virtual function void build_to_5b6b_map (); 73 | //map all 32 values for each disparity 74 | endec_8b10b_d_6b_e code_word_6b = code_word_6b.first(); 75 | bit[6:0] map_key; 76 | int symb_vector_5b6b = `ENDEC_5B6B_SYMBOL_HAS_DOUBLE_ENCODING; 77 | 78 | for (int iter = 0; iter <= 31; iter++) begin 79 | //add for negative disparity, use value '0' for running disparity '-1' 80 | map_key = iter; 81 | m_map_to_5b6b[map_key] = code_word_6b; 82 | //add for positive disparity, use value '1' for running disparity '-1' 83 | if (symb_vector_5b6b[iter] == 1) begin 84 | code_word_6b = code_word_6b.next(); 85 | end 86 | map_key = (1<<5) + iter; 87 | m_map_to_5b6b[map_key] = code_word_6b; 88 | code_word_6b = code_word_6b.next(); 89 | end 90 | endfunction 91 | 92 | // maps 3b4b symbols to the corresponding uncoded data bits and disparity of the symbol 93 | // the 2 MSBs hold the disparity and the 4 LSBs hold the uncoded bits 94 | // disparity(of coded word) is represented like this: -2->0, 0->1, 2->2 95 | bit[5:0] m_map_from_3b4b [endec_8b10b_d_4b_e]; 96 | // maps uncoded data bits and disparity of the symbol to the corresponding 3b4b symbol 97 | // the 2 MSBs hold the running disparity and the 4 LSBs hold the uncoded bits 98 | // running disparity is represented like this: -1->0, 1->1 99 | endec_8b10b_d_4b_e m_map_to_3b4b [bit[5:0]]; 100 | 101 | /* Function that builds a mapping between a 3b4b encoded word and 102 | * it's un-coded counterpart together with it's disparity 103 | * use extra data value '8' for alternative coding of data value '7' 104 | */ 105 | virtual function void build_from_3b4b_map (); 106 | endec_8b10b_d_4b_e code_word_4b = code_word_4b.first(); 107 | bit[5:0] map_entry; 108 | int symb_vector_3b4b = `ENDEC_3B4B_SYMBOL_HAS_DOUBLE_ENCODING; 109 | 110 | for (int iter = 0; iter <= 8; iter++) begin 111 | if (symb_vector_3b4b[iter] == 1) begin 112 | map_entry = (2<<4) + iter;//symbol disparity is 2 113 | m_map_from_3b4b[code_word_4b] = map_entry; 114 | code_word_4b = code_word_4b.next(); 115 | map_entry = iter;//symbol disparity is -2, use value '0' to represent 116 | m_map_from_3b4b[code_word_4b] = map_entry; 117 | end else begin 118 | map_entry = (1<<4) + iter;//symbol disparity is 0 119 | m_map_from_3b4b[code_word_4b] = map_entry; 120 | end 121 | code_word_4b = code_word_4b.next(); 122 | end 123 | endfunction 124 | 125 | /* Function that builds the mapping in the direction opposite to 126 | * the one above 127 | */ 128 | virtual function void build_to_3b4b_map (); 129 | endec_8b10b_d_4b_e code_word_4b = code_word_4b.first(); 130 | bit[5:0] map_key; 131 | int symb_vector_3b4b = `ENDEC_3B4B_SYMBOL_HAS_DOUBLE_ENCODING; 132 | 133 | for (int iter = 0; iter <= 8; iter++) begin 134 | //add for negative disparity(use value '0' for the array entry) 135 | map_key = iter; 136 | m_map_to_3b4b[map_key] = code_word_4b; 137 | //add for positive disparity(use value '1' for the array entry) 138 | if (symb_vector_3b4b[iter] == 1) begin 139 | code_word_4b = code_word_4b.next(); 140 | end 141 | map_key = (1<<4) + iter; 142 | m_map_to_3b4b[map_key] = code_word_4b; 143 | code_word_4b = code_word_4b.next(); 144 | end 145 | endfunction 146 | 147 | // maps 5b6b coded word of the control symbols to the corresponding uncoded data bits and disparity value of the 148 | // symbol the 2 MSBs hold the disparity value of the coded symbol and the 5 LSBs hold the uncoded bits 149 | // disparity(of coded word) is represented like this: -2->0, 0->1, 2->2 150 | bit[6:0] m_map_from_k_6b[endec_8b10b_k_6b_e]; 151 | // maps uncoded data bits and disparity of the coded control symbol to the corresponding 5b6b symbol 152 | // the 2 MSBs hold the running disparity and the 5 LSBs hold the uncoded bits 153 | // running disparity is represented like this: -1->0, 1->1 154 | endec_8b10b_k_6b_e m_map_to_k_6b[bit[6:0]]; 155 | 156 | /* Function that builds a mapping between a 5b6b encoded word, 157 | * part of the control symbols, and it's un-coded counterpart 158 | * together with it's disparity 159 | */ 160 | virtual function void build_from_k_6b_map (); 161 | endec_8b10b_k_6b_e k_word_6b = k_word_6b.first(); 162 | bit[6:0] map_entry; 163 | //values that are encoded 164 | bit [4:0] coded_values [5] = '{28, 23, 27, 29, 30}; 165 | 166 | for (int iter = 0;iter < k_word_6b.num(); iter++) begin 167 | int sel_coded_val = iter/2; 168 | //disparity representation 2->2, -2->0 169 | bit[1:0] disparity = ((iter%2) == 0) ? 2 : 0; 170 | map_entry = (disparity<<5) + coded_values[sel_coded_val]; 171 | m_map_from_k_6b[k_word_6b] = map_entry; 172 | k_word_6b = k_word_6b.next(); 173 | end 174 | endfunction 175 | 176 | /* Function that builds the mapping in the direction opposite to 177 | * the one above 178 | */ 179 | virtual function void build_to_k_6b_map (); 180 | endec_8b10b_k_6b_e k_word_6b = k_word_6b.first(); 181 | bit[6:0] map_key; 182 | //values that are encoded 183 | bit [4:0] coded_values [5] = '{28, 23, 27, 29, 30}; 184 | 185 | for (int iter = 0;iter < k_word_6b.num(); iter++) begin 186 | int sel_coded_val = iter/2; 187 | //running disparity representation -1->0, 1->1 188 | bit disparity = ((iter%2) == 0) ? 0 : 1; 189 | map_key = (disparity<<5) + coded_values[sel_coded_val]; 190 | m_map_to_k_6b[map_key] = k_word_6b; 191 | k_word_6b = k_word_6b.next(); 192 | end 193 | endfunction 194 | 195 | // maps 3b4b coded word(for negative running disparity) of the control symbols to the corresponding uncoded data 196 | // bits and disparity value of the symbol the 2 MSBs hold the disparity value of the coded symbol and the 5 LSBs 197 | // hold the uncoded bits disparity(of coded word) is represented like this: -2->0, 0->1, 2->2 198 | bit[5:0] m_map_from_k_4b_n[endec_8b10b_k_4b_n_e]; 199 | // maps uncoded data bits and disparity of the coded control symbol to the corresponding 5b6b symbol 200 | // the 2 MSBs hold the running disparity and the 5 LSBs hold the uncoded bits 201 | // running disparity is represented like this: -1->0, 1->1 202 | endec_8b10b_k_4b_n_e m_map_to_k_4b_n[bit[5:0]]; 203 | 204 | /* Function that builds a mapping between a 5b6b encoded word, part 205 | * of the control symbols, and it's un-coded counterpart together with 206 | * it's disparity 207 | */ 208 | virtual function void build_from_k_4b_n_map (); 209 | endec_8b10b_k_4b_n_e k_word_4b = k_word_4b.first(); 210 | bit[5:0] map_entry; 211 | 212 | for (int iter = 0;iter < k_word_4b.num(); iter++) begin 213 | // disparity is '2' in the cases below 214 | if (iter inside {0, 4, 7}) begin 215 | map_entry = (2<<4) + iter; 216 | end 217 | else begin 218 | map_entry = (1<<4) + iter;//symbol disparity is 0 219 | end 220 | m_map_from_k_4b_n[k_word_4b] = map_entry; 221 | 222 | k_word_4b = k_word_4b.next(); 223 | end 224 | endfunction 225 | 226 | /* Function that builds the mapping in the direction opposite to 227 | * the one above 228 | */ 229 | virtual function void build_to_k_4b_n_map (); 230 | endec_8b10b_k_4b_n_e k_word_4b = k_word_4b.first(); 231 | bit[5:0] map_key; 232 | 233 | for (int iter = 0; iter <= 7; iter++) begin 234 | //add for negative disparity(use value '0' for the array entry) 235 | //for this map we always have negative running disparity 236 | map_key = iter; 237 | m_map_to_k_4b_n[map_key] = k_word_4b; 238 | k_word_4b = k_word_4b.next(); 239 | end 240 | endfunction 241 | 242 | // maps 3b4b coded word(for positive running disparity) of the control symbols to the corresponding uncoded data 243 | // bits and disparity value of the symbol the 2 MSBs hold the disparity value of the coded symbol and the 5 LSBs 244 | // hold the uncoded bits disparity(of coded word) is represented like this: -2->0, 0->1, 2->2 245 | bit[5:0] m_map_from_k_4b_p[endec_8b10b_k_4b_p_e]; 246 | // maps uncoded data bits and disparity of the coded control symbol to the corresponding 5b6b symbol 247 | // the 2 MSBs hold the running disparity and the 5 LSBs hold the uncoded bits 248 | // running disparity is represented like this: -1->0, 1->1 249 | endec_8b10b_k_4b_p_e m_map_to_k_4b_p[bit[5:0]]; 250 | 251 | /* Function that builds a mapping between a 3b4b encoded word,part of 252 | * the control symbols, and it's un-coded counterpart together with 253 | * it's disparity 254 | */ 255 | virtual function void build_from_k_4b_p_map (); 256 | endec_8b10b_k_4b_p_e k_word_4b = k_word_4b.first(); 257 | bit[5:0] map_entry; 258 | 259 | for (int iter = 0;iter < k_word_4b.num(); iter++) begin 260 | // disparity is '-2' in the cases below 261 | if (iter inside {0, 4, 7}) begin 262 | map_entry = iter; 263 | end 264 | else begin 265 | map_entry = (1<<4) + iter;//symbol disparity is 0 266 | end 267 | m_map_from_k_4b_p[k_word_4b] = map_entry; 268 | 269 | k_word_4b = k_word_4b.next(); 270 | end 271 | endfunction 272 | 273 | /* Function that builds the mapping in the direction opposite to 274 | * the one above 275 | */ 276 | virtual function void build_to_k_4b_p_map (); 277 | endec_8b10b_k_4b_p_e k_word_4b = k_word_4b.first(); 278 | bit[5:0] map_key; 279 | 280 | for (int iter = 0; iter <= 7; iter++) begin 281 | //add for positive disparity(use value '1' for the array entry) 282 | //for this map we always have positive running disparity 283 | map_key = (1<<4) + iter; 284 | m_map_to_k_4b_p[map_key] = k_word_4b; 285 | k_word_4b = k_word_4b.next(); 286 | end 287 | endfunction 288 | 289 | 290 | /*constructor 291 | * @param name - name of the component instance 292 | */ 293 | function new (input string name = "endec_8b10b_mappings"); 294 | super.new(name); 295 | //build maps for 5b6b data symbols 296 | build_from_5b6b_map(); 297 | build_to_5b6b_map(); 298 | //build maps for 3b4b data symbols 299 | build_from_3b4b_map(); 300 | build_to_3b4b_map(); 301 | //build maps for 6b control symbols 302 | build_from_k_6b_map(); 303 | build_to_k_6b_map(); 304 | //build maps for 4b control symbols 305 | build_from_k_4b_n_map(); 306 | build_to_k_4b_n_map(); 307 | build_from_k_4b_p_map(); 308 | build_to_k_4b_p_map(); 309 | endfunction 310 | 311 | endclass 312 | 313 | `endif//ENDEC_8b10b_MAPPINGS_SVH -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_8b10b/endec_8b10b_pkg.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_pkg.sv 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: Package containing the implementation of endec_8b10b 21 | * encoder/decoder 22 | *****************************************************************************/ 23 | 24 | `ifndef ENDEC_8b10b_PKG_SV 25 | `define ENDEC_8b10b_PKG_SV 26 | 27 | package endec_8b10b_pkg; 28 | 29 | import uvm_pkg::*; 30 | `include "uvm_macros.svh" 31 | 32 | `include "endec_8b10b_defines.svh" 33 | `include "endec_8b10b_types.svh" 34 | 35 | `include "endec_8b10b_cov_item.svh" 36 | `include "endec_8b10b_coverage.svh" 37 | 38 | `include "endec_8b10b_mappings.svh" 39 | `include "endec_8b10b_encoder.svh" 40 | `include "endec_8b10b_decoder.svh" 41 | 42 | endpackage 43 | 44 | `endif//ENDEC_8b10b_PKG_SV -------------------------------------------------------------------------------- /encoder_decoder/sv/endec_8b10b/endec_8b10b_types.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_8b10b_types.svh 17 | * PROJECT: endec_8b10b 18 | * 19 | * 20 | * Description: This file contains type declarations for 21 | * the endec_8b10b package 22 | *****************************************************************************/ 23 | 24 | `ifndef ENDEC_8b10b_TYPES_SVH 25 | `define ENDEC_8b10b_TYPES_SVH 26 | 27 | //serves as input of the encoder and output of the decoder 28 | typedef struct { 29 | // 8 bit value input for encoding 30 | // or output of decoding 31 | bit [7:0] enc_dec_8b_val; 32 | // field indicating if it's data or control symbol 33 | bit is_k_symbol; 34 | //used to register decoding errors 35 | // 0 - no error 36 | // 1 - disparity error 37 | // 2 - symbol error 38 | bit [1:0] decode_err; 39 | } endec_8b10b_enc_in_dec_out_s; 40 | 41 | //typedef for the special symbols involved in this coding/decoding method 42 | //in 8bit representation 43 | typedef enum bit[7:0] { 44 | K_28_0_8B = 8'h1C, 45 | K_28_1_8B = 8'h3C, 46 | K_28_2_8B = 8'h5C, 47 | K_28_3_8B = 8'h7C, 48 | K_28_4_8B = 8'h9C, 49 | K_28_5_8B = 8'hBC, 50 | K_28_6_8B = 8'hDC, 51 | K_28_7_8B = 8'hFC, 52 | K_23_7_8B = 8'hF7, 53 | K_27_7_8B = 8'hFB, 54 | K_29_7_8B = 8'hFD, 55 | K_30_7_8B = 8'hFE 56 | } endec_8b10b_k_8b_e; 57 | 58 | //6bit encoded representation of the 5msb bits of the 8bit input data (control symbols) 59 | typedef enum bit[5:0] { 60 | K_28_6B_N = 6'b00_1111, 61 | K_28_6B_P = 6'b11_0000, 62 | K_23_6B_N = 6'b11_1010, 63 | K_23_6B_P = 6'b00_0101, 64 | K_27_6B_N = 6'b11_0110, 65 | K_27_6B_P = 6'b00_1001, 66 | K_29_6B_N = 6'b10_1110, 67 | K_29_6B_P = 6'b01_0001, 68 | K_30_6B_N = 6'b01_1110, 69 | K_30_6B_P = 6'b10_0001 70 | } endec_8b10b_k_6b_e; 71 | 72 | //4bit encoded representation of the 3 msb bits of 8bit input data (control symbols) 73 | //these are used if current value of running disparity is negative 74 | typedef enum bit[3:0] { 75 | K_X_0_4B_N = 4'b1011, 76 | K_X_1_4B_N = 4'b0110, 77 | K_X_2_4B_N = 4'b1010, 78 | K_X_3_4B_N = 4'b1100, 79 | K_X_4_4B_N = 4'b1101, 80 | K_X_5_4B_N = 4'b0101, 81 | K_X_6_4B_N = 4'b1001, 82 | K_X_7_4B_N = 4'b0111 83 | } endec_8b10b_k_4b_n_e; 84 | 85 | //4bit encoded representation of the 3 msb bits of 8bit input data (control symbols) 86 | //these are used if current value of running disparity is positive 87 | typedef enum bit[3:0] { 88 | K_X_0_4B_P = 4'b0100, 89 | K_X_1_4B_P = 4'b1001, 90 | K_X_2_4B_P = 4'b0101, 91 | K_X_3_4B_P = 4'b0011, 92 | K_X_4_4B_P = 4'b0010, 93 | K_X_5_4B_P = 4'b1010, 94 | K_X_6_4B_P = 4'b0110, 95 | K_X_7_4B_P = 4'b1000 96 | } endec_8b10b_k_4b_p_e; 97 | 98 | //10bit encoded representation of control symbols 99 | typedef enum bit[9:0] { 100 | K_28_0_10B_N = 10'b00_1111_0100, 101 | K_28_0_10B_P = 10'b11_0000_1011, 102 | K_28_1_10B_N = 10'b00_1111_1001, 103 | K_28_1_10B_P = 10'b11_0000_0110, 104 | K_28_2_10B_N = 10'b00_1111_0101, 105 | K_28_2_10B_P = 10'b11_0000_1010, 106 | K_28_3_10B_N = 10'b00_1111_0011, 107 | K_28_3_10B_P = 10'b11_0000_1100, 108 | K_28_4_10B_N = 10'b00_1111_0010, 109 | K_28_4_10B_P = 10'b11_0000_1101, 110 | K_28_5_10B_N = 10'b00_1111_1010, 111 | K_28_5_10B_P = 10'b11_0000_0101, 112 | K_28_6_10B_N = 10'b00_1111_0110, 113 | K_28_6_10B_P = 10'b11_0000_1001, 114 | K_28_7_10B_N = 10'b00_1111_1000, 115 | K_28_7_10B_P = 10'b11_0000_0111, 116 | K_23_7_10B_N = 10'b11_1010_1000, 117 | K_23_7_10B_P = 10'b00_0101_0111, 118 | K_27_7_10B_N = 10'b11_0110_1000, 119 | K_27_7_10B_P = 10'b00_1001_0111, 120 | K_29_7_10B_N = 10'b10_1110_1000, 121 | K_29_7_10B_P = 10'b01_0001_0111, 122 | K_30_7_10B_N = 10'b01_1110_1000, 123 | K_30_7_10B_P = 10'b10_0001_0111 124 | } endec_8b10b_k_10b_e; 125 | 126 | //6bit encoded representation of the 5 lsb bits of 8bit input data 127 | typedef enum bit[5:0] { 128 | D_00_6B_N = 6'b10_0111, 129 | D_00_6B_P = 6'b01_1000, 130 | D_01_6B_N = 6'b01_1101, 131 | D_01_6B_P = 6'b10_0010, 132 | D_02_6B_N = 6'b10_1101, 133 | D_02_6B_P = 6'b01_0010, 134 | D_03_6B = 6'b11_0001, 135 | D_04_6B_N = 6'b11_0101, 136 | D_04_6B_P = 6'b00_1010, 137 | D_05_6B = 6'b10_1001, 138 | D_06_6B = 6'b01_1001, 139 | D_07_6B_N = 6'b11_1000, 140 | D_07_6B_P = 6'b00_0111, 141 | D_08_6B_N = 6'b11_1001, 142 | D_08_6B_P = 6'b00_0110, 143 | D_09_6B = 6'b10_0101, 144 | D_10_6B = 6'b01_0101, 145 | D_11_6B = 6'b11_0100, 146 | D_12_6B = 6'b00_1101, 147 | D_13_6B = 6'b10_1100, 148 | D_14_6B = 6'b01_1100, 149 | D_15_6B_N = 6'b01_0111, 150 | D_15_6B_P = 6'b10_1000, 151 | D_16_6B_N = 6'b01_1011, 152 | D_16_6B_P = 6'b10_0100, 153 | D_17_6B = 6'b10_0011, 154 | D_18_6B = 6'b01_0011, 155 | D_19_6B = 6'b11_0010, 156 | D_20_6B = 6'b00_1011, 157 | D_21_6B = 6'b10_1010, 158 | D_22_6B = 6'b01_1010, 159 | D_23_6B_N = 6'b11_1010, 160 | D_23_6B_P = 6'b00_0101, 161 | D_24_6B_N = 6'b11_0011, 162 | D_24_6B_P = 6'b00_1100, 163 | D_25_6B = 6'b10_0110, 164 | D_26_6B = 6'b01_0110, 165 | D_27_6B_N = 6'b11_0110, 166 | D_27_6B_P = 6'b00_1001, 167 | D_28_6B = 6'b00_1110, 168 | D_29_6B_N = 6'b10_1110, 169 | D_29_6B_P = 6'b01_0001, 170 | D_30_6B_N = 6'b01_1110, 171 | D_30_6B_P = 6'b10_0001, 172 | D_31_6B_N = 6'b10_1011, 173 | D_31_6B_P = 6'b01_0100 174 | } endec_8b10b_d_6b_e; 175 | 176 | //4bit encoded representation of the 3 msb bits of 8bit input data 177 | typedef enum bit[3:0] { 178 | D_X_0_4B_N = 4'b1011, 179 | D_X_0_4B_P = 4'b0100, 180 | D_X_1_4B = 4'b1001, 181 | D_X_2_4B = 4'b0101, 182 | D_X_3_4B_N = 4'b1100, 183 | D_X_3_4B_P = 4'b0011, 184 | D_X_4_4B_N = 4'b1101, 185 | D_X_4_4B_P = 4'b0010, 186 | D_X_5_4B = 4'b1010, 187 | D_X_6_4B = 4'b0110, 188 | D_X_P7_4B_N = 4'b1110, 189 | D_X_P7_4B_P = 4'b0001, 190 | D_X_A7_4B_N = 4'b0111, 191 | D_X_A7_4B_P = 4'b1000 192 | } endec_8b10b_d_4b_e; 193 | 194 | `endif//ENDEC_8b10b_TYPES_SVH -------------------------------------------------------------------------------- /examples/coding_and_scrambling/scripts/options_ius.f: -------------------------------------------------------------------------------- 1 | +incdir+${PROJECT_DIR}/sv/ 2 | +incdir+${PROJECT_DIR}/encoder_decoder/sv/endec_64b66b/ 3 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ 4 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ve 5 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/tests 6 | +incdir+${PROJECT_DIR}/scrambler_descrambler/sv/ 7 | 8 | +incdir+${EXAMPLE_DIR}/ 9 | +incdir+${EXAMPLE_DIR}/sv 10 | +incdir+${EXAMPLE_DIR}/tests 11 | 12 | -linedebug 13 | -uvmlinedebug 14 | +uvm_set_action="*,_ALL_,UVM_ERROR,UVM_DISPLAY|UVM_STOP" 15 | -uvm 16 | -access rw 17 | -sv 18 | -covoverwrite 19 | -coverage all 20 | +UVM_NO_RELNOTES 21 | -DSC_INCLUDE_DYNAMIC_PROCESSES 22 | +define+UVM_OBJECT_MUST_HAVE_CONSTRUCTOR 23 | -timescale 1ns/1ps 24 | 25 | ${PROJECT_DIR}/encoder_decoder/sv/endec_64b66b/endec_64b66b_pkg.sv 26 | ${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_pkg.sv 27 | ${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/tests/endec_64b66b_tests_pkg.sv 28 | ${PROJECT_DIR}/scrambler_descrambler/sv/scrambler_descrambler_pkg.sv 29 | 30 | ${TOP_FILE_PATH} 31 | -------------------------------------------------------------------------------- /examples/coding_and_scrambling/scripts/options_vcs.f: -------------------------------------------------------------------------------- 1 | -sverilog 2 | 3 | +incdir+${PROJECT_DIR}/encoder_decoder/sv/endec_64b66b/ 4 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ 5 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ve 6 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/tests 7 | +incdir+${PROJECT_DIR}/scrambler_descrambler/sv/ 8 | 9 | 10 | +incdir+${EXAMPLE_DIR}/ 11 | +incdir+${EXAMPLE_DIR}/sv 12 | +incdir+${EXAMPLE_DIR}/tests 13 | 14 | ${PROJECT_DIR}/encoder_decoder/sv/endec_64b66b/endec_64b66b_pkg.sv 15 | ${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_pkg.sv 16 | ${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/tests/endec_64b66b_tests_pkg.sv 17 | ${PROJECT_DIR}/scrambler_descrambler/sv/scrambler_descrambler_pkg.sv 18 | ${TOP_FILE_PATH} 19 | -top ${TOP_MODULE_NAME} 20 | -timescale=1ns/1ps -------------------------------------------------------------------------------- /examples/coding_and_scrambling/scripts/options_vlog.f: -------------------------------------------------------------------------------- 1 | +incdir+${PROJECT_DIR}/encoder_decoder/sv/endec_64b66b/ 2 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ 3 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ve 4 | +incdir+${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/tests 5 | +incdir+${PROJECT_DIR}/scrambler_descrambler/sv/ 6 | 7 | 8 | +incdir+${EXAMPLE_DIR}/ 9 | +incdir+${EXAMPLE_DIR}/sv 10 | +incdir+${EXAMPLE_DIR}/tests 11 | -${ARCH_BITS} 12 | -sv 13 | ${PROJECT_DIR}/encoder_decoder/sv/endec_64b66b/endec_64b66b_pkg.sv 14 | ${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/ve/endec_64b66b_ve_pkg.sv 15 | ${PROJECT_DIR}/encoder_decoder/examples/endec_64b66b/tests/endec_64b66b_tests_pkg.sv 16 | ${PROJECT_DIR}/scrambler_descrambler/sv/scrambler_descrambler_pkg.sv 17 | ${TOP_FILE_PATH} -------------------------------------------------------------------------------- /examples/coding_and_scrambling/scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | 4 | #the default values of the user controlled options 5 | default_run_mode="batch" 6 | default_tool=ius 7 | default_seed=1; 8 | default_test="endec_64b66b_with_scrambler_test" 9 | default_quit_cnt=0 10 | default_verbosity=UVM_MEDIUM 11 | default_arch_bits=64 12 | 13 | 14 | run_mode=${default_run_mode} 15 | tool=${default_tool} 16 | seed=${default_seed} 17 | test=${default_test} 18 | quit_cnt=${default_quit_cnt} 19 | verbosity=${default_verbosity} 20 | ARCH_BITS=${default_arch_bits} 21 | 22 | export TOP_MODULE_NAME=${DUT_MODULE_NAME}_top 23 | export TOP_FILE_NAME=${TOP_MODULE_NAME}.sv 24 | export TOP_FILE_PATH=${EXAMPLE_DIR}/sv/${TOP_FILE_NAME} 25 | 26 | # give direct values to exports 27 | export PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../../ && pwd )" 28 | export EXAMPLE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../ && pwd )" 29 | 30 | echo $PROJECT_DIR 31 | echo $EXAMPLE_DIR 32 | 33 | export TOP_MODULE_NAME=coding_and_scrambling_top 34 | export TOP_FILE_NAME=coding_and_scrambling_top.sv 35 | export TOP_FILE_PATH=${EXAMPLE_DIR}/sv/${TOP_FILE_NAME} 36 | 37 | help() { 38 | echo "" 39 | echo "Possible options for this script:" 40 | echo " -i --> run in interactive mode" 41 | echo " -seed --> specify a particular seed for the simulation (default: ${default_seed})" 42 | echo " -test --> specify a particular test to run (default: ${default_test})" 43 | echo " -tool [ius|questa|vcs] --> specify what simulator to use (default: ${default_tool})" 44 | echo " -quit_cnt --> specify after how many errors should the test stop (default: ${default_quit_cnt})" 45 | echo " -verbosity {UVM_NONE|UVM_LOW|UVM_MEDIUM|UVM_HIGH|UVM_FULL|UVM_DEBUG }] --> specify the verbosity of a message (default: ${default_uvm_verbosity})" 46 | echo " -bit[32|64] --> specify what architecture to use: 32 or 64 bits (default: ${default_arch_bits} bits)" 47 | echo " -help --> print this message" 48 | echo "" 49 | } 50 | 51 | run_with_ius_test() { 52 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 53 | 54 | if [ ${ARCH_BITS} -eq 64 ]; then 55 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -64bit" 56 | fi 57 | 58 | if [ "$run_mode" = "interactive" ]; then 59 | rm -rf ncsim_cmds.tcl 60 | touch ncsim_cmds.tcl 61 | 62 | echo "database -open waves -into waves.shm -default" >> ncsim_cmds.tcl 63 | echo "probe -create ${TOP_MODULE_NAME} -depth all -tasks -functions -uvm -packed 4k -unpacked 16k -all" >> ncsim_cmds.tcluntil it sleeps metallica 64 | 65 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -gui -input ncsim_cmds.tcl " 66 | else 67 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -exit " 68 | fi 69 | 70 | irun -f ${PROJECT_DIR}/examples/coding_and_scrambling/scripts/options_ius.f -svseed ${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} +UVM_MAX_QUIT_COUNT=${quit_cnt} ${EXTRA_OPTIONS} 71 | } 72 | 73 | run_with_vcs_test() { 74 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 75 | 76 | if [ "$run_mode" = "interactive" ]; then 77 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -gui " 78 | fi 79 | 80 | if [ ${ARCH_BITS} -eq 64 ]; then 81 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -full64" 82 | fi 83 | 84 | vcs -ntb_opts uvm -f ${PROJECT_DIR}/examples/coding_and_scrambling/scripts/options_vcs.f +ntb_random_seed=${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} +UVM_MAX_QUIT_COUNT=${quit_cnt} -R ${EXTRA_OPTIONS} 85 | 86 | } 87 | 88 | run_with_questa_test() { 89 | vlib work 90 | vlog -f ${PROJECT_DIR}/examples/coding_and_scrambling/scripts/options_vlog.f 91 | 92 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 93 | 94 | if [ "$run_mode" != "interactive" ]; then 95 | rm -rf vsim_cmds.do 96 | touch vsim_cmds.do 97 | 98 | echo "run -all; exit" >> vsim_cmds.do 99 | 100 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -do vsim_cmds.do -c " 101 | fi 102 | 103 | vsim -${ARCH_BITS} -novopt ${TOP_MODULE_NAME} -sv_seed ${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} +UVM_MAX_QUIT_COUNT=${quit_cnt} ${EXTRA_OPTIONS} 104 | } 105 | 106 | while [ $# -gt 0 ]; do 107 | case `echo $1 | tr "[A-Z]" "[a-z]"` in 108 | -seed) 109 | seed=$2 110 | ;; 111 | -tool) 112 | tool=$2 113 | ;; 114 | -test) 115 | echo "STOP HERE" 116 | echo $2 117 | read -p "Should take the non-default test" user_input 118 | test=$2 119 | ;; 120 | -verbosity) 121 | verbosity=$2 122 | ;; 123 | -quit_cnt) 124 | quit_cnt=$2 125 | ;; 126 | -i) 127 | run_mode=interactive 128 | ;; 129 | -bits) 130 | ARCH_BITS=$2 131 | ;; 132 | -help) 133 | help 134 | exit 0 135 | ;; 136 | esac 137 | shift 138 | done 139 | 140 | export ARCH_BITS=${ARCH_BITS} 141 | 142 | case $tool in 143 | ius) 144 | echo "Selected tool: IUS..." 145 | ;; 146 | vcs) 147 | echo "Selected tool: VCS..." 148 | ;; 149 | questa) 150 | echo "Selected tool: Questa..." 151 | ;; 152 | *) 153 | echo "Illegal option for tool: $tool" 154 | exit 1; 155 | ;; 156 | esac 157 | 158 | 159 | sim_dir=`pwd`/sim_${test} 160 | echo "Start running ${test} test in ${sim_dir}"; 161 | rm -rf ${sim_dir}; 162 | mkdir ${sim_dir}; 163 | cd ${sim_dir}; 164 | run_with_${tool}_test 165 | -------------------------------------------------------------------------------- /examples/coding_and_scrambling/sv/coding_and_scrambling_top.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: coding_and_scrambling_top.sv 17 | * PROJECT: physical_coding_algorithms 18 | * 19 | * 20 | * Description: This file contains the top module used for starting the test 21 | *******************************************************************************/ 22 | 23 | `ifndef CODING_AND_SCRAMBLING_TOP_SV 24 | `define CODING_AND_SCRAMBLING_TOP_SV 25 | 26 | 27 | `include "uvm_macros.svh" 28 | 29 | import uvm_pkg::*; 30 | import endec_64b66b_pkg::*; 31 | import endec_64b66b_ve_pkg::*; 32 | import endec_64b66b_tests_pkg::*; 33 | import scrambler_descrambler_pkg::*; 34 | 35 | `include "endec_64b66b_driver_with_scrambler.svh" 36 | 37 | `include "endec_64b66b_with_scrambler_test.sv" 38 | 39 | module coding_and_scrambling_top; 40 | 41 | initial begin 42 | run_test(""); 43 | end 44 | 45 | endmodule 46 | 47 | `endif 48 | -------------------------------------------------------------------------------- /examples/coding_and_scrambling/sv/endec_64b66b_driver_with_scrambler.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_driver_with_scrambler.svh 17 | * PROJECT: physical_coding_algorithms 18 | * 19 | * 20 | * Description: This file contains a specialization of the endec_64b66b driver 21 | * that instantiates a multiplicative type scrambler and descrambler 22 | *******************************************************************************/ 23 | 24 | 25 | `ifndef ENDEC_64b66b_DRIVER_WITH_SCRAMBLER_SVH 26 | `define ENDEC_64b66b_DRIVER_WITH_SCRAMBLER_SVH 27 | 28 | 29 | /* Driver class specialization instantiating a scrambler and a descrambler 30 | * 31 | */ 32 | class endec_64b66b_driver_with_scrambler extends endec_64b66b_ve_drv; 33 | `uvm_component_utils(endec_64b66b_driver_with_scrambler) 34 | 35 | 36 | //parameters for the scrambler and descrambler 37 | parameter ORDER = 64; 38 | parameter TAPS = 'h9010030500008000; 39 | 40 | 41 | // multiplicative scrambler instance 42 | scrambler_multiplicative #(ORDER, TAPS) m_mult_scrambler; 43 | // multiplicative descrambler instance 44 | descrambler_multiplicative #(ORDER, TAPS) m_mult_descrambler; 45 | 46 | 47 | /* Constructor 48 | * @param name : name for this component instance 49 | * @param parent : parent for this component 50 | */ 51 | function new(string name, uvm_component parent); 52 | super.new(name, parent); 53 | 54 | // allocate the multiplicative scrambler and descrambler 55 | m_mult_scrambler = scrambler_multiplicative #(ORDER,TAPS)::type_id::create( 56 | "m_mult_scrambler", 57 | this 58 | ); 59 | m_mult_descrambler = descrambler_multiplicative #(ORDER,TAPS)::type_id::create( 60 | "m_mult_descrambler", 61 | this 62 | ); 63 | endfunction 64 | 65 | 66 | /* UVM build phase 67 | * @param phase - current phase 68 | */ 69 | virtual function void build_phase(uvm_phase phase); 70 | super.build_phase(phase); 71 | endfunction 72 | 73 | 74 | /* UVM connect_phase 75 | * @param phase - current phase 76 | */ 77 | virtual function void connect_phase(uvm_phase phase); 78 | super.connect_phase(phase); 79 | endfunction 80 | 81 | 82 | /* UVM run_phase 83 | * @param phase - current phase 84 | */ 85 | virtual task run_phase(uvm_phase phase); 86 | endec_64b66b_ve_seq_item encoder_item; 87 | 88 | 89 | // bit-stream input for scrambler 90 | bs_t scrmbl_input; 91 | // bit-stream output for scrambler 92 | bs_t scrmbl_output; 93 | // bit-stream output of descrambler 94 | bs_t descrmbl_output; 95 | 96 | 97 | forever begin 98 | // get item from the sequencer 99 | seq_item_port.get_next_item(encoder_item); 100 | 101 | // print item 102 | `uvm_info("DRIVER_64b66b_WITH_SCRAMBLER", encoder_item.convert2string(), UVM_HIGH) 103 | 104 | 105 | // encode 106 | encoder_item.m_code_block_66b = m_encoder_64b66b.encode( 107 | {encoder_item.m_data0,encoder_item.m_data1, 108 | encoder_item.m_control0, 109 | encoder_item.m_control1} 110 | ); 111 | 112 | // update block type of the packet after encoding process has been performed 113 | encoder_item.m_tx_block_type = m_encoder_64b66b.get_tx_block_format(); 114 | `uvm_info( 115 | "DRIVER_64b66b_WITH_SCRAMBLER", 116 | $sformatf("\nEncoder output = %x " , encoder_item.m_code_block_66b), 117 | UVM_MEDIUM 118 | ) 119 | 120 | 121 | // apply scrambling 122 | // serialize the coded 66bits excluding the 2bit header 123 | scrmbl_input = {>>{encoder_item.m_code_block_66b[63:0]}}; 124 | 125 | // call scrambling function on the bit-stream 126 | scrmbl_output = m_mult_scrambler.scramble(scrmbl_input); 127 | 128 | // update endec_64b66b item field holding the scrambled bits 129 | encoder_item.m_scrmbl_code_blk = {>>{scrmbl_output}}; 130 | 131 | // apply de-scrambling 132 | descrmbl_output = m_mult_descrambler.descramble(scrmbl_output); 133 | 134 | // update endec_64b66b item field holding the descrambled bits 135 | encoder_item.m_descrmbl_code_blk = {>>{descrmbl_output}}; 136 | 137 | `uvm_info( 138 | "DRIVER_64b66b_WITH_SCRAMBLER", 139 | $sformatf( 140 | "\nScrambler ouput %x\nDescranbler output %x\n", 141 | encoder_item.m_scrmbl_code_blk, 142 | encoder_item.m_descrmbl_code_blk 143 | ), 144 | UVM_MEDIUM 145 | ) 146 | 147 | 148 | // check scrambler input is the same with descrambler output 149 | assert (encoder_item.m_code_block_66b[63:0] == encoder_item.m_descrmbl_code_blk) else 150 | `uvm_error( 151 | "DRIVER_64b66b_WITH_SCRAMBLER", 152 | $sformatf( 153 | "\nDifference between scrambler input value %x\nand descrambler output value %x", 154 | encoder_item.m_code_block_66b[63:0], 155 | encoder_item.m_descrmbl_code_blk 156 | ) 157 | ) 158 | 159 | 160 | // decode 161 | encoder_item.m_decoded_xgmii_data = m_decoder_64b66b.decode( 162 | {encoder_item.m_code_block_66b[65:64], 163 | encoder_item.m_descrmbl_code_blk} 164 | ); 165 | `uvm_info( 166 | "DRIVER_64b66b_WITH_SCRAMBLER", 167 | $sformatf( 168 | "\Decoder output \ncontrol0 = %x \ndata0 = %x \ncontrol1 = %x \ndata1 = %x \n", 169 | encoder_item.m_decoded_xgmii_data[71:68], 170 | encoder_item.m_decoded_xgmii_data[67:36], 171 | encoder_item.m_decoded_xgmii_data[35:32], 172 | encoder_item.m_decoded_xgmii_data[31:0] 173 | ), 174 | UVM_MEDIUM 175 | ) 176 | 177 | 178 | // send item to scoreboard 179 | m_post_decode_item_ap.write(encoder_item); 180 | 181 | seq_item_port.item_done(); 182 | end 183 | endtask 184 | 185 | endclass 186 | 187 | `endif 188 | -------------------------------------------------------------------------------- /examples/coding_and_scrambling/tests/endec_64b66b_with_scrambler_test.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: endec_64b66b_with_scrambler_test.svh 17 | * PROJECT: physical_coding_algorithms 18 | * 19 | * 20 | * Description: This file contains the test in which the driver of the 21 | * endec_64b66b package uses the scrambling-descrambling 22 | *******************************************************************************/ 23 | 24 | 25 | `ifndef ENDEC_64b66b_WITH_SCRAMBLER_TEST_SV 26 | `define ENDEC_64b66b_WITH_SCRAMBLER_TEST_SV 27 | 28 | 29 | /* Test class with legal sequence 30 | */ 31 | class endec_64b66b_with_scrambler_test extends endec_64b66b_tests_base_test; 32 | `uvm_component_utils(endec_64b66b_with_scrambler_test) 33 | 34 | 35 | /* Constructor 36 | * @param name : name for this component instance 37 | * @param parent : parent for this component 38 | */ 39 | function new(string name, uvm_component parent); 40 | super.new(name, parent); 41 | endfunction 42 | 43 | 44 | /* UVM build phase 45 | * @param phase - current phase 46 | */ 47 | virtual function void build_phase(uvm_phase phase); 48 | // override default driver with driver instantiating scrambler and descrambler 49 | factory.set_type_override_by_type( 50 | endec_64b66b_ve_drv::get_type(), 51 | endec_64b66b_driver_with_scrambler::get_type(), 52 | 1 53 | ); 54 | 55 | super.build_phase(phase); 56 | endfunction 57 | 58 | 59 | /* UVM run phase 60 | * @param phase - current phase 61 | */ 62 | virtual task run_phase(uvm_phase phase); 63 | 64 | endec_64b66b_ve_all_legal_seq seq = endec_64b66b_ve_all_legal_seq::type_id::create( 65 | "seq_64b66b_ve_all_legal", m_env.m_agent_64b66b.m_sequencer_64b66b 66 | ); 67 | 68 | phase.raise_objection(this); 69 | 70 | assert(seq.randomize() with {m_num_of_items inside {20};}); 71 | seq.start(m_env.m_agent_64b66b.m_sequencer_64b66b); 72 | 73 | phase.drop_objection(this); 74 | endtask 75 | 76 | 77 | endclass 78 | 79 | `endif//ENDEC_64b66b_WITH_SCRAMBLER_TEST_SV 80 | -------------------------------------------------------------------------------- /scrambler_descrambler/examples/additive/scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | export PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../../ && pwd )" 4 | export EXAMPLE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../ && pwd )" 5 | 6 | #the default values of the user controlled options 7 | default_test="scrambler_descrambler_additive_test" 8 | 9 | export DUT_MODULE_NAME=scrambler_descrambler_additive 10 | 11 | ${PROJECT_DIR}/examples/common/scripts/run.sh -default_test ${default_test} $@ -------------------------------------------------------------------------------- /scrambler_descrambler/examples/additive/sv/scrambler_descrambler_additive_top.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * NAME: scrambler_descrambler_additive_top.sv 17 | * PROJECT: scrambler_descrambler 18 | * Description: This file contains the declaration of the verilog module used 19 | * in the additive example of scrambler_descrambler pkg. 20 | *******************************************************************************/ 21 | 22 | 23 | `ifndef SCRAMBLER_DESCRAMBLER_ADDITIVE_TOP_SV 24 | `define SCRAMBLER_DESCRAMBLER_ADDITIVE_TOP_SV 25 | 26 | `include "scrambler_descrambler_additive_test.sv" 27 | 28 | 29 | module scrambler_descrambler_additive_top; 30 | 31 | initial begin 32 | run_test("scrambler_descrambler_additive_test"); 33 | end 34 | 35 | endmodule 36 | 37 | `endif -------------------------------------------------------------------------------- /scrambler_descrambler/examples/additive/tests/scrambler_descrambler_additive_test.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: scrambler_descrambler_additive_test.sv 17 | * PROJECT: scrambler_descrambler 18 | * 19 | * 20 | * Description: This is the package file 21 | *******************************************************************************/ 22 | 23 | 24 | `ifndef SCRAMBLER_DESCRAMBLER_ADDITIVE_TEST_SV 25 | `define SCRAMBLER_DESCRAMBLER_ADDITIVE_TEST_SV 26 | 27 | 28 | import uvm_pkg::*; 29 | `include "uvm_macros.svh" 30 | 31 | import scrambler_descrambler_pkg::*; 32 | 33 | 34 | /* Test class 35 | * 36 | */ 37 | class scrambler_descrambler_additive_test extends uvm_test; 38 | `uvm_component_utils(scrambler_descrambler_additive_test) 39 | 40 | 41 | // convenience parameter holding the order of the polynomial 42 | parameter ORDER = 64; 43 | 44 | 45 | // the scrambler and descrambler are actually the same 46 | scrambler_descrambler_additive#(ORDER, 'h8001000000000000) m_add_scrambler; 47 | // descrambler instance 48 | scrambler_descrambler_additive#(ORDER, 'h8001000000000000) m_add_descrambler; 49 | 50 | 51 | /* Constructor 52 | * @param name : name for this component instance 53 | * @param parent : parent for this component 54 | */ 55 | function new(input string name, input uvm_component parent); 56 | // call super.new() 57 | super.new(name, parent); 58 | endfunction 59 | 60 | 61 | /* UVM build phase 62 | * @param phase - current phase 63 | */ 64 | virtual function void build_phase(uvm_phase phase); 65 | super.build_phase(phase); 66 | 67 | m_add_scrambler = scrambler_descrambler_additive #(ORDER, 'h8001000000000000)::type_id::create( 68 | "m_add_scrambler", 69 | this 70 | ); 71 | m_add_descrambler = scrambler_descrambler_additive #(ORDER, 'h8001000000000000)::type_id::create( 72 | "m_add_descrambler", 73 | this 74 | ); 75 | 76 | // load same initial values in both scrambler and descrambler 77 | m_add_scrambler.load_lfsr('h2a); 78 | m_add_descrambler.load_lfsr('h2a); 79 | endfunction 80 | 81 | 82 | /* UVM run_phase 83 | * @param phase - current phase 84 | */ 85 | virtual task run_phase(uvm_phase phase); 86 | // fields used as input or for holding intermediate results 87 | bit[ORDER-1:0] scrambler_input; 88 | bit[ORDER-1:0] scrambler_output; 89 | bit[ORDER-1:0] descrambler_output; 90 | 91 | 92 | // bit-stream input/output from scrambler/descrambler 93 | bs_t bs_input_0; 94 | bs_t bs_output_0; 95 | bs_t bs_input_1; 96 | bs_t bs_output_1; 97 | 98 | //determines number of iteration 99 | int num_of_iterations; 100 | void'(std::randomize(num_of_iterations) with { 101 | (num_of_iterations > 20) && (num_of_iterations < 100); 102 | }); 103 | 104 | for (int iter = 0; iter < num_of_iterations; iter++) begin 105 | // randomize scrambler input 106 | if (!std::randomize(scrambler_input)) begin 107 | `uvm_error("SCRAMBLER_DESCRAMBLER_ADDITIVE_TEST", "Randomizing failed.") 108 | end 109 | 110 | 111 | bs_input_0 = {>>{scrambler_input}}; 112 | `uvm_info( 113 | "SCRAMBLER_DESCRAMBLER_ADDITIVE_TEST", 114 | $sformatf("Scrambler 0 input compact %x",scrambler_input), 115 | UVM_HIGH 116 | ) 117 | 118 | 119 | bs_output_0 = m_add_scrambler.scramble(bs_input_0); 120 | scrambler_output = {>>{bs_output_0}}; 121 | `uvm_info( 122 | "SCRAMBLER_DESCRAMBLER_ADDITIVE_TEST", 123 | $sformatf("Scrambler 0 output compact %x", scrambler_output), 124 | UVM_HIGH 125 | ) 126 | 127 | 128 | bs_input_1 = {>>{scrambler_output}}; 129 | bs_output_1 = m_add_descrambler.descramble(bs_input_1); 130 | descrambler_output = {>>{bs_output_1}}; 131 | `uvm_info( 132 | "SCRAMBLER_DESCRAMBLER_ADDITIVE_TEST", 133 | $sformatf("Descrambler output compact %x\n\n\n",descrambler_output), 134 | UVM_HIGH 135 | ) 136 | 137 | 138 | // perform scoreboarding between scrambler input and descrambler output 139 | assert (scrambler_input == descrambler_output) else 140 | `uvm_error( 141 | "SCRAMBLER_DESCRAMBLER_ADDITIVE_TEST", 142 | $sformatf("\nDifference between scrambler input value %x\nand descrambler output value %x", 143 | scrambler_input, 144 | descrambler_output 145 | ) 146 | ) 147 | end 148 | endtask 149 | 150 | endclass 151 | 152 | 153 | `endif -------------------------------------------------------------------------------- /scrambler_descrambler/examples/common/scripts/options_ius.f: -------------------------------------------------------------------------------- 1 | +incdir+${PROJECT_DIR}/sv/ 2 | 3 | +incdir+${EXAMPLE_DIR}/ 4 | +incdir+${EXAMPLE_DIR}/sv 5 | +incdir+${EXAMPLE_DIR}/tests 6 | 7 | +incdir+${EXAMPLE_DIR}/ 8 | +incdir+${EXAMPLE_DIR}/sv 9 | +incdir+${EXAMPLE_DIR}/tests 10 | -${ARCH_BITS}bit 11 | -linedebug 12 | -uvmlinedebug 13 | +uvm_set_action="*,_ALL_,UVM_ERROR,UVM_DISPLAY|UVM_STOP" 14 | -uvm 15 | -access rw 16 | -sv 17 | -covoverwrite 18 | -coverage all 19 | +UVM_NO_RELNOTES 20 | -DSC_INCLUDE_DYNAMIC_PROCESSES 21 | +define+UVM_OBJECT_MUST_HAVE_CONSTRUCTOR 22 | +UVM_VERBOSITY=UVM_LOW 23 | -timescale 1ns/1ps 24 | 25 | ${TOP_FILE_PATH} 26 | -------------------------------------------------------------------------------- /scrambler_descrambler/examples/common/scripts/options_vcs.f: -------------------------------------------------------------------------------- 1 | -sverilog 2 | 3 | +incdir+${PROJECT_DIR}/sv/ 4 | 5 | +incdir+${EXAMPLE_DIR}/ 6 | +incdir+${EXAMPLE_DIR}/sv 7 | +incdir+${EXAMPLE_DIR}/tests 8 | 9 | +incdir+${EXAMPLE_DIR}/ 10 | +incdir+${EXAMPLE_DIR}/sv 11 | +incdir+${EXAMPLE_DIR}/tests 12 | 13 | ${PROJECT_DIR}/sv/scrambler_descrambler_pkg.sv 14 | ${TOP_FILE_PATH} 15 | -top ${TOP_MODULE_NAME} 16 | -timescale=1ns/1ps -------------------------------------------------------------------------------- /scrambler_descrambler/examples/common/scripts/options_vlog.f: -------------------------------------------------------------------------------- 1 | +incdir+${PROJECT_DIR}/sv/ 2 | 3 | +incdir+${EXAMPLE_DIR}/ 4 | +incdir+${EXAMPLE_DIR}/sv 5 | +incdir+${EXAMPLE_DIR}/tests 6 | 7 | +incdir+${EXAMPLE_DIR}/ 8 | +incdir+${EXAMPLE_DIR}/sv 9 | +incdir+${EXAMPLE_DIR}/tests 10 | -${ARCH_BITS} 11 | -sv 12 | ${PROJECT_DIR}/sv/scrambler_descrambler_pkg.sv 13 | ${TOP_FILE_PATH} 14 | -------------------------------------------------------------------------------- /scrambler_descrambler/examples/common/scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | #the default values of the user controlled options 4 | default_run_mode="batch" 5 | default_tool=ius 6 | default_seed=1; 7 | default_test="NONE" 8 | default_quit_cnt=0 9 | default_verbosity=UVM_MEDIUM 10 | default_arch_bits=64 11 | 12 | while [ $# -gt 0 ]; do 13 | case `echo $1 | tr "[A-Z]" "[a-z]"` in 14 | -default_test) 15 | default_test=$2 16 | break; 17 | ;; 18 | esac 19 | done 20 | 21 | run_mode=${default_run_mode} 22 | tool=${default_tool} 23 | seed=${default_seed} 24 | test=${default_test} 25 | verbosity=${default_verbosity} 26 | quit_cnt=${default_quit_cnt} 27 | ARCH_BITS=${default_arch_bits} 28 | 29 | export TOP_MODULE_NAME=${DUT_MODULE_NAME}_top 30 | export TOP_FILE_NAME=${TOP_MODULE_NAME}.sv 31 | export TOP_FILE_PATH=${EXAMPLE_DIR}/sv/${TOP_FILE_NAME} 32 | 33 | help() { 34 | echo "" 35 | echo "Possible options for this script:" 36 | echo " -i --> run in interactive mode" 37 | echo " -seed --> specify a particular seed for the simulation (default: ${default_seed})" 38 | echo " -test --> specify a particular test to run (default: ${default_test})" 39 | echo " -tool [ius|questa|vcs] --> specify what simulator to use (default: ${default_tool})" 40 | echo " -quit_cnt --> specify after how many errors should the test stop (default: ${default_quit_cnt})" 41 | echo " -verbosity {UVM_NONE|UVM_LOW|UVM_MEDIUM|UVM_HIGH|UVM_FULL|UVM_DEBUG }] --> specify the verbosity of a message (default: ${default_uvm_verbosity})" 42 | echo " -bit[32|64] --> specify what architecture to use: 32 or 64 bits (default: ${default_arch_bits} bits)" 43 | echo " -help --> print this message" 44 | echo "" 45 | } 46 | 47 | run_with_ius_test() { 48 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 49 | 50 | if [ "$run_mode" = "interactive" ]; then 51 | rm -rf ncsim_cmds.tcl 52 | touch ncsim_cmds.tcl 53 | 54 | echo "database -open waves -into waves.shm -default" >> ncsim_cmds.tcl 55 | echo "probe -create ${TOP_MODULE_NAME} -depth all -tasks -functions -uvm -packed 4k -unpacked 16k -all" >> ncsim_cmds.tcl 56 | 57 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -gui -input ncsim_cmds.tcl " 58 | else 59 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -exit " 60 | fi 61 | 62 | irun -f ${PROJECT_DIR}/examples/common/scripts/options_ius.f -svseed ${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} +UVM_MAX_QUIT_COUNT=${quit_cnt} ${EXTRA_OPTIONS} 63 | } 64 | 65 | run_with_vcs_test() { 66 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 67 | 68 | if [ "$run_mode" = "interactive" ]; then 69 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -gui " 70 | fi 71 | 72 | vcs -ntb_opts uvm -f ${PROJECT_DIR}/examples/common/scripts/options_vcs.f +ntb_random_seed=${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} +UVM_MAX_QUIT_COUNT=${quit_cnt} -R ${EXTRA_OPTIONS} 73 | 74 | } 75 | 76 | run_with_questa_test() { 77 | vlib work 78 | vlog -f ${PROJECT_DIR}/examples/common/scripts/options_vlog.f 79 | 80 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} " 81 | 82 | if [ "$run_mode" != "interactive" ]; then 83 | rm -rf vsim_cmds.do 84 | touch vsim_cmds.do 85 | 86 | echo "run -all; exit" >> vsim_cmds.do 87 | 88 | EXTRA_OPTIONS=" ${EXTRA_OPTIONS} -do vsim_cmds.do -c " 89 | fi 90 | 91 | vsim -${ARCH_BITS} -novopt ${TOP_MODULE_NAME} -sv_seed ${seed} +UVM_TESTNAME=${test} +UVM_VERBOSITY=${verbosity} +UVM_MAX_QUIT_COUNT=${quit_cnt} ${EXTRA_OPTIONS} 92 | } 93 | 94 | while [ $# -gt 0 ]; do 95 | case `echo $1 | tr "[A-Z]" "[a-z]"` in 96 | -seed) 97 | seed=$2 98 | ;; 99 | -tool) 100 | tool=$2 101 | ;; 102 | -test) 103 | test=$2 104 | ;; 105 | -verbosity) 106 | verbosity=$2 107 | ;; 108 | -quit_cnt) 109 | quit_cnt=$2 110 | ;; 111 | -i) 112 | run_mode=interactive 113 | ;; 114 | -help) 115 | help 116 | exit 0 117 | ;; 118 | esac 119 | shift 120 | done 121 | 122 | export ARCH_BITS=${ARCH_BITS} 123 | 124 | case $tool in 125 | ius) 126 | echo "Selected tool: IUS..." 127 | ;; 128 | vcs) 129 | echo "Selected tool: VCS..." 130 | ;; 131 | questa) 132 | echo "Selected tool: Questa..." 133 | ;; 134 | *) 135 | echo "Illegal option for tool: $tool" 136 | exit 1; 137 | ;; 138 | esac 139 | 140 | sim_dir=`pwd`/sim_${test} 141 | echo "Start running ${test} test in ${sim_dir}"; 142 | rm -rf ${sim_dir}; 143 | mkdir ${sim_dir}; 144 | cd ${sim_dir}; 145 | run_with_${tool}_test 146 | -------------------------------------------------------------------------------- /scrambler_descrambler/examples/multiplicative/scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | export PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../../ && pwd )" 4 | export EXAMPLE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../ && pwd )" 5 | 6 | #the default values of the user controlled options 7 | default_test="scrambler_descrambler_multiplicative_test" 8 | 9 | export DUT_MODULE_NAME=scrambler_descrambler_multiplicative 10 | 11 | ${PROJECT_DIR}/examples/common/scripts/run.sh -default_test ${default_test} $@ -------------------------------------------------------------------------------- /scrambler_descrambler/examples/multiplicative/sv/scrambler_descrambler_multiplicative_top.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * NAME: scrambler_descrambler_multiplicative_top.sv 17 | * PROJECT: scrambler_descrambler 18 | * Description: This file contains the declaration of the verilog module used 19 | * in the multiplicative example of the scrambler_descrambler pkg. 20 | *******************************************************************************/ 21 | 22 | 23 | `ifndef SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TOP_SV 24 | `define SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TOP_SV 25 | 26 | 27 | `include "scrambler_descrambler_multiplicative_test.sv" 28 | 29 | module scrambler_descrambler_multiplicative_top; 30 | 31 | initial begin 32 | run_test("scrambler_descrambler_multiplicative_test"); 33 | end 34 | 35 | endmodule 36 | 37 | 38 | `endif -------------------------------------------------------------------------------- /scrambler_descrambler/examples/multiplicative/tests/scrambler_descrambler_multiplicative_test.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: scrambler_descrambler_multiplicative_test.sv 17 | * PROJECT: scrambler_descrambler 18 | * 19 | * 20 | * Description: This is the test file for multiplicative scrambler/descrambler 21 | *******************************************************************************/ 22 | 23 | 24 | `ifndef SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TEST_SV 25 | `define SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TEST_SV 26 | 27 | 28 | import uvm_pkg::*; 29 | `include "uvm_macros.svh" 30 | 31 | import scrambler_descrambler_pkg::*; 32 | 33 | 34 | /* Test class 35 | * 36 | */ 37 | class scrambler_descrambler_multiplicative_test extends uvm_test; 38 | `uvm_component_utils(scrambler_descrambler_multiplicative_test) 39 | 40 | 41 | // convenience parameter holding the order of the polynomial 42 | parameter ORDER = 64; 43 | 44 | 45 | // scrambler instance 46 | scrambler_multiplicative#(ORDER, 'h8001000000000000) m_mult_scrambler; 47 | // descrambler instance 48 | descrambler_multiplicative#(ORDER, 'h8001000000000000) m_mult_descrambler; 49 | 50 | /* Constructor 51 | * @param name : name for this component instance 52 | * @param parent : parent for this component 53 | */ 54 | function new(input string name, input uvm_component parent); 55 | // call super.new() 56 | super.new(name, parent); 57 | endfunction 58 | 59 | 60 | /* UVM build phase 61 | * @param phase - current phase 62 | */ 63 | virtual function void build_phase(uvm_phase phase); 64 | super.build_phase(phase); 65 | // the polynomial is x^63 + x^48 66 | m_mult_scrambler = scrambler_multiplicative #(ORDER, 'h8001000000000000)::type_id::create( 67 | "m_mult_scrambler", 68 | this 69 | ); 70 | m_mult_descrambler = descrambler_multiplicative #(ORDER, 'h8001000000000000)::type_id::create( 71 | "m_mult_descrambler", 72 | this 73 | ); 74 | endfunction 75 | 76 | 77 | /* UVM run_phase 78 | * @param phase - current phase 79 | */ 80 | virtual task run_phase(uvm_phase phase); 81 | // fields used as input or for holding intermediate results 82 | bit[ORDER-1:0] scrambler_in; 83 | bit[ORDER-1:0] scrambler_out; 84 | bit[ORDER-1:0] descrambler_out; 85 | 86 | 87 | // bit-stream input/output from scrambler/descrambler 88 | bs_t bs_input_0; 89 | bs_t bs_output_0; 90 | bs_t bs_input_1; 91 | bs_t bs_output_1; 92 | 93 | //determines number of iteration 94 | int num_of_iterations; 95 | void'(std::randomize(num_of_iterations) with { 96 | (num_of_iterations > 10) && (num_of_iterations < 100); 97 | }); 98 | 99 | 100 | for (int iter = 0; iter < num_of_iterations; iter++) begin 101 | // randomize scrambler input 102 | if (!std::randomize(scrambler_in)) begin 103 | `uvm_error("SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TEST", "Randomizing failed.") 104 | end 105 | 106 | 107 | bs_input_0 = {>>{scrambler_in}}; 108 | `uvm_info( 109 | "SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TEST", 110 | $sformatf("Scrambler 0 input compact %x",scrambler_in), 111 | UVM_HIGH 112 | ) 113 | 114 | 115 | bs_output_0 = m_mult_scrambler.scramble(bs_input_0); 116 | scrambler_out = {>>{bs_output_0}}; 117 | `uvm_info( 118 | "SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TEST", 119 | $sformatf("Scrambler 0 output %x", scrambler_out), 120 | UVM_HIGH 121 | ) 122 | 123 | 124 | bs_input_1 = {>>{scrambler_out}}; 125 | bs_output_1 = m_mult_descrambler.descramble(bs_input_1); 126 | descrambler_out = {>>{bs_output_1}}; 127 | `uvm_info( 128 | "SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TEST", 129 | $sformatf("Descrambler output %x\n\n\n",descrambler_out), 130 | UVM_HIGH 131 | ) 132 | 133 | 134 | // perform scoreboarding between scrambler input and descrambler output 135 | assert (scrambler_in == descrambler_out) else 136 | `uvm_error( 137 | "SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TEST", 138 | $sformatf("\nDifference between scrambler input value %x\nand descrambler output value %x", 139 | scrambler_in, descrambler_out) 140 | ) 141 | end 142 | endtask 143 | 144 | endclass 145 | 146 | 147 | `endif//SCRAMBLER_DESCRAMBLER_MULTIPLICATIVE_TEST_SV -------------------------------------------------------------------------------- /scrambler_descrambler/sv/descrambler_multiplicative.svh: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * (C) Copyright 2015 AMIQ Consulting 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | * MODULE: descrambler_multiplicative.svh 18 | * PROJECT: scrambler_descrambler 19 | * 20 | * 21 | * Description: This is the implementation file of the multiplicative descrambler, 22 | * part of the scrambler_descrambler package 23 | *******************************************************************************/ 24 | 25 | 26 | `ifndef DESCRAMBLER_MULTIPLICATIVE_SVH 27 | `define DESCRAMBLER_MULTIPLICATIVE_SVH 28 | 29 | 30 | /* Class implementing multiplicative descrambler function 31 | * @param ORDER : the order of the polynomial 32 | * @param TAPS_IN : value of taps of the polynomial 33 | */ 34 | class descrambler_multiplicative #(int ORDER = 0, bit[ORDER-1:0] TAPS_IN = 0) extends uvm_object; 35 | `uvm_object_param_utils(descrambler_multiplicative #(ORDER, TAPS_IN)) 36 | 37 | 38 | // shift registers for descrambler 39 | local bit[ORDER-1:0] m_lfsr_descrambler; 40 | // taps corresponding to the generating polynomial 41 | local bit[ORDER-1:0] m_taps; 42 | 43 | 44 | /* Constructor 45 | * @param name : name for this component instance 46 | */ 47 | function new(input string name = ""); 48 | super.new(name); 49 | this.m_taps = TAPS_IN; 50 | endfunction 51 | 52 | 53 | /* Descramble function 54 | * @param a_bs_in : current bit input 55 | * @return the descrambled bit-stream output 56 | */ 57 | virtual function bs_t descramble(input bs_t a_bs_in); 58 | bs_t bs_out; 59 | 60 | 61 | bs_out = new[a_bs_in.size()]; 62 | 63 | 64 | foreach (a_bs_in[iter]) begin 65 | // output the vector with the values inside the taps 66 | bit[63:0] taps_out = m_lfsr_descrambler & m_taps; 67 | 68 | byte unsigned num_of_ones = $countones(taps_out); 69 | 70 | bs_out[iter] = a_bs_in[iter] + (num_of_ones%2); 71 | 72 | m_lfsr_descrambler <<= 1; 73 | m_lfsr_descrambler[0] = a_bs_in[iter]; 74 | end 75 | 76 | 77 | return bs_out; 78 | endfunction 79 | 80 | 81 | endclass 82 | 83 | `endif 84 | -------------------------------------------------------------------------------- /scrambler_descrambler/sv/scrambler_descrambler_additive.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: scrambler_descrambler_additive.svh 17 | * PROJECT: scrambler_descrambler 18 | * 19 | * 20 | * Description: This is the implementation file of the additive scrambler 21 | * and descrambler part of the scrambler_descrambler package 22 | *******************************************************************************/ 23 | 24 | 25 | `ifndef SCRAMBLER_DESCRAMBLER_ADDITIVE_SVH 26 | `define SCRAMBLER_DESCRAMBLER_ADDITIVE_SVH 27 | 28 | 29 | /* Class implementing the additive scrambler/descrambler 30 | * Both Additive scrambler and descrambler have the same implementation 31 | * @param ORDER : the order of the polynomial 32 | * @param TAPS_IN : value of taps of the polynomial 33 | */ 34 | class scrambler_descrambler_additive#(int ORDER = 0, bit[ORDER-1:0] TAPS_IN = 0) extends uvm_object; 35 | `uvm_object_param_utils(scrambler_descrambler_additive#(ORDER,TAPS_IN)) 36 | 37 | // shift register 38 | local bit[ORDER-1:0] m_lfsr; 39 | // taps corresponding to the generating polynomial 40 | local bit[ORDER-1:0] m_taps; 41 | 42 | 43 | /* Constructor 44 | * @param name : name for this component instance 45 | */ 46 | function new(input string name = ""); 47 | super.new(name); 48 | this.m_taps = TAPS_IN; 49 | endfunction 50 | 51 | 52 | /* Function that load the shift register with initial value 53 | * @param a_load_value : value to load the shift register with 54 | */ 55 | virtual function void load_lfsr (bit[ORDER-1:0] a_load_value); 56 | this.m_lfsr = a_load_value; 57 | endfunction 58 | 59 | 60 | /* Function updating the lfsr 61 | * 62 | */ 63 | local function void update_lfsr (); 64 | // holds the number of taps that participate in the 65 | // polynomial and have value 1 66 | byte unsigned num_of_ones; 67 | // result vector of and-ing together the polynomial tap vector 68 | // with the value of the lfsr 69 | bit[ORDER-1:0] taps_out; 70 | 71 | taps_out = m_lfsr & m_taps; 72 | num_of_ones = $countones(taps_out); 73 | m_lfsr <<= 1; 74 | m_lfsr[0] = (num_of_ones%2); 75 | endfunction 76 | 77 | 78 | /* Function applying scrambling on input using the shift register 79 | * @param a_bs_in : bit-stream input 80 | * @return bit-stream out 81 | */ 82 | virtual function bs_t scramble (input bs_t a_bs_in); 83 | return scramble_or_descramble(a_bs_in); 84 | endfunction 85 | 86 | /* Function applying descrambling on input using the shift register 87 | * @param a_bs_in : bit-stream input 88 | * @return bit-stream out 89 | */ 90 | virtual function bs_t descramble (input bs_t a_bs_in); 91 | return scramble_or_descramble(a_bs_in); 92 | endfunction 93 | 94 | /* Function applying scrambling/descrambling on input using the shift register 95 | * same function performs both operations 96 | * @param a_bs_in : bit-stream input 97 | * @return bit-stream out 98 | */ 99 | virtual protected function bs_t scramble_or_descramble (input bs_t a_bs_in); 100 | bs_t bs_out; 101 | bs_out = new[a_bs_in.size()]; 102 | 103 | foreach (a_bs_in[iter]) begin 104 | update_lfsr(); 105 | bs_out[iter] = m_lfsr[0] + a_bs_in[iter]; 106 | end 107 | 108 | return bs_out; 109 | endfunction 110 | 111 | 112 | endclass 113 | 114 | `endif -------------------------------------------------------------------------------- /scrambler_descrambler/sv/scrambler_descrambler_pkg.sv: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: scrambler_descrambler_pkg.sv 17 | * PROJECT: scrambler_descrambler 18 | * 19 | * 20 | * Description: This is the package file 21 | *******************************************************************************/ 22 | 23 | `ifndef SCRAMBLER_DESCRAMBLER_PKG_SV 24 | `define SCRAMBLER_DESCRAMBLER_PKG_SV 25 | 26 | package scrambler_descrambler_pkg; 27 | import uvm_pkg::*; 28 | `include "uvm_macros.svh" 29 | 30 | `include "scrambler_descrambler_types.svh"; 31 | `include "scrambler_descrambler_additive.svh"; 32 | `include "scrambler_multiplicative.svh"; 33 | `include "descrambler_multiplicative.svh"; 34 | 35 | endpackage 36 | 37 | `endif//SCRAMBLER_DESCRAMBLER_PKG_SV -------------------------------------------------------------------------------- /scrambler_descrambler/sv/scrambler_descrambler_types.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: scrambler_descrambler_types.svh 17 | * PROJECT: scrambler_descrambler 18 | * 19 | * 20 | * Description: This is the file with the types used by the package 21 | *******************************************************************************/ 22 | 23 | 24 | `ifndef SCRAMBLER_DESCRAMBLER_TYPES_SVH 25 | `define SCRAMBLER_DESCRAMBLER_TYPES_SVH 26 | 27 | 28 | // unpacked array of bits to model streams of bits 29 | typedef bit bs_t[]; 30 | 31 | 32 | `endif -------------------------------------------------------------------------------- /scrambler_descrambler/sv/scrambler_multiplicative.svh: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * (C) Copyright 2015 AMIQ Consulting 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | * MODULE: scrambler_multiplicative.sv 17 | * PROJECT: scrambler_descrambler 18 | * 19 | * 20 | * Description: This is the implementation file of the multiplicative scrambler 21 | * part of the scrambler_descrambler package 22 | *******************************************************************************/ 23 | 24 | 25 | `ifndef SCRAMBLER_MULTIPLICATIVE_SVH 26 | `define SCRAMBLER_MULTIPLICATIVE_SVH 27 | 28 | 29 | /* Class implementing multiplicative scrambler function 30 | * @param ORDER : the order of the polynomial 31 | * @param TAPS_IN : value of taps of the polynomial 32 | */ 33 | class scrambler_multiplicative #(int ORDER = 0, bit[ORDER-1:0] TAPS_IN = 0) extends uvm_object; 34 | `uvm_object_param_utils(scrambler_multiplicative #(ORDER, TAPS_IN)) 35 | 36 | 37 | // shift registers for scrambler 38 | local bit[ORDER-1:0] m_lfsr_scrambler; 39 | // taps corresponding to the generating polynomial 40 | local bit[ORDER-1:0] m_taps; 41 | 42 | 43 | /* Constructor 44 | * @param name : name for this component instance 45 | */ 46 | function new(input string name = ""); 47 | super.new(name); 48 | this.m_taps = TAPS_IN; 49 | endfunction 50 | 51 | 52 | /* Scramble function 53 | * @param a_bs_in : current bit input 54 | * @return the scrambled bit-stream output 55 | */ 56 | virtual function bs_t scramble(input bs_t a_bs_in); 57 | bs_t bs_out; 58 | 59 | 60 | bs_out = new[a_bs_in.size()]; 61 | 62 | 63 | foreach (a_bs_in[iter]) begin 64 | // output the vector with the values inside the taps 65 | bit[63:0] taps_out = m_lfsr_scrambler & m_taps; 66 | 67 | byte unsigned num_of_ones = $countones(taps_out); 68 | 69 | bs_out[iter] = a_bs_in[iter] + (num_of_ones%2); 70 | 71 | m_lfsr_scrambler <<= 1; 72 | m_lfsr_scrambler[0] = bs_out[iter]; 73 | end 74 | 75 | 76 | return bs_out; 77 | endfunction 78 | 79 | 80 | endclass 81 | 82 | `endif 83 | --------------------------------------------------------------------------------