Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are tasked to design your own CRC hardware. a. [8 pts] Create a valid 4-bit

ID: 3592910 • Letter: Y

Question

You are tasked to design your own CRC hardware. a. [8 pts] Create a valid 4-bit Pattern P, and then write a test 6-bit data chunk D, then show your work of calculating the FCS F to get your final transmitted bitstream T and work out the receiver’s calculation to determine if there was an error or not. b. [8 pts] Draw the block diagram for the actual hardware to encode this CRC, and create a timing diagram (like we did on the whiteboard in class) where you show the values of your input, your output, and all of your shift registers as data is streamed into your hardware, and your final output bitstream is created.

Explanation / Answer

subroutine swap_real(a1, a2)

   implicit none

! Input/Output
   real, intent(inout) :: a1(:), a2(:)

! Locals
   integer :: i
   real :: a

! Swap
   do i = 1, min(size(a1), size(a2))
      a = a1(i)
      a1(i) = a2(i)
      a2(i) = a
   enddo

end subroutine swap_real
As in the previous example, an explicit interface to this routine must be available to its caller so that the type signature is known. As before, this is preferably done by placing the function in a MODULE and then USEing the module in the calling routine. An alternative is to use a INTERFACE block.

Internal and Elemental Procedures[edit]

An alternative way to write the swap_real subroutine from the previous example, is:

subroutine swap_real(a1, a2)

   implicit none

! Input/Output
   real, intent(inout) :: a1(:), a2(:)

! Locals
   integer :: N

! Swap, using the internal subroutine
   N = min(size(a1), size(a2))
   call swap_e(a1(:N), a2(:N))

contains
   elemental subroutine swap_e(a1, a2)
      real, intent(inout) :: a1, a2
      real :: a
      a = a1
      a1 = a2
      a2 = a
   end subroutine swap_e
end subroutine swap_real
In the example, the swap_e subroutine is elemental, i.e., it acts upon its array arguments, on an element-by-element basis. Elemental procedures must be pure (i.e., they must have no side effects and can invoke only pure procedures), and all the arguments must be scalar. Since swap_e is internal to the swap_real subroutine, no other program unit can invoke it.

The following program serves as a test for any of the two swap_real subroutines presented:

program test_swap_real
    implicit none

!   explicit interface to the swap_real subroutine
    interface
        subroutine swap_real(a1, a2)
            real, intent(inout) :: a1(:), a2(:)
        end subroutine swap_real
    end interface

!   Declare variables
    integer :: i
    real :: a(10), b(10)

!   Initialize a, b
    a = [(real(i), i = 1, 20, 2)]
    b = a + 1

!   Output before swap
    print '(/"before swap:")'
    print '("a = [", 10f6.1, "]")', a
    print '("b = [", 10f6.1, "]")', b

!   Call the swap_real subroutine
    call swap_real(a, b)

!   Output after swap
    print '(// "after swap:")'
    print '("a = [", 10f6.1, "]")', a
    print '("b = [", 10f6.1, "]")', b

end program test_swap_real
Pointers and targets methods[edit]

In Fortran, the concept of pointers differs from that in C-like languages. A Fortran 90 pointer does not merely store the memory address of a target variable; it also contains additional descriptive information such as the target's rank, the upper and lower bounds of each dimension, and even strides through memory. This allows a Fortran 90 pointer to point at submatrices.

Fortran 90 pointers are "associated" with well-defined "target" variables, via either the pointer assignment operator (=>) or an ALLOCATE statement. When appearing in expressions, pointers are always dereferenced

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote